Add eslint configuration from premium

[MAILPOET-3358]
This commit is contained in:
Jan Lysý
2022-01-27 09:55:08 +01:00
committed by Ján Mikláš
parent 4d6fd85007
commit ed7de702fa
2 changed files with 97 additions and 0 deletions

View File

@ -0,0 +1,32 @@
{
"extends": "airbnb",
"env": {
"browser": true
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"jsx": true
}
},
"plugins": [
"react-hooks"
],
"settings": {
"import/resolver": "webpack"
},
"rules": {
// React hooks rules
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
// Exceptions
"arrow-parens": ["error", "always"],
"comma-dangle": ["error", "always-multiline"],
"import/extensions": 0, // we wouldn't be able to import jQuery without this line
"jsx-a11y/anchor-is-valid": [ "error", {
"components": [ "Link" ],
"specialLink": [ "to" ]
}]
}
}

View File

@ -0,0 +1,65 @@
{
"extends": [
"airbnb",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"env": {
"amd": true,
"browser": true,
"mocha": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"tsconfigRootDir": ".",
"project": ["./tsconfig.json"],
"ecmaVersion": 6,
"ecmaFeatures": {
"jsx": true
}
},
"plugins": [
"react-hooks",
"no-only-tests",
"@typescript-eslint"
],
"settings": {
"import/resolver": "webpack"
},
"rules": {
"no-use-before-define": "off", // disable the original rule, use only the typescript rule on the next line
"@typescript-eslint/no-use-before-define": ["error"],
// PropTypes
"react/prop-types": 0,
"react/jsx-props-no-spreading": 0,
// Hooks
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
// Exceptions
"react/jsx-filename-extension": 0,
"arrow-parens": ["error", "always"],
"comma-dangle": ["error", "always-multiline"],
"no-only-tests/no-only-tests": 2,
"no-script-url": 0,
"import/extensions": 0, // we wouldn't be able to import jQuery without this line
"import/prefer-default-export": 0, // we want to stop using default exports and start using named exports
"react/destructuring-assignment": 0, // that would be too many changes to fix this one
"prefer-destructuring": 0, // that would be too many changes to fix this one
"jsx-a11y/label-has-for": [2, {
"required": {"some": ["nesting", "id"]} // some of our labels are hidden and we cannot nest those
}],
"jsx-a11y/anchor-is-valid": 0, // cannot fix this one, it would break wprdpress themes
"jsx-a11y/label-has-associated-control": [ 2, {
"either": "either" // control has to be either nested or associated via htmlFor
}]
},
"overrides": [
{
"files": ["**/_stories/*.tsx"],
"rules": {
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }]
}
}
]
}