Skip to content

feat(eslint): disable rules conflicting with prettier #132

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
}
Expand Down Expand Up @@ -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": {
Expand Down
33 changes: 2 additions & 31 deletions eslint/index.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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'],
Expand All @@ -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',
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -74,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": {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2861,6 +2861,11 @@ [email protected], 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"
Expand Down