Skip to content

Commit

Permalink
Rework Prettier invocation (mastodon#28851)
Browse files Browse the repository at this point in the history
  • Loading branch information
renchap authored Feb 27, 2024
1 parent dc4427d commit 3b31447
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 361 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ module.exports = defineConfig({
'plugin:import/typescript',
'plugin:promise/recommended',
'plugin:jsdoc/recommended-typescript',
'plugin:prettier/recommended',
],

parserOptions: {
Expand All @@ -347,6 +346,9 @@ module.exports = defineConfig({
},

rules: {
// Disable formatting rules that have been enabled in the base config
'indent': 'off',

'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],

'@typescript-eslint/consistent-type-definitions': ['warn', 'interface'],
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Check formatting
on:
push:
pull_request:

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Set up Javascript environment
uses: ./.github/actions/setup-javascript

- name: Check formatting with Prettier
run: yarn format:check
2 changes: 1 addition & 1 deletion .github/workflows/lint-css.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
- run: echo "::add-matcher::.github/stylelint-matcher.json"

- name: Stylelint
run: yarn lint:sass
run: yarn lint:css
38 changes: 0 additions & 38 deletions .github/workflows/lint-json.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .github/workflows/lint-md.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/lint-yml.yml

This file was deleted.

8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@
# Ignore Docker option files
docker-compose.override.yml

# Ignore public
/public/assets
/public/emoji
/public/packs
/public/packs-test
/public/system

# Ignore emoji map file
/app/javascript/mastodon/features/emoji/emoji_map.json

Expand All @@ -74,4 +81,5 @@ app/javascript/styles/mastodon/reset.scss
# Ignore the generated AUTHORS.md
AUTHORS.md

# Process a few selected JS files
!lint-staged.config.js
20 changes: 7 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,16 @@
"scripts": {
"build:development": "cross-env RAILS_ENV=development NODE_ENV=development ./bin/webpack",
"build:production": "cross-env RAILS_ENV=production NODE_ENV=production ./bin/webpack",
"fix:js": "yarn lint:js --fix",
"fix:json": "prettier --write \"**/*.{json,json5}\"",
"fix:md": "prettier --write \"**/*.md\"",
"fix:sass": "stylelint --fix \"**/*.{css,scss}\" && prettier --write \"**/*.{css,scss}\"",
"fix:yml": "prettier --write \"**/*.{yaml,yml}\"",
"fix": "yarn fix:js && yarn fix:json && yarn fix:sass && yarn fix:yml",
"fix:js": "eslint . --ext=.js,.jsx,.ts,.tsx --cache --report-unused-disable-directives --fix",
"fix:css": "stylelint --fix \"**/*.{css,scss}\"",
"fix": "yarn fix:js && yarn fix:css",
"format": "prettier --write --log-level warn .",
"format:check": "prettier --check --ignore-unknown .",
"i18n:extract": "formatjs extract 'app/javascript/**/*.{js,jsx,ts,tsx}' '--ignore=**/*.d.ts' --out-file app/javascript/mastodon/locales/en.json --format config/formatjs-formatter.js",
"jest": "cross-env NODE_ENV=test jest",
"lint:js": "eslint . --ext=.js,.jsx,.ts,.tsx --cache --report-unused-disable-directives",
"lint:json": "prettier --check \"**/*.{json,json5}\"",
"lint:md": "prettier --check \"**/*.md\"",
"lint:sass": "stylelint \"**/*.{css,scss}\" && prettier --check \"**/*.{css,scss}\"",
"lint:yml": "prettier --check \"**/*.{yaml,yml}\"",
"lint": "yarn lint:js && yarn lint:json && yarn lint:sass && yarn lint:yml",
"lint:css": "stylelint \"**/*.{css,scss}\"",
"lint": "yarn lint:js && yarn lint:css",
"postversion": "git push --tags",
"prepare": "husky",
"start": "node ./streaming/index.js",
Expand Down Expand Up @@ -177,14 +173,12 @@
"@typescript-eslint/parser": "^7.0.0",
"babel-jest": "^29.5.0",
"eslint": "^8.41.0",
"eslint-config-prettier": "^9.0.0",
"eslint-define-config": "^2.0.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-formatjs": "^4.10.1",
"eslint-plugin-import": "~2.29.0",
"eslint-plugin-jsdoc": "^48.0.0",
"eslint-plugin-jsx-a11y": "~6.8.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-promise": "~6.1.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
Expand Down
Loading

0 comments on commit 3b31447

Please sign in to comment.