From df4c26a5a3b5bedd07339ca5d8fa19a012e27790 Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 23 Jun 2021 13:22:48 +0300 Subject: [PATCH 1/3] feat(eslint): disable rules conflicting with prettier Disable rules which can be auto fixed by prettier --- eslint/index.js | 33 ++------------------------------- package.json | 7 ++++--- yarn.lock | 5 +++++ 3 files changed, 11 insertions(+), 34 deletions(-) diff --git a/eslint/index.js b/eslint/index.js index 41757b4..cc6b1f5 100644 --- a/eslint/index.js +++ b/eslint/index.js @@ -1,6 +1,6 @@ module.exports = { parser: '@typescript-eslint/parser', - extends: ['airbnb-typescript', 'airbnb/hooks', 'plugin:@typescript-eslint/recommended'], + extends: ['airbnb-typescript', 'airbnb/hooks', 'plugin:@typescript-eslint/recommended', 'prettier'], parserOptions: { project: './tsconfig.json', ecmaVersion: 2018, @@ -32,30 +32,12 @@ module.exports = { }, rules: { quotes: ['warn', 'single', { avoidEscape: true }], - 'comma-dangle': ['warn', 'always-multiline'], - 'comma-spacing': ['warn', { before: false, after: true }], - 'comma-style': ['warn', 'last'], - 'computed-property-spacing': ['warn', 'never'], - 'func-call-spacing': ['warn', 'never'], - indent: ['warn', 4, { SwitchCase: 1 }], - 'key-spacing': ['warn'], - 'no-trailing-spaces': ['warn'], - 'no-whitespace-before-property': ['warn'], 'padding-line-between-statements': [ 'warn', { blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' }, { blankLine: 'always', prev: '*', next: 'return' }, { blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] }, ], - 'quote-props': ['warn', 'as-needed'], - semi: ['warn'], - 'semi-spacing': ['warn'], - 'semi-style': ['warn'], - 'space-before-blocks': ['warn'], - 'space-in-parens': ['warn'], - 'space-infix-ops': ['warn'], - 'space-unary-ops': ['warn'], - 'switch-colon-spacing': ['warn'], 'no-shadow': 'off', // This rules conflicts with prettier formatter 'operator-linebreak': 'off', @@ -96,8 +78,6 @@ module.exports = { ], // React - 'react/jsx-indent': ['warn', 4], - 'react/jsx-indent-props': ['warn', 4], 'react/jsx-curly-spacing': ['warn', { when: 'always', children: true }], 'react/jsx-fragments': ['warn', 'element'], 'react/static-property-placement': ['error', 'static public field'], @@ -120,22 +100,13 @@ module.exports = { ], // typescript - '@typescript-eslint/indent': [ - 'warn', - 4, - { - SwitchCase: 1, - ignoredNodes: ['TSTypeParameterInstantiation'], - }, - ], + '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/array-type': [ 'error', { default: 'array-simple', readonly: 'array-simple' }, ], - '@typescript-eslint/type-annotation-spacing': 'error', - '@typescript-eslint/member-delimiter-style': 'error', '@typescript-eslint/consistent-type-assertions': 'error', '@typescript-eslint/no-array-constructor': 'error', '@typescript-eslint/no-empty-interface': 'error', diff --git a/package.json b/package.json index 0d14f0a..4fbce76 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "command-line-args": "5.1.1", "conventional-changelog-cli": "2.1.0", "conventional-github-releaser": "3.1.5", + "eslint-config-prettier": "^8.3.0", "stylelint-config-prettier": "^8.0.2", "stylelint-prettier": "^1.1.2" }, @@ -24,16 +25,16 @@ "eslint-config-airbnb-typescript": "^9.0.0", "eslint-import-resolver-typescript": "^2.2.1", "eslint-plugin-cypress": "2.11.1", + "eslint-plugin-dirnames": "^1.0.3", "eslint-plugin-import": "^2.22.0", "eslint-plugin-jsx-a11y": "^6.3.1", "eslint-plugin-prettier": "^3.1.4", "eslint-plugin-react": "^7.20.6", "eslint-plugin-react-hooks": "^4.1.0", "eslint-plugin-simple-import-sort": "^5.0.3", + "eslint-plugin-unicorn": "^18.0.1", "husky": "^4.2.5", "lint-staged": "^10.2.13", - "eslint-plugin-unicorn": "^18.0.1", - "eslint-plugin-dirnames": "^1.0.3", "prettier": "^2.1.1", "prettier-eslint": "^11.0.0", "prettier-eslint-cli": "^5.0.0", @@ -54,13 +55,13 @@ "eslint-import-resolver-typescript": "2.2.1", "eslint-plugin-cypress": "2.11.1", "eslint-plugin-dirnames": "1.0.3", - "eslint-plugin-unicorn": "18.0.1", "eslint-plugin-import": "^2.22.0", "eslint-plugin-jsx-a11y": "^6.3.1", "eslint-plugin-prettier": "3.1.4", "eslint-plugin-react": "^7.20.6", "eslint-plugin-react-hooks": "^4.1.0", "eslint-plugin-simple-import-sort": "5.0.3", + "eslint-plugin-unicorn": "18.0.1", "husky": "4.2.5", "lint-staged": "10.2.13", "prettier": "2.1.1", diff --git a/yarn.lock b/yarn.lock index 86cbdab..8318452 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2861,6 +2861,11 @@ eslint-config-airbnb@18.2.0, eslint-config-airbnb@^18.2.0: object.assign "^4.1.0" object.entries "^1.1.2" +eslint-config-prettier@^8.3.0: + version "8.3.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz#f7471b20b6fe8a9a9254cc684454202886a2dd7a" + integrity sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew== + eslint-import-resolver-node@^0.3.3: version "0.3.4" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz#85ffa81942c25012d8231096ddf679c03042c717" From f7ee10c2e17cf083d9129bda3778e5d891691dab Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 23 Jun 2021 18:24:38 +0300 Subject: [PATCH 2/3] feat(*): add test for format --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4fbce76..81a61a2 100644 --- a/package.json +++ b/package.json @@ -75,9 +75,10 @@ "github-release": "conventional-github-releaser -p angular", "lint": "eslint ./", "precommit": "lint-staged", - "test": "yarn test:eslint && yarn test:stylelint", + "test": "yarn test:eslint && yarn test:stylelint && yarn test:format", "test:eslint": "eslint \"./test/**/*.{ts,tsx,js,jsx}\"", "test:stylelint": "node ./test/stylelint-test.js", + "test:format": "prettier-eslint --list-different $INIT_CWD/test/**/*.{ts,tsx,js,jsx,css}", "format": "prettier-eslint --write $INIT_CWD/{eslint,stylelint,test,commitlint}/**/*.{ts,tsx,js,jsx,css}" }, "lint-staged": { From b0b27f6cc3437f4990a985d5dc6500149315a039 Mon Sep 17 00:00:00 2001 From: Ivan Date: Wed, 23 Jun 2021 18:25:52 +0300 Subject: [PATCH 3/3] feat(*): update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85675a4..38bd084 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,8 @@ npm info "arui-presets-lint@latest" peerDependencies "scripts": { "lint:css": "stylelint ./src/**/*.css", "lint:scripts": "eslint \"**/*.{js,jsx,ts,tsx}\" --ext .js,.jsx,.ts,.tsx", - "lint": "yarn lint:css && yarn lint:scripts", + "check-format": "prettier-eslint --list-different $INIT_CWD/{config,src}/**/*.{ts,tsx,js,jsx,css}", + "lint": "yarn lint:css && yarn lint:scripts && yarn check-format", "format": "prettier-eslint --write $INIT_CWD/{config,src}/**/*.{ts,tsx,js,jsx,css}" } } @@ -106,7 +107,8 @@ coverage "scripts": { "lint:css": "stylelint ./src/**/*.css", "lint:scripts": "eslint \"**/*.{js,jsx,ts,tsx}\" --ext .js,.jsx,.ts,.tsx", - "lint": "yarn lint:css && yarn lint:scripts", + "check-format": "prettier-eslint --list-different $INIT_CWD/{config,src}/**/*.{ts,tsx,js,jsx,css}", + "lint": "yarn lint:css && yarn lint:scripts && yarn check-format", "format": "prettier-eslint --write $INIT_CWD/{config,src}/**/*.{ts,tsx,js,jsx,css}" }, "lint-staged": {