create js, ts and react configurations

This commit is contained in:
Sergey Krylov 2024-01-15 07:03:53 +03:00
parent 3b2508c482
commit 4345b4ac7e
18 changed files with 3813 additions and 622 deletions

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
20.10.0

View File

@ -1,10 +1,20 @@
module.exports = {
extends: [
require.resolve('./rules/base'),
overrides: [
{
files: ['**/*.js'],
extends: [require.resolve('./js-base')],
},
{
files: ['**/*.jsx'],
extends: [require.resolve('./js-react')],
},
{
files: ['**/*.ts'],
extends: [require.resolve('./ts-base')],
},
{
files: ['**/*.tsx'],
extends: [require.resolve('./ts-react')],
},
],
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
rules: {},
};

7
js-base.js Normal file
View File

@ -0,0 +1,7 @@
module.exports = {
extends: [
'./rules/.eslint-js',
'./rules/.eslint-import',
'./rules/style/.eslint-style-js',
].map(require.resolve)
};

9
js-react.js Normal file
View File

@ -0,0 +1,9 @@
module.exports = {
extends: [
'./js-base',
'./rules/react/.eslint-jsx-a11y',
'./rules/react/.eslint-react',
'./rules/react/.eslint-react-hooks',
'./rules/style/.eslint-style-jsx',
].map(require.resolve),
};

View File

@ -1,23 +1,9 @@
{
"author": "Sergey Krylov",
"author": "Sergey <ksv741@gmail.com> Krylov",
"bugs": {
"url": "https://github.com/ksv741/eslint-config-ksv741/issues"
},
"dependencies": {
"confusing-browser-globals": "^1.0.11"
},
"description": "",
"devDependencies": {
"eslint": "^7.32.0 || ^8.2.0"
},
"engines": {
"node": ">-12.15.0"
},
"exports": {
".": "./index.js",
"./rules/base": "./rules/base.js",
"./package.json": "./package.json"
},
"description": "Eslint config for JavaScript, Typescript and React by ksv741",
"homepage": "https://github.com/ksv741/eslint-config-ksv741",
"keywords": [
"eslint",
@ -31,15 +17,43 @@
"es2018"
],
"license": "MIT",
"main": "index.js",
"name": "eslint-config-ksv741",
"peerDependencies": {
"eslint": "^7.32.0 || ^8.2.0",
"eslint-plugin-import": "^2.28.0"
},
"repository": {
"type": "git",
"url": "https://github.com/ksv741/eslint-config-ksv741"
},
"version": "0.0.1"
"version": "0.0.1",
"devDependencies": {
"eslint": "8.56.0"
},
"main": "index.js",
"engines": {
"node": ">=16.13.0"
},
"dependencies": {
"@stylistic/eslint-plugin": "1.5.4",
"@typescript-eslint/eslint-plugin": "6.20.0",
"@typescript-eslint/parser": "6.20.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jsx-a11y": "6.8.0",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0"
},
"peerDependencies": {
"eslint": "^8.56.0",
"typescript": ">=4.2.2"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
},
"exports": {
".": "./index.js",
"./js-base": "./js-base.js",
"./js-react": "./js-react.js",
"./ts-react": "./ts-react.js",
"./ts-base": "./ts-base.js"
}
}

120
rules/.eslint-import.js Normal file
View File

@ -0,0 +1,120 @@
module.exports = {
plugins: [
'import',
],
rules: {
'import/consistent-type-specifier-style': ['off', 'prefer-top-level'],
'import/default': 'error',
'import/dynamic-import-chunkname': 'off',
'import/export': 'error',
'import/exports-last': 'off',
'import/extensions': ['error', 'ignorePackages', {
'mjs': 'never',
'cjs': 'never',
'js': 'never',
}],
'import/first': 'error',
'import/group-exports': 'off',
'import/max-dependencies': ['warn', {
'max': 15,
}],
'import/named': 'error',
'import/namespace': 'off',
'import/newline-after-import': 'error',
'import/no-absolute-path': 'error',
'import/no-amd': 'error',
'import/no-anonymous-default-export': ['error', {
'allowArray': false,
'allowArrowFunction': false,
'allowAnonymousClass': false,
'allowAnonymousFunction': false,
'allowLiteral': false,
'allowObject': false,
}],
'import/no-commonjs': 'off',
'import/no-cycle': ['error', {
'maxDepth': '∞',
}],
'import/no-default-export': 'off',
'import/no-deprecated': 'warn',
'import/no-duplicates': 'error',
'import/no-dynamic-require': 'error',
'import/no-empty-named-blocks': 'error',
'import/no-extraneous-dependencies': ['error', {
'devDependencies': [
'test/**',
'tests/**',
'spec/**',
'**/__tests__/**',
'**/__mocks__/**',
'test.{js,jsx}',
'test-*.{js,jsx}',
'**/*{.,_}{test,spec}.{js,jsx}',
'**/jest.config.js',
'**/jest.setup.js',
'**/vue.config.js',
'**/webpack.config.js',
'**/webpack.config.*.js',
'**/rollup.config.js',
'**/rollup.config.*.js',
'**/gulpfile.js',
'**/gulpfile.*.js',
'**/Gruntfile{,.js}',
'**/protractor.conf.js',
'**/protractor.conf.*.js',
'**/karma.conf.js',
'**/.eslintrc.js',
],
'optionalDependencies': false,
}],
'import/no-import-module-exports': ['error', {
'exceptions': [],
}],
'import/no-internal-modules': 'off',
'import/no-mutable-exports': 'error',
'import/no-named-as-default': 'error',
'import/no-named-as-default-member': 'error',
'import/no-named-default': 'error',
'import/no-named-export': 'off',
'import/no-namespace': 'off',
'import/no-nodejs-modules': 'off',
'import/no-relative-packages': 'error',
'import/no-relative-parent-imports': 'off',
'import/no-restricted-paths': 'off',
'import/no-self-import': 'error',
'import/no-unassigned-import': 'off',
'import/no-unresolved': ['error', {
'commonjs': true,
'caseSensitive': true,
}],
'import/no-unused-modules': 'off',
'import/no-useless-path-segments': ['error', {
'commonjs': true,
}],
'import/no-webpack-loader-syntax': 'error',
'import/order': ['error', {
'groups': [
[
'builtin',
'external',
'internal',
],
],
}],
'import/prefer-default-export': 'off',
'import/unambiguous': 'off',
},
settings: {
'import/resolver': {
node: {
extensions: ['.mjs', '.cjs', '.js', '.json'],
},
},
'import/extensions': ['.mjs', '.cjs', '.js', '.json'],
'import/core-modules': [],
'import/ignore': [
'node_modules',
'\\.(coffee|scss|css|less|hbs|svg|json)$',
],
},
}

426
rules/.eslint-js.js Normal file
View File

@ -0,0 +1,426 @@
module.exports = {
env: {
browser: true,
node: true,
},
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
'accessor-pairs': 'off',
'array-callback-return': ['error', {
'allowImplicit': true,
}],
'arrow-body-style': ['error', 'as-needed', {
'requireReturnForObjectLiteral': false,
}],
'block-scoped-var': 'error',
'camelcase': ['error', {
'properties': 'never',
'ignoreDestructuring': false,
}],
'capitalized-comments': ['off', 'never', {
'line': {
'ignorePattern': '.*',
'ignoreInlineComments': true,
'ignoreConsecutiveComments': true,
},
'block': {
'ignorePattern': '.*',
'ignoreInlineComments': true,
'ignoreConsecutiveComments': true,
},
}],
'class-methods-use-this': ['warn', {
'exceptMethods': [],
}],
'complexity': ['off', 20],
'consistent-return': 'error',
'consistent-this': 'off',
'constructor-super': 'error',
'curly': ['error', 'multi-line'],
'default-case': ['error', {
'commentPattern': '^no default$',
}],
'default-case-last': 'error',
'default-param-last': 'error',
'dot-notation': ['error', {
'allowKeywords': true,
}],
'eqeqeq': ['error', 'always', {
'null': 'ignore',
}],
'for-direction': 'error',
'func-name-matching': ['off', 'always', {
'includeCommonJSModuleExports': false,
'considerPropertyDescriptor': true,
}],
'func-names': 'warn',
'func-style': ['error', 'expression'],
'getter-return': ['error', {
'allowImplicit': true,
}],
'grouped-accessor-pairs': 'error',
'guard-for-in': 'error',
'id-denylist': 'off',
'id-length': 'off',
'id-match': 'off',
'init-declarations': 'off',
'line-comment-position': ['off', {
'position': 'above',
'ignorePattern': null,
'applyDefaultPatterns': true,
}],
'logical-assignment-operators': ['error', 'always'],
'max-classes-per-file': ['error', 1],
'max-depth': 'off',
'max-lines': 'off',
'max-lines-per-function': 'off',
'max-nested-callbacks': 'off',
'max-params': ['warn', {
max: 3
}],
'max-statements': 'off',
'multiline-comment-style': ['off', 'starred-block',],
'new-cap': ['error', {
'newIsCap': true,
'newIsCapExceptions': [],
'capIsNew': false,
'capIsNewExceptions': [
'Immutable.Map',
'Immutable.Set',
'Immutable.List',
],
}],
'no-alert': 'error',
'no-array-constructor': 'error',
'no-async-promise-executor': 'error',
'no-await-in-loop': 'error',
'no-bitwise': 'error',
'no-caller': 'error',
'no-case-declarations': 'error',
'no-class-assign': 'error',
'no-compare-neg-zero': 'error',
'no-cond-assign': ['error', 'always',],
'no-console': 'warn',
'no-const-assign': 'error',
'no-constant-binary-expression': 'off',
'no-constant-condition': 'warn',
'no-constructor-return': 'error',
'no-continue': 'off',
'no-control-regex': 'error',
'no-debugger': 'error',
'no-delete-var': 'error',
'no-div-regex': 'off',
'no-dupe-args': 'error',
'no-dupe-class-members': 'error',
'no-dupe-else-if': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
'no-duplicate-imports': 'off',
'no-else-return': ['error', {
'allowElseIf': false,
}],
'no-empty': 'error',
'no-empty-character-class': 'error',
'no-empty-function': ['error', {
'allow': [
'arrowFunctions',
'functions',
'methods',
],
}],
'no-empty-pattern': 'error',
'no-empty-static-block': 'error',
'no-eq-null': 'error',
'no-eval': 'error',
'no-ex-assign': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-extra-boolean-cast': 'error',
'no-extra-label': 'error',
'no-fallthrough': 'error',
'no-func-assign': 'error',
'no-global-assign': ['error', {
'exceptions': [],
}],
'no-implicit-coercion': ['off', {
'boolean': false,
'number': true,
'string': true,
'allow': [],
}],
'no-implicit-globals': 'off',
'no-implied-eval': 'error',
'no-import-assign': 'error',
'no-inline-comments': 'off',
'no-inner-declarations': 'error',
'no-invalid-regexp': 'error',
'no-invalid-this': 'off',
'no-irregular-whitespace': 'error',
'no-iterator': 'error',
'no-label-var': 'error',
'no-labels': ['error', {
'allowLoop': false,
'allowSwitch': false,
}],
'no-lone-blocks': 'error',
'no-lonely-if': 'error',
'no-loop-func': 'error',
'no-loss-of-precision': 'error',
'no-magic-numbers': 'off',
'no-misleading-character-class': 'error',
'no-multi-assign': 'error',
'no-multi-str': 'error',
'no-negated-condition': 'off',
'no-nested-ternary': 'error',
'no-new': 'error',
'no-new-func': 'error',
'no-new-native-nonconstructor': 'error',
'no-new-symbol': 'error',
'no-new-wrappers': 'error',
'no-nonoctal-decimal-escape': 'error',
'no-obj-calls': 'error',
'no-object-constructor': 'error',
'no-octal': 'error',
'no-octal-escape': 'error',
'no-param-reassign': ['error', {
'props': true,
'ignorePropertyModificationsFor': [
'acc',
'accumulator',
'e',
'ctx',
'context',
'req',
'request',
'res',
'response',
'$scope',
'staticContext',
],
}],
'no-plusplus': ['error', {
'allowForLoopAfterthoughts': true
}],
'no-promise-executor-return': 'error',
'no-proto': 'error',
'no-prototype-builtins': 'error',
'no-redeclare': 'error',
'no-regex-spaces': 'error',
'no-restricted-exports': ['error', {
'restrictedNamedExports': [
'default then',
],
}],
'no-restricted-globals': ['error',
{
'name': 'event',
'message': 'Use local parameter instead.',
},
{
'name': 'fdescribe',
'message': 'Do not commit fdescribe. Use describe instead.',
},
],
'no-restricted-imports': ['off', {
'paths': [],
'patterns': [],
}],
'no-restricted-properties': ['error',
{
'object': 'arguments',
'property': 'callee',
'message': 'arguments.callee is deprecated',
},
{
'object': 'global',
'property': 'isFinite',
'message': 'Please use Number.isFinite instead',
},
{
'object': 'self',
'property': 'isFinite',
'message': 'Please use Number.isFinite instead',
},
{
'object': 'window',
'property': 'isFinite',
'message': 'Please use Number.isFinite instead',
},
{
'object': 'global',
'property': 'isNaN',
'message': 'Please use Number.isNaN instead',
},
{
'object': 'self',
'property': 'isNaN',
'message': 'Please use Number.isNaN instead',
},
{
'object': 'window',
'property': 'isNaN',
'message': 'Please use Number.isNaN instead',
},
{
'property': '__defineGetter__',
'message': 'Please use Object.defineProperty instead.',
},
{
'property': '__defineSetter__',
'message': 'Please use Object.defineProperty instead.',
},
{
'object': 'Math',
'property': 'pow',
'message': 'Use the exponentiation operator (**) instead.',
},
],
'no-restricted-syntax': ['error',
{
'selector': 'LabeledStatement',
'message': 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
'selector': 'WithStatement',
'message': '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
'no-return-assign': ['error', 'always'],
'no-script-url': 'error',
'no-self-assign': ['error', {
'props': true,
}],
'no-self-compare': 'error',
'no-sequences': 'error',
'no-setter-return': 'error',
'no-shadow': 'error',
'no-shadow-restricted-names': 'error',
'no-sparse-arrays': 'error',
'no-template-curly-in-string': 'error',
'no-ternary': 'off',
'no-this-before-super': 'error',
'no-throw-literal': 'error',
'no-undef': 'error',
'no-undef-init': 'error',
'no-undefined': 'error',
'no-underscore-dangle': 'off',
'no-unexpected-multiline': 'error',
'no-unmodified-loop-condition': 'off',
'no-unneeded-ternary': ['error', {
'defaultAssignment': false,
}],
'no-unreachable': 'error',
'no-unreachable-loop': ['error', {
'ignore': [],
}],
'no-unsafe-finally': 'error',
'no-unsafe-negation': 'error',
'no-unsafe-optional-chaining': ['error', {
'disallowArithmeticOperators': true,
}],
'no-unused-expressions': ['error', {
'allowShortCircuit': false,
'allowTernary': false,
'allowTaggedTemplates': false,
}],
'no-unused-labels': 'error',
'no-unused-private-class-members': 'error',
'no-unused-vars': ['error', {
'vars': 'all',
'args': 'after-used',
'ignoreRestSiblings': true,
}],
'no-use-before-define': ['error', {
'functions': true,
'classes': true,
'variables': true,
}],
'no-useless-backreference': 'error',
'no-useless-call': 'off',
'no-useless-catch': 'error',
'no-useless-computed-key': 'error',
'no-useless-concat': 'error',
'no-useless-constructor': 'error',
'no-useless-escape': 'error',
'no-useless-rename': ['error', {
'ignoreDestructuring': false,
'ignoreImport': false,
'ignoreExport': false,
}],
'no-useless-return': 'error',
'no-var': 'error',
'no-void': 'error',
'no-warning-comments': ['off', {
'terms': [
'todo',
'fixme',
'xxx',
],
'location': 'start',
}],
'no-with': 'error',
'object-shorthand': ['error', 'always', {
'ignoreConstructors': false,
'avoidQuotes': true,
}],
'one-var': ['error', 'never'],
'operator-assignment': ['error', 'always'],
'prefer-arrow-callback': ['error', {
'allowNamedFunctions': false,
'allowUnboundThis': true,
}],
'prefer-const': ['error', {
'destructuring': 'any',
'ignoreReadBeforeAssign': true,
}],
'prefer-destructuring': ['error',
{
'VariableDeclarator': {
'array': false,
'object': true,
},
'AssignmentExpression': {
'array': true,
'object': false,
},
},
{
'enforceForRenamedProperties': false,
},
],
'prefer-exponentiation-operator': 'error',
'prefer-named-capture-group': 'off',
'prefer-numeric-literals': 'error',
'prefer-object-has-own': 'error',
'prefer-object-spread': 'error',
'prefer-promise-reject-errors': ['error', {
'allowEmptyReject': true,
}],
'prefer-regex-literals': ['error', {
'disallowRedundantWrapping': true,
}],
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'error',
'radix': 'error',
'require-atomic-updates': 'off',
'require-await': 'error',
'require-unicode-regexp': 'off',
'require-yield': 'error',
'sort-imports': 'off',
'sort-keys': 'off',
'sort-vars': 'error',
'strict': ['error', 'never'],
'symbol-description': 'error',
'unicode-bom': ['error', 'never'],
'use-isnan': 'error',
'valid-typeof': ['error', {
'requireStringLiterals': true,
}],
'vars-on-top': 'error',
'yoda': 'error',
}
}

270
rules/.eslint-ts.js Normal file
View File

@ -0,0 +1,270 @@
const { rules: baseRules } = require('./.eslint-js.js');
const { rules: importsRules, settings: importSettings } = require('./.eslint-import.js');
module.exports = {
plugins: [
'@typescript-eslint'
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.d.ts'],
},
'import/resolver': {
...importSettings['import/resolver'],
node: {
...importSettings['import/resolver'].node,
extensions: [
...importSettings['import/resolver'].node.extensions,
'.ts',
'.d.ts'
],
},
typescript: {
'alwaysTryTypes': true,
project: 'tsconfig.json',
},
},
'import/extensions': [...importSettings['import/extensions'], '.ts', '.d.ts'],
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
},
rules: {
'constructor-super': 'off',
'getter-return': 'off',
'no-const-assign': 'off',
'no-dupe-args': 'off',
'no-dupe-keys': 'off',
'no-func-assign': 'off',
'no-import-assign': 'off',
'no-new-symbol': 'off',
'no-obj-calls': 'off',
'no-setter-return': 'off',
'no-this-before-super': 'off',
'no-undef': 'off',
'no-unreachable': 'off',
'no-unsafe-negation': 'off',
camelcase: 'off',
'@typescript-eslint/naming-convention': ['error',
{
selector: 'enum',
format: ['UPPER_CASE'],
},
{
selector: 'variable',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
},
{
selector: 'function',
format: ['camelCase', 'PascalCase'],
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
],
'default-param-last': 'off',
'@typescript-eslint/default-param-last': baseRules['default-param-last'],
'dot-notation': 'off',
'@typescript-eslint/dot-notation': baseRules['dot-notation'],
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': baseRules['no-array-constructor'],
'no-dupe-class-members': 'off',
'@typescript-eslint/no-dupe-class-members': baseRules['no-dupe-class-members'],
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': baseRules['no-empty-function'],
'no-implied-eval': 'off',
'no-new-func': 'off',
'@typescript-eslint/no-implied-eval': baseRules['no-implied-eval'],
'no-loss-of-precision': 'off',
'@typescript-eslint/no-loss-of-precision': baseRules['no-loss-of-precision'],
'no-loop-func': 'off',
'@typescript-eslint/no-loop-func': baseRules['no-loop-func'],
'no-magic-numbers': 'off',
'@typescript-eslint/no-magic-numbers': baseRules['no-magic-numbers'],
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': baseRules['no-redeclare'],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': baseRules['no-shadow'],
'no-throw-literal': 'off',
'@typescript-eslint/no-throw-literal': baseRules['no-throw-literal'],
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': baseRules['no-unused-expressions'],
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': baseRules['no-unused-vars'],
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': baseRules['no-use-before-define'],
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': baseRules['no-useless-constructor'],
'require-await': 'off',
'@typescript-eslint/require-await': baseRules['require-await'],
'@typescript-eslint/return-await': ['error', 'in-try-catch'],
'import/extensions': [
importsRules['import/extensions'][0],
importsRules['import/extensions'][1],
{
...importsRules['import/extensions'][2],
ts: 'never',
},
],
'import/no-extraneous-dependencies': [
importsRules['import/no-extraneous-dependencies'][0],
{
...importsRules['import/no-extraneous-dependencies'][1],
devDependencies: importsRules[
'import/no-extraneous-dependencies'
][1].devDependencies.reduce((result, devDep) => {
const toAppend = [devDep];
const devDepWithTs = devDep.replace(/\bjs(x?)\b/g, 'ts$1');
if (devDepWithTs !== devDep) {
toAppend.push(devDepWithTs);
}
return [...result, ...toAppend];
}, []),
},
],
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-tslint-comment': 'error',
'@typescript-eslint/ban-types': 'error',
'@typescript-eslint/class-literal-property-style': 'error',
'class-methods-use-this': 'off',
'@typescript-eslint/class-methods-use-this': baseRules['class-methods-use-this'],
'@typescript-eslint/consistent-generic-constructors': 'error',
'@typescript-eslint/consistent-indexed-object-style': 'error',
'@typescript-eslint/consistent-type-assertions': ['error', {
assertionStyle: 'as',
}],
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': ['error', {
prefer: 'type-imports'
}],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'init-declarations': 'off',
'@typescript-eslint/init-declarations': baseRules['init-declarations'],
'max-params': 'off',
'@typescript-eslint/max-params': baseRules['max-params'],
'@typescript-eslint/member-ordering': 'error',
'@typescript-eslint/method-signature-style': ['error', 'property'],
'@typescript-eslint/no-array-delete': 'off',
'@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
'@typescript-eslint/no-confusing-void-expression': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
'@typescript-eslint/no-duplicate-type-constituents': 'error',
'@typescript-eslint/no-dynamic-delete': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'no-invalid-this': 'off',
'@typescript-eslint/no-invalid-this': baseRules['no-invalid-this'],
'@typescript-eslint/no-invalid-void-type': 'error',
'@typescript-eslint/no-meaningless-void-operator': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-misused-promises': 'error',
'@typescript-eslint/no-mixed-enums': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-redundant-type-constituents': 'error',
'@typescript-eslint/no-require-imports': 'error',
'no-restricted-imports': 'off',
'@typescript-eslint/no-restricted-imports': baseRules['no-restricted-imports'],
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
'@typescript-eslint/no-unsafe-enum-comparison': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
'@typescript-eslint/no-unsafe-unary-minus': 'error',
'@typescript-eslint/no-useless-empty-export': 'error',
'@typescript-eslint/no-useless-template-literals': 'error',
'@typescript-eslint/no-var-requires': 'error',
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
'@typescript-eslint/parameter-properties': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'prefer-destructuring': 'off',
'@typescript-eslint/prefer-destructuring': baseRules['prefer-destructuring'],
'@typescript-eslint/prefer-enum-initializers': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-literal-enum-member': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-promise-reject-errors': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/prefer-readonly-parameter-types': 'off',
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
'@typescript-eslint/prefer-regexp-exec': 'error',
'@typescript-eslint/prefer-return-this-type': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/prefer-ts-expect-error': 'off',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/restrict-template-expressions': 'error',
'@typescript-eslint/sort-type-constituents': 'error',
'@typescript-eslint/strict-boolean-expressions': 'error',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/triple-slash-reference': 'error',
'@typescript-eslint/typedef': 'error',
'@typescript-eslint/unbound-method': 'error',
'@typescript-eslint/unified-signatures': 'error',
},
}

View File

@ -1,593 +0,0 @@
const confusingBrowserGlobals = require('confusing-browser-globals');
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: {
generators: false,
objectLiteralDuplicateProperties: false,
},
},
rules: {
'accessor-pairs': 'off',
'array-callback-return': ['error', { allowImplicit: true }],
'block-scoped-var': 'error',
complexity: ['off', 20],
'class-methods-use-this': ['error', { exceptMethods: [] }],
'consistent-return': 'error',
curly: 'error',
'default-case': ['error', { commentPattern: '^no default$' }],
'default-case-last': 'error',
'default-param-last': 'error',
'dot-notation': ['error', { allowKeywords: true }],
'dot-location': ['error', 'property'],
eqeqeq: ['error', 'always', { null: 'ignore' }],
'grouped-accessor-pairs': 'error',
'guard-for-in': 'error',
'max-classes-per-file': ['error', 1],
'no-alert': 'warn',
'no-caller': 'error',
'no-case-declarations': 'error',
'no-constructor-return': 'error',
'no-div-regex': 'off',
'no-else-return': ['error', { allowElseIf: false }],
'no-empty-function': ['error', {
allow: [
'arrowFunctions',
'functions',
'methods',
],
}],
'no-empty-pattern': 'error',
'no-empty-static-block': 'error',
'no-eq-null': 'off',
'no-eval': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-extra-label': 'error',
'no-fallthrough': 'error',
'no-floating-decimal': 'error',
'no-global-assign': ['error', { exceptions: [] }],
'no-native-reassign': 'off',
'no-implicit-coercion': ['off', {
boolean: false,
number: true,
string: true,
allow: [],
}],
'no-implicit-globals': 'off',
'no-implied-eval': 'error',
'no-invalid-this': 'off',
'no-iterator': 'error',
'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
'no-lone-blocks': 'error',
'no-loop-func': 'error',
'no-magic-numbers': ['off', {
ignore: [],
ignoreArrayIndexes: true,
enforceConst: true,
detectObjects: false,
}],
'no-multi-spaces': ['error', {
ignoreEOLComments: false,
}],
'no-multi-str': 'error',
'no-new': 'error',
'no-new-func': 'error',
'no-new-wrappers': 'error',
'no-nonoctal-decimal-escape': 'error',
'no-octal': 'error',
'no-octal-escape': 'error',
'no-param-reassign': ['error', {
props: true,
ignorePropertyModificationsFor: [
],
}],
'no-proto': 'error',
'no-redeclare': 'error',
'no-restricted-properties': ['error', {
object: 'arguments',
property: 'callee',
message: 'arguments.callee is deprecated',
}, {
object: 'global',
property: 'isFinite',
message: 'Please use Number.isFinite instead',
}, {
object: 'self',
property: 'isFinite',
message: 'Please use Number.isFinite instead',
}, {
object: 'window',
property: 'isFinite',
message: 'Please use Number.isFinite instead',
}, {
object: 'global',
property: 'isNaN',
message: 'Please use Number.isNaN instead',
}, {
object: 'self',
property: 'isNaN',
message: 'Please use Number.isNaN instead',
}, {
object: 'window',
property: 'isNaN',
message: 'Please use Number.isNaN instead',
}, {
property: '__defineGetter__',
message: 'Please use Object.defineProperty instead.',
}, {
property: '__defineSetter__',
message: 'Please use Object.defineProperty instead.',
}, {
object: 'Math',
property: 'pow',
message: 'Use the exponentiation operator (**) instead.',
}],
'no-return-assign': ['error', 'always'],
'no-return-await': 'error',
'no-script-url': 'error',
'no-self-assign': ['error', {
props: true,
}],
'no-self-compare': 'error',
'no-sequences': 'error',
'no-throw-literal': 'error',
'no-unmodified-loop-condition': 'off',
'no-unused-expressions': ['error', {
allowShortCircuit: false,
allowTernary: false,
allowTaggedTemplates: false,
}],
'no-unused-labels': 'error',
'no-useless-call': 'off',
'no-useless-catch': 'error',
'no-useless-concat': 'error',
'no-useless-escape': 'error',
'no-useless-return': 'error',
'no-void': 'error',
'no-warning-comments': ['off', { terms: ['todo', 'fixme', 'xxx'], location: 'start' }],
'no-with': 'error',
'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
'prefer-named-capture-group': 'off',
'prefer-object-has-own': 'off',
'prefer-regex-literals': ['error', {
disallowRedundantWrapping: true,
}],
radix: 'error',
'require-await': 'off',
'require-unicode-regexp': 'off',
'vars-on-top': 'error',
'wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }],
yoda: 'error',
'for-direction': 'error',
'getter-return': ['error', { allowImplicit: true }],
'no-async-promise-executor': 'error',
'no-await-in-loop': 'error',
'no-compare-neg-zero': 'error',
'no-cond-assign': ['error', 'always'],
'no-console': 'warn',
'no-constant-binary-expression': 'off',
'no-constant-condition': 'warn',
'no-control-regex': 'error',
'no-debugger': 'error',
'no-dupe-args': 'error',
'no-dupe-else-if': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
'no-empty': 'error',
'no-empty-character-class': 'error',
'no-ex-assign': 'error',
'no-extra-boolean-cast': 'error',
'no-extra-parens': ['off', 'all', {
conditionalAssign: true,
nestedBinaryExpressions: false,
returnAssign: false,
enforceForArrowConditionals: false,
}],
'no-extra-semi': 'error',
'no-func-assign': 'error',
'no-import-assign': 'error',
'no-inner-declarations': 'error',
'no-invalid-regexp': 'error',
'no-irregular-whitespace': 'error',
'no-loss-of-precision': 'error',
'no-misleading-character-class': 'error',
'no-obj-calls': 'error',
'no-new-native-nonconstructor': 'off',
'no-promise-executor-return': 'error',
'no-prototype-builtins': 'error',
'no-regex-spaces': 'error',
'no-setter-return': 'error',
'no-sparse-arrays': 'error',
'no-template-curly-in-string': 'error',
'no-unexpected-multiline': 'error',
'no-unreachable': 'error',
'no-unreachable-loop': ['error', {
}],
'no-unsafe-finally': 'error',
'no-unsafe-negation': 'error',
'no-unsafe-optional-chaining': ['error', { disallowArithmeticOperators: true }],
'no-unused-private-class-members': 'off',
'no-useless-backreference': 'error',
'no-negated-in-lhs': 'off',
'require-atomic-updates': 'off',
'use-isnan': 'error',
'valid-jsdoc': 'off',
'valid-typeof': ['error', { requireStringLiterals: true }],
'arrow-body-style': ['error', 'as-needed', {
requireReturnForObjectLiteral: false,
}],
'arrow-parens': ['error', 'always'],
'arrow-spacing': ['error', { before: true, after: true }],
'constructor-super': 'error',
'generator-star-spacing': ['error', { before: false, after: true }],
'no-class-assign': 'error',
'no-confusing-arrow': ['error', {
allowParens: true,
}],
'no-const-assign': 'error',
'no-dupe-class-members': 'error',
'no-duplicate-imports': 'off',
'no-new-symbol': 'error',
'no-restricted-exports': ['error', {
restrictedNamedExports: [
],
}],
'no-restricted-imports': ['off', {
paths: [],
patterns: [],
}],
'no-this-before-super': 'error',
'no-useless-computed-key': 'error',
'no-useless-constructor': 'error',
'no-useless-rename': ['error', {
ignoreDestructuring: false,
ignoreImport: false,
ignoreExport: false,
}],
'no-var': 'error',
'object-shorthand': ['error', 'always', {
ignoreConstructors: false,
avoidQuotes: true,
}],
'prefer-arrow-callback': ['error', {
allowNamedFunctions: false,
allowUnboundThis: true,
}],
'prefer-const': ['error', {
destructuring: 'any',
ignoreReadBeforeAssign: true,
}],
'prefer-destructuring': ['error', {
VariableDeclarator: {
array: false,
object: true,
},
AssignmentExpression: {
array: true,
object: false,
},
}, {
enforceForRenamedProperties: false,
}],
'prefer-numeric-literals': 'error',
'prefer-reflect': 'off',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'error',
'require-yield': 'error',
'rest-spread-spacing': ['error', 'never'],
'sort-imports': ['off', {
ignoreCase: false,
ignoreDeclarationSort: false,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
}],
'symbol-description': 'error',
'template-curly-spacing': 'error',
'yield-star-spacing': ['error', 'after'],
'callback-return': 'off',
'global-require': 'error',
'handle-callback-err': 'off',
'no-buffer-constructor': 'error',
'no-mixed-requires': ['off', false],
'no-new-require': 'error',
'no-path-concat': 'error',
'no-process-env': 'off',
'no-process-exit': 'off',
'no-restricted-modules': 'off',
'no-sync': 'off',
strict: ['error', 'never'],
'array-element-newline': ['off', { multiline: true, minItems: 3 }],
'array-bracket-spacing': ['error', 'never'],
'block-spacing': ['error', 'always'],
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
camelcase: ['error', { properties: 'never', ignoreDestructuring: false }],
'capitalized-comments': ['off', 'never', {
line: {
ignorePattern: '.*',
ignoreInlineComments: true,
ignoreConsecutiveComments: true,
},
block: {
ignorePattern: '.*',
ignoreInlineComments: true,
ignoreConsecutiveComments: true,
},
}],
'comma-dangle': ['error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'always-multiline',
}],
'comma-spacing': ['error', { before: false, after: true }],
'comma-style': ['error', 'last', {
exceptions: {
ArrayExpression: false,
ArrayPattern: false,
ArrowFunctionExpression: false,
CallExpression: false,
FunctionDeclaration: false,
FunctionExpression: false,
ImportDeclaration: false,
ObjectExpression: false,
ObjectPattern: false,
VariableDeclaration: false,
NewExpression: false,
},
}],
'computed-property-spacing': ['error', 'never'],
'consistent-this': 'off',
'eol-last': ['error', 'always'],
'function-call-argument-newline': ['error', 'consistent'],
'func-call-spacing': ['error', 'never'],
'func-name-matching': ['off', 'always', {
includeCommonJSModuleExports: false,
considerPropertyDescriptor: true,
}],
'func-names': 'warn',
'func-style': ['off', 'expression'],
'function-paren-newline': ['error', 'multiline-arguments'],
'id-denylist': 'off',
'id-length': 'off',
'id-match': 'off',
'implicit-arrow-linebreak': ['error', 'beside'],
indent: ['error', 2, {
SwitchCase: 1,
VariableDeclarator: 1,
outerIIFEBody: 1,
FunctionDeclaration: {
parameters: 1,
body: 1,
},
FunctionExpression: {
parameters: 1,
body: 1,
},
CallExpression: {
arguments: 1,
},
ArrayExpression: 1,
ObjectExpression: 1,
ImportDeclaration: 1,
flatTernaryExpressions: false,
ignoredNodes: ['JSXElement', 'JSXElement > *', 'JSXAttribute', 'JSXIdentifier', 'JSXNamespacedName', 'JSXMemberExpression', 'JSXSpreadAttribute', 'JSXExpressionContainer', 'JSXOpeningElement', 'JSXClosingElement', 'JSXFragment', 'JSXOpeningFragment', 'JSXClosingFragment', 'JSXText', 'JSXEmptyExpression', 'JSXSpreadChild'],
ignoreComments: false,
}],
'jsx-quotes': ['off', 'prefer-double'],
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
'keyword-spacing': ['error', {
before: true,
after: true,
overrides: {
return: { after: true },
throw: { after: true },
case: { after: true },
},
}],
'line-comment-position': ['off', {
position: 'above',
ignorePattern: '',
applyDefaultPatterns: true,
}],
'linebreak-style': ['error', 'unix'],
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: false }],
'lines-around-comment': 'off',
'lines-around-directive': ['error', {
before: 'always',
after: 'always',
}],
'logical-assignment-operators': ['off', 'always', {
enforceForIfStatements: true,
}],
'max-depth': ['off', 4],
'max-len': ['error', 100, 2, {
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],
'max-lines': ['off', {
max: 300,
skipBlankLines: true,
skipComments: true,
}],
'max-lines-per-function': ['off', {
max: 50,
skipBlankLines: true,
skipComments: true,
IIFEs: true,
}],
'max-nested-callbacks': 'off',
'max-params': ['off', 3],
'max-statements': ['off', 10],
'max-statements-per-line': ['off', { max: 1 }],
'multiline-comment-style': ['off', 'starred-block'],
'multiline-ternary': ['off', 'never'],
'new-cap': ['error', {
newIsCap: true,
newIsCapExceptions: [],
capIsNew: false,
capIsNewExceptions: ['Immutable.Map', 'Immutable.Set', 'Immutable.List'],
}],
'new-parens': 'error',
'newline-after-var': 'off',
'newline-before-return': 'off',
'newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }],
'no-array-constructor': 'error',
'no-bitwise': 'error',
'no-continue': 'error',
'no-inline-comments': 'off',
'no-lonely-if': 'error',
'no-mixed-operators': ['error', {
groups: [
['%', '**'],
['%', '+'],
['%', '-'],
['%', '*'],
['%', '/'],
['/', '*'],
['&', '|', '<<', '>>', '>>>'],
['==', '!=', '===', '!=='],
['&&', '||'],
],
allowSamePrecedence: false,
}],
'no-mixed-spaces-and-tabs': 'error',
'no-multi-assign': ['error'],
'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
'no-negated-condition': 'off',
'no-nested-ternary': 'error',
'no-new-object': 'error',
'no-plusplus': 'error',
'no-restricted-syntax': [
'error',
{
selector: 'ForInStatement',
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
{
selector: 'ForOfStatement',
message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.',
},
{
selector: 'LabeledStatement',
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
'no-spaced-func': 'off',
'no-tabs': 'error',
'no-ternary': 'off',
'no-trailing-spaces': ['error', {
skipBlankLines: false,
ignoreComments: false,
}],
'no-underscore-dangle': ['error', {
allow: [],
allowAfterThis: false,
allowAfterSuper: false,
enforceInMethodNames: true,
}],
'no-unneeded-ternary': ['error', { defaultAssignment: false }],
'no-whitespace-before-property': 'error',
'nonblock-statement-body-position': ['error', 'beside', { overrides: {} }],
'object-curly-spacing': ['error', 'always'],
'object-curly-newline': ['error', {
ObjectExpression: { minProperties: 4, multiline: true, consistent: true },
ObjectPattern: { minProperties: 4, multiline: true, consistent: true },
ImportDeclaration: { minProperties: 4, multiline: true, consistent: true },
ExportDeclaration: { minProperties: 4, multiline: true, consistent: true },
}],
'object-property-newline': ['error', {
allowAllPropertiesOnSameLine: true,
}],
'one-var': ['error', 'never'],
'one-var-declaration-per-line': ['error', 'always'],
'operator-assignment': ['error', 'always'],
'operator-linebreak': ['error', 'before', { overrides: { '=': 'none' } }],
'padded-blocks': ['error', {
blocks: 'never',
classes: 'never',
switches: 'never',
}, {
allowSingleLineBlocks: true,
}],
'padding-line-between-statements': 'off',
'prefer-exponentiation-operator': 'error',
'prefer-object-spread': 'error',
'quote-props': ['error', 'as-needed', { keywords: false, unnecessary: true, numbers: false }],
quotes: ['error', 'single', { avoidEscape: true }],
'require-jsdoc': 'off',
semi: ['error', 'always'],
'semi-spacing': ['error', { before: false, after: true }],
'semi-style': ['error', 'last'],
'sort-keys': ['off', 'asc', { caseSensitive: false, natural: true }],
'sort-vars': 'off',
'space-before-blocks': 'error',
'space-before-function-paren': ['error', {
anonymous: 'always',
named: 'never',
asyncArrow: 'always',
}],
'space-in-parens': ['error', 'never'],
'space-infix-ops': 'error',
'space-unary-ops': ['error', {
words: true,
nonwords: false,
overrides: {
},
}],
'spaced-comment': ['error', 'always', {
line: {
exceptions: ['-', '+'],
},
block: {
exceptions: ['-', '+'],
balanced: true,
},
}],
'switch-colon-spacing': ['error', { after: true, before: false }],
'template-tag-spacing': ['error', 'never'],
'unicode-bom': ['error', 'never'],
'wrap-regex': 'off',
'init-declarations': 'off',
'no-catch-shadow': 'off',
'no-delete-var': 'error',
'no-label-var': 'error',
'no-restricted-globals': [
'error',
{
name: 'isFinite',
message: 'Use Number.isFinite instead https://github.com/airbnb/javascript#standard-library--isfinite',
},
{
name: 'isNaN',
message: 'Use Number.isNaN instead https://github.com/airbnb/javascript#standard-library--isnan',
},
].concat(confusingBrowserGlobals.map((g) => ({
name: g,
message: `Use window.${g} instead.`,
}))),
'no-shadow': 'error',
'no-shadow-restricted-names': 'error',
'no-undef': 'error',
'no-undef-init': 'error',
'no-undefined': 'off',
'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }],
'no-use-before-define': ['error', { functions: true, classes: true, variables: true }],
},
};

View File

@ -0,0 +1,179 @@
module.exports = {
plugins: [
'jsx-a11y',
'react'
],
rules: {
'jsx-a11y/alt-text': ['error', {
'elements': [
'img',
'object',
'area',
'input[type="image"]',
],
'img': [],
'object': [],
'area': [],
'input[type="image"]': [],
}],
'jsx-a11y/anchor-ambiguous-text': 'off',
'jsx-a11y/anchor-has-content': ['error', {
'components': [],
}],
'jsx-a11y/anchor-is-valid': ['error', {
'components': [
'Link',
],
'specialLink': [
'to',
],
'aspects': [
'noHref',
'invalidHref',
'preferButton',
],
}],
'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
'jsx-a11y/aria-props': 'error',
'jsx-a11y/aria-proptypes': 'error',
'jsx-a11y/aria-role': ['error', {
'ignoreNonDOM': false,
}],
'jsx-a11y/aria-unsupported-elements': 'error',
'jsx-a11y/autocomplete-valid': ['error', {
'inputComponents': [],
}],
'jsx-a11y/click-events-have-key-events': 'error',
'jsx-a11y/control-has-associated-label': ['error', {
'labelAttributes': [
'label',
],
'controlComponents': [],
'ignoreElements': [
'audio',
'canvas',
'embed',
'input',
'textarea',
'tr',
'video',
],
'ignoreRoles': [
'grid',
'listbox',
'menu',
'menubar',
'radiogroup',
'row',
'tablist',
'toolbar',
'tree',
'treegrid',
],
'depth': 5,
}],
'jsx-a11y/heading-has-content': ['error', {
'components': [],
}],
'jsx-a11y/html-has-lang': 'error',
'jsx-a11y/iframe-has-title': 'error',
'jsx-a11y/img-redundant-alt': 'error',
'jsx-a11y/interactive-supports-focus': 'error',
'jsx-a11y/label-has-associated-control': ['error', {
'labelComponents': [],
'labelAttributes': [],
'controlComponents': [],
'assert': 'both',
'depth': 25,
}],
'jsx-a11y/lang': 'error',
'jsx-a11y/media-has-caption': ['error', {
'audio': [],
'video': [],
'track': [],
}],
'jsx-a11y/mouse-events-have-key-events': 'error',
'jsx-a11y/no-access-key': 'error',
'jsx-a11y/no-aria-hidden-on-focusable': 'error',
'jsx-a11y/no-autofocus': ['error', {
'ignoreNonDOM': true,
}],
'jsx-a11y/no-distracting-elements': ['error', {
'elements': [
'marquee',
'blink',
]
}],
'jsx-a11y/no-interactive-element-to-noninteractive-role': ['error', {
'tr': [
'none',
'presentation',
],
}],
'jsx-a11y/no-noninteractive-element-interactions': ['error', {
'handlers': [
'onClick',
'onMouseDown',
'onMouseUp',
'onKeyPress',
'onKeyDown',
'onKeyUp',
],
}],
'jsx-a11y/no-noninteractive-element-to-interactive-role': ['error', {
'ul': [
'listbox',
'menu',
'menubar',
'radiogroup',
'tablist',
'tree',
'treegrid',
],
'ol': [
'listbox',
'menu',
'menubar',
'radiogroup',
'tablist',
'tree',
'treegrid',
],
'li': [
'menuitem',
'option',
'row',
'tab',
'treeitem',
],
'table': [
'grid',
],
'td': [
'gridcell',
],
}],
'jsx-a11y/no-noninteractive-tabindex': ['error', {
'tags': [],
'roles': [
'tabpanel',
],
}],
'jsx-a11y/no-redundant-roles': 'error',
'jsx-a11y/no-static-element-interactions': ['error', {
'handlers': [
'onClick',
'onMouseDown',
'onMouseUp',
'onKeyPress',
'onKeyDown',
'onKeyUp',
],
}],
'jsx-a11y/prefer-tag-over-role': 'off',
'jsx-a11y/role-has-required-aria-props': 'error',
'jsx-a11y/role-supports-aria-props': 'error',
'jsx-a11y/scope': 'error',
'jsx-a11y/tabindex-no-positive': 'error',
}
}

View File

@ -0,0 +1,9 @@
module.exports = {
plugins: [
'react-hooks'
],
rules: {
'react-hooks/exhaustive-deps': 'error',
'react-hooks/rules-of-hooks': 'error',
}
}

View File

@ -0,0 +1,312 @@
const { rules: baseRules } = require('../.eslint-js');
const { rules: importRules, settings: importSettings } = require('../.eslint-import');
module.exports = {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
},
plugins: [
'react',
],
rules: {
'class-methods-use-this': [baseRules['class-methods-use-this'][0], {
...baseRules['class-methods-use-this'][1],
'exceptMethods': [
...baseRules['class-methods-use-this'][1]?.exceptMethods,
'render',
'getInitialState',
'getDefaultProps',
'getChildContext',
'componentWillMount',
'UNSAFE_componentWillMount',
'componentDidMount',
'componentWillReceiveProps',
'UNSAFE_componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'UNSAFE_componentWillUpdate',
'componentDidUpdate',
'componentWillUnmount',
'componentDidCatch',
'getSnapshotBeforeUpdate',
],
}],
'import/extensions': [importRules['import/extensions'][0],
importRules['import/extensions'][1],
{
...importRules['import/extensions'][2],
'jsx': 'never',
},
],
'import/no-nodejs-modules': 'error',
'react/boolean-prop-naming': ['off', {
'propTypeNames': [
'bool',
'mutuallyExclusiveTrueProps',
],
'rule': '^(is|has)[A-Z]([A-Za-z0-9]?)+',
'message': '',
}],
'react/button-has-type': ['error', {
'button': true,
'submit': true,
'reset': false,
}],
'react/default-props-match-prop-types': ['error', {
'allowRequiredDefaults': false,
}],
'react/destructuring-assignment': ['error', 'always'],
'react/display-name': ['off', {
'ignoreTranspilerName': false,
}],
'react/forbid-component-props': ['off', {
'forbid': [],
}],
'react/forbid-dom-props': ['off', {
'forbid': [],
}],
'react/forbid-elements': ['off', {
'forbid': [],
}],
'react/forbid-foreign-prop-types': ['warn', {
'allowInPropTypes': true,
}],
'react/forbid-prop-types': ['error', {
'forbid': [
'any',
'array',
'object',
],
'checkContextTypes': true,
'checkChildContextTypes': true,
}],
'react/function-component-definition': ['error', {
'namedComponents': [
'arrow-function',
],
'unnamedComponents': 'function-expression',
}],
'react/hook-use-state': 'error',
'react/iframe-missing-sandbox': 'error',
'react/jsx-boolean-value': ['error',
'never',
{
'always': [],
},
],
'react/jsx-child-element-spacing': 'off',
'react/jsx-closing-bracket-location': 'off',
'react/jsx-closing-tag-location': 'off',
'react/jsx-curly-brace-presence': 'off',
'react/jsx-curly-newline': 'off',
'react/jsx-curly-spacing': 'off',
'react/jsx-equals-spacing': 'off',
'react/jsx-filename-extension': ['error', {
'extensions': [
'.jsx',
'.js',
],
}],
'react/jsx-first-prop-new-line': 'off',
'react/jsx-fragments': ['error', 'syntax' ],
'react/jsx-handler-names': ['off', {
'eventHandlerPrefix': 'handle',
'eventHandlerPropPrefix': 'on',
}],
'react/jsx-indent': 'off',
'react/jsx-indent-props': 'off',
'react/jsx-key': 'error',
'react/jsx-max-depth': 'off',
'react/jsx-max-props-per-line': 'off',
'react/jsx-newline': 'off',
'react/jsx-no-bind': ['error', {
'ignoreRefs': true,
'allowArrowFunctions': true,
'allowFunctions': false,
'allowBind': false,
'ignoreDOMComponents': true,
}],
'react/jsx-no-comment-textnodes': 'error',
'react/jsx-no-constructed-context-values': 'error',
'react/jsx-no-duplicate-props': ['error', {
'ignoreCase': false,
}],
'react/jsx-no-leaked-render': 'error',
'react/jsx-no-literals': 'off',
'react/jsx-no-script-url': ['error', [
{
'name': 'Link',
'props': [
'to',
],
},
]],
'react/jsx-no-target-blank': ['error', {
'enforceDynamicLinks': 'always',
}],
'react/jsx-no-undef': 'error',
'react/jsx-no-useless-fragment': 'error',
'react/jsx-one-expression-per-line': 'off',
'react/jsx-pascal-case': ['error', {
'allowAllCaps': true,
'ignore': [],
}],
'react/jsx-props-no-multi-spaces': 'off',
'react/jsx-props-no-spreading': 'off',
'react/jsx-sort-props': 'off',
'react/jsx-tag-spacing': 'off',
'react/jsx-uses-react': 'error',
'react/jsx-uses-vars': 'error',
'react/jsx-wrap-multilines': ['error', {
'declaration': 'parens-new-line',
'assignment': 'parens-new-line',
'return': 'parens-new-line',
'arrow': 'parens-new-line',
'condition': 'parens-new-line',
'logical': 'parens-new-line',
'prop': 'parens-new-line',
}],
'react/no-access-state-in-setstate': 'error',
'react/no-adjacent-inline-elements': 'off',
'react/no-array-index-key': 'error',
'react/no-arrow-function-lifecycle': 'error',
'react/no-children-prop': 'error',
'react/no-danger': 'error',
'react/no-danger-with-children': 'error',
'react/no-deprecated': 'error',
'react/no-did-mount-set-state': 'off',
'react/no-did-update-set-state': 'error',
'react/no-direct-mutation-state': 'error',
'react/no-find-dom-node': 'error',
'react/no-invalid-html-attribute': 'error',
'react/no-is-mounted': 'error',
'react/no-multi-comp': 'off',
'react/no-namespace': 'error',
'react/no-object-type-as-default-prop': 'off',
'react/no-redundant-should-component-update': 'error',
'react/no-render-return-value': 'error',
'react/no-set-state': 'off',
'react/no-string-refs': 'error',
'react/no-this-in-sfc': 'error',
'react/no-typos': 'error',
'react/no-unescaped-entities': 'error',
'react/no-unknown-property': 'error',
'react/no-unsafe': 'off',
'react/no-unstable-nested-components': 'error',
'react/no-unused-class-component-methods': 'error',
'react/no-unused-prop-types': ['error', {
'customValidators': [],
'skipShapeProps': true,
}],
'react/no-unused-state': 'error',
'react/no-will-update-set-state': 'error',
'react/prefer-es6-class': ['error', 'always'],
'react/prefer-exact-props': 'error',
'react/prefer-read-only-props': 'off',
'react/prefer-stateless-function': ['error', {
'ignorePureComponents': true,
}],
'react/prop-types': ['error', {
'ignore': [],
'customValidators': [],
'skipUndeclared': false,
}],
'react/react-in-jsx-scope': 'off',
'react/require-default-props': ['error', {
'forbidDefaultForRequired': true,
'functions': 'ignore',
}],
'react/require-optimization': ['off', {
'allowDecorators': [],
}],
'react/require-render-return': 'error',
'react/self-closing-comp': 'off',
'react/sort-comp': ['error', {
'order': [
'static-variables',
'static-methods',
'instance-variables',
'lifecycle',
'/^handle.+$/',
'/^on.+$/',
'getters',
'setters',
'/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
'instance-methods',
'everything-else',
'rendering',
],
'groups': {
'lifecycle': [
'displayName',
'propTypes',
'contextTypes',
'childContextTypes',
'mixins',
'statics',
'defaultProps',
'constructor',
'getDefaultProps',
'getInitialState',
'state',
'getChildContext',
'getDerivedStateFromProps',
'componentWillMount',
'UNSAFE_componentWillMount',
'componentDidMount',
'componentWillReceiveProps',
'UNSAFE_componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'UNSAFE_componentWillUpdate',
'getSnapshotBeforeUpdate',
'componentDidUpdate',
'componentDidCatch',
'componentWillUnmount',
],
'rendering': [
'/^render.+$/',
'render',
],
},
}],
'react/sort-default-props': ['error', {
'ignoreCase': false,
}],
'react/sort-prop-types': 'off',
'react/state-in-constructor': ['error', 'always'],
'react/static-property-placement': ['error', 'property assignment', {
childContextTypes: 'property assignment',
contextTypes: 'property assignment',
contextType: 'static public field',
defaultProps: 'property assignment',
displayName: 'property assignment',
propTypes: 'property assignment',
}],
'react/style-prop-object': 'error',
'react/void-dom-elements-no-children': 'error',
},
settings: {
'import/extensions': [
...importSettings['import/extensions'],
'.jsx',
],
'import/resolver': {
...importSettings['import/resolver'],
node: {
...importSettings['import/resolver'].node,
extensions: [
...importSettings['import/resolver'].node.extensions,
'.jsx',
],
},
},
'react': {
'pragma': 'React',
'version': 'detect',
},
},
}

View File

@ -0,0 +1,240 @@
module.exports = {
plugins: [
'@stylistic'
],
rules: {
'@stylistic/array-bracket-newline': ['error', 'consistent'],
'@stylistic/array-bracket-spacing': ['error', 'never'],
'@stylistic/array-element-newline': ['error', 'consistent'],
'@stylistic/arrow-parens': ['error', 'always'],
'@stylistic/arrow-spacing': ['error', {
before: true,
after: true,
}],
'@stylistic/block-spacing': ['error', 'always'],
'@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }],
'@stylistic/comma-dangle': ['error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'always-multiline',
enums: 'always-multiline',
generics: 'always-multiline',
tuples: 'always-multiline',
}],
'@stylistic/comma-spacing': ['error', {
before: false,
after: true,
}],
'@stylistic/comma-style': ['error', 'last', {
exceptions: {
ArrayExpression: false,
ArrayPattern: false,
ArrowFunctionExpression: false,
CallExpression: false,
FunctionDeclaration: false,
FunctionExpression: false,
ImportDeclaration: false,
ObjectExpression: false,
ObjectPattern: false,
VariableDeclaration: false,
NewExpression: false,
},
}],
'@stylistic/computed-property-spacing': ['error', 'never'],
'@stylistic/dot-location': ['error', 'property'],
'@stylistic/eol-last': ['error', 'always'],
'@stylistic/function-call-argument-newline': ['error', 'consistent'],
'@stylistic/function-call-spacing': ['error', 'never'],
'@stylistic/function-paren-newline': ['error', 'multiline-arguments'],
'@stylistic/generator-star-spacing': ['error', {
before: false,
after: true,
}],
'@stylistic/implicit-arrow-linebreak': ['error', 'beside'],
'@stylistic/indent': ['error', 2, {
SwitchCase: 1,
VariableDeclarator: 1,
outerIIFEBody: 1,
FunctionDeclaration: {
parameters: 1,
body: 1,
},
FunctionExpression: {
parameters: 1,
body: 1,
},
CallExpression: {
arguments: 1,
},
ArrayExpression: 1,
ObjectExpression: 1,
ImportDeclaration: 1,
flatTernaryExpressions: false,
ignoredNodes: ['JSXElement', 'JSXElement > *', 'JSXAttribute', 'JSXIdentifier', 'JSXNamespacedName', 'JSXMemberExpression', 'JSXSpreadAttribute', 'JSXExpressionContainer', 'JSXOpeningElement', 'JSXClosingElement', 'JSXFragment', 'JSXOpeningFragment', 'JSXClosingFragment', 'JSXText', 'JSXEmptyExpression', 'JSXSpreadChild'],
ignoreComments: false,
}],
'@stylistic/indent-binary-ops': ['error', 2],
'@stylistic/key-spacing': ['error', {
beforeColon: false,
afterColon: true,
}],
'@stylistic/keyword-spacing': ['error', {
before: true,
after: true,
overrides: {
return: { after: true },
throw: { after: true },
case: { after: true },
},
}],
'@stylistic/linebreak-style': ['error', 'unix'],
'@stylistic/lines-around-comment': 'off',
'@stylistic/lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: false }],
'@stylistic/max-len': ['error', {
code: 120,
tabWidth: 2,
ignoreUrls: true,
ignoreComments: true,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],
'@stylistic/max-statements-per-line': ['error', { max: 1 }],
'@stylistic/multiline-ternary': ['error', 'always-multiline'],
'@stylistic/new-parens': 'error',
'@stylistic/newline-per-chained-call': ['error', { ignoreChainWithDepth: 4 }],
'@stylistic/no-confusing-arrow': ['error', {
allowParens: true,
}],
'@stylistic/no-extra-parens': ['error', 'all', {
conditionalAssign: true,
nestedBinaryExpressions: false,
returnAssign: false,
ignoreJSX: 'all',
enforceForArrowConditionals: false,
}],
'@stylistic/no-extra-semi': 'error',
'@stylistic/no-floating-decimal': 'error',
'@stylistic/no-mixed-operators': ['error', {
groups: [
['%', '**'],
['%', '+'],
['%', '-'],
['%', '*'],
['%', '/'],
['/', '*'],
['&', '|', '<<', '>>', '>>>'],
['==', '!=', '===', '!=='],
['&&', '||'],
],
allowSamePrecedence: false,
}],
'@stylistic/no-mixed-spaces-and-tabs': 'error',
'@stylistic/no-multi-spaces': ['error', {
ignoreEOLComments: false,
}],
'@stylistic/no-multiple-empty-lines': ['error', {
max: 1,
maxBOF: 0,
maxEOF: 0,
}],
'@stylistic/no-tabs': 'error',
'@stylistic/no-trailing-spaces': ['error', {
skipBlankLines: false,
ignoreComments: false,
}],
'@stylistic/no-whitespace-before-property': 'error',
'@stylistic/nonblock-statement-body-position': ['error', 'beside', { overrides: {} }],
'@stylistic/object-curly-newline': ['error', {
ObjectExpression: {
minProperties: 4,
multiline: true,
consistent: true,
},
ObjectPattern: {
minProperties: 4,
multiline: true,
consistent: true,
},
ImportDeclaration: {
minProperties: 4,
multiline: true,
consistent: true,
},
ExportDeclaration: {
minProperties: 4,
multiline: true,
consistent: true,
},
}],
'@stylistic/object-curly-spacing': ['error', 'always'],
'@stylistic/object-property-newline': ['error', {
allowAllPropertiesOnSameLine: true,
}],
'@stylistic/one-var-declaration-per-line': ['error', 'always'],
'@stylistic/operator-linebreak': ['error', 'before', { overrides: { '=': 'none' } }],
'@stylistic/padded-blocks': ['error', {
blocks: 'never',
classes: 'never',
switches: 'never',
}, {
allowSingleLineBlocks: true,
}],
'@stylistic/padding-line-between-statements': ["error",
{ blankLine: "always", prev: "*", next: "return" },
{ blankLine: "always", prev: "*", next: "for" },
{ blankLine: "always", prev: "for", next: "*" },
{ blankLine: "always", prev: "for", next: "*" },
{ blankLine: "always", prev: "throw", next: "*" },
{ blankLine: "always", prev: "*", next: "throw" },
],
'@stylistic/quote-props': ['error', 'as-needed', {
keywords: false,
unnecessary: true,
numbers: false,
}],
'@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
'@stylistic/rest-spread-spacing': ['error', 'never'],
'@stylistic/semi': ['error', 'always'],
'@stylistic/semi-spacing': ['error', {
before: false,
after: true,
}],
'@stylistic/semi-style': ['error', 'last'],
'@stylistic/space-before-blocks': 'error',
'@stylistic/space-before-function-paren': ['error', {
anonymous: 'always',
named: 'never',
asyncArrow: 'always',
}],
'@stylistic/space-in-parens': ['error', 'never'],
'@stylistic/space-infix-ops': 'error',
'@stylistic/space-unary-ops': ['error', {
words: true,
nonwords: false,
overrides: {},
}],
'@stylistic/spaced-comment': ['error', 'always', {
line: {
exceptions: ['-', '+'],
markers: ['=', '!', '/'],
},
block: {
exceptions: ['-', '+'],
markers: ['=', '!', ':', '::'],
balanced: true,
},
}],
'@stylistic/switch-colon-spacing': ['error', {
after: true,
before: false,
}],
'@stylistic/template-curly-spacing': 'error',
'@stylistic/template-tag-spacing': ['error', 'never'],
'@stylistic/wrap-iife': ['error', 'outside', { functionPrototypeMethods: false }],
'@stylistic/wrap-regex': 'error',
'@stylistic/yield-star-spacing': ['error', 'after'],
}
}

View File

@ -0,0 +1,60 @@
module.exports = {
plugins: [
'@stylistic'
],
rules: {
'@stylistic/jsx-child-element-spacing': 'off',
'@stylistic/jsx-closing-bracket-location': ['error', 'line-aligned'],
'@stylistic/jsx-closing-tag-location': 'error',
'@stylistic/jsx-curly-brace-presence': ['error', {
'props': 'never',
'children': 'never',
}],
'@stylistic/jsx-curly-newline': ['error', {
'multiline': 'consistent',
'singleline': 'consistent',
}],
'@stylistic/jsx-curly-spacing': ['error', 'never', {
'allowMultiline': true,
}],
'@stylistic/jsx-equals-spacing': ['error', 'never'],
'@stylistic/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
'@stylistic/jsx-indent': ['error', 2],
'@stylistic/jsx-indent-props': ['error', 2],
'@stylistic/jsx-max-props-per-line': ['error', {
"maximum": { "single": 3, "multi": 1 }
}],
'@stylistic/jsx-newline': ['error', {
'prevent': false
}],
'@stylistic/jsx-one-expression-per-line': ['error', {
'allow': 'literal',
}],
'@stylistic/jsx-props-no-multi-spaces': 'error',
'@stylistic/jsx-quotes': ['error', "prefer-double"],
'@stylistic/jsx-self-closing-comp': 'off',
'@stylistic/jsx-sort-props': ['error', {
'ignoreCase': true,
'callbacksLast': true,
'shorthandFirst': true,
'shorthandLast': false,
'noSortAlphabetically': false,
'reservedFirst': true,
}],
'@stylistic/jsx-tag-spacing': ['error', {
'closingSlash': 'never',
'beforeSelfClosing': 'always',
'afterOpening': 'never',
'beforeClosing': 'never',
}],
'@stylistic/jsx-wrap-multilines': ['error', {
'declaration': 'parens-new-line',
'assignment': 'parens-new-line',
'return': 'parens-new-line',
'arrow': 'parens-new-line',
'condition': 'parens-new-line',
'logical': 'parens-new-line',
'prop': 'parens-new-line',
}],
}
}

View File

@ -0,0 +1,30 @@
module.exports = {
plugins: [
'@stylistic'
],
rules: {
'@stylistic/member-delimiter-style': ['error', {
'multiline': {
'delimiter': 'semi',
'requireLast': true,
},
'multilineDetection': 'brackets',
'singleline': {
'delimiter': 'semi',
'requireLast': false,
},
}],
'@stylistic/type-annotation-spacing': ["error", {
"before": false,
"after": true,
"overrides": {
"arrow": {
"before": true,
"after": true
}
}
}],
'@stylistic/type-generic-spacing': 'error',
'@stylistic/type-named-tuple-spacing': 'error',
}
}

7
ts-base.js Normal file
View File

@ -0,0 +1,7 @@
module.exports = {
extends: [
'./js-base',
'./rules/.eslint-ts',
'./rules/style/.eslint-style-ts',
].map(require.resolve)
};

45
ts-react.js Normal file
View File

@ -0,0 +1,45 @@
const {rules: reactRules, settings: reactSettings} = require('./rules/react/.eslint-react.js');
const reactFilenameExtensionRule = reactRules['react/jsx-filename-extension'];
module.exports = {
extends: [
'./js-react',
'./ts-base',
].map(require.resolve),
settings: {
'import/resolver': {
...reactSettings['import/resolver'],
node: {
...reactSettings['import/resolver'].node,
extensions: [
...reactSettings['import/resolver'].node.extensions,
'.tsx'
]
}
},
'import/extensions': [
...reactSettings['import/extensions'],
'.tsx'
],
},
rules: {
"@typescript-eslint/class-methods-use-this": reactRules['class-methods-use-this'],
'import/extensions': [
reactRules['import/extensions'][0],
reactRules['import/extensions'][1],
{
...reactRules['import/extensions'][2],
'tsx': 'never',
},
],
"react/jsx-filename-extension": [reactFilenameExtensionRule[0], {
...reactFilenameExtensionRule[1],
'extensions': [
...reactFilenameExtensionRule[1].extensions,
'.tsx',
],
}],
'react/require-default-props': 'off'
}
};

2045
yarn.lock Normal file

File diff suppressed because it is too large Load Diff