mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
workspace: update eslint rule (#1027)
This commit is contained in:
1 parent
05c3b8f2bd
commit
cee3c00ddb
150 files changed
+1069
-1043
No files matched your search
+366
-385
@@ -1,409 +1,144 @@
|
||||
import { FlatCompat } from '@eslint/eslintrc';
|
||||
/* eslint perfectionist/sort-objects: error */
|
||||
import antfu from '@antfu/eslint-config';
|
||||
import eslintReact from '@eslint-react/eslint-plugin';
|
||||
import stylistic from '@stylistic/eslint-plugin';
|
||||
import typescriptEslint from '@typescript-eslint/eslint-plugin';
|
||||
import tsParser from '@typescript-eslint/parser';
|
||||
import { defineConfig, globalIgnores } from 'eslint/config';
|
||||
import deMorgan from 'eslint-plugin-de-morgan';
|
||||
import github from 'eslint-plugin-github';
|
||||
import jsxA11Y from 'eslint-plugin-jsx-a11y';
|
||||
import reactRefresh from 'eslint-plugin-react-refresh';
|
||||
import simpleImportSort from 'eslint-plugin-simple-import-sort';
|
||||
|
||||
const compat = new FlatCompat({});
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores([
|
||||
'**/*.d.ts',
|
||||
'**/node_modules',
|
||||
'**/.git',
|
||||
]),
|
||||
/** @type {typeof antfu} */
|
||||
const base = (option, ...args) => antfu(
|
||||
{
|
||||
extends: [
|
||||
compat.extends('airbnb-base'),
|
||||
compat.extends('airbnb/hooks'),
|
||||
github.getFlatConfigs().react,
|
||||
deMorgan.configs.recommended,
|
||||
eslintReact.configs['recommended-typescript'],
|
||||
markdown: false,
|
||||
typescript: true,
|
||||
vue: true,
|
||||
...option,
|
||||
gitignore: false,
|
||||
ignores: [
|
||||
'**/*.d.ts',
|
||||
'**/.git',
|
||||
'**/.pnp.*',
|
||||
...(option.ignores || []),
|
||||
],
|
||||
|
||||
settings: {
|
||||
'import/parsers': {
|
||||
'@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
|
||||
},
|
||||
|
||||
'import/resolver': {
|
||||
node: {
|
||||
extensions: ['.mjs', '.js', '.json', '.ts', '.d.ts'],
|
||||
},
|
||||
},
|
||||
|
||||
'import/extensions': ['.js', '.mjs', '.jsx', '.ts', '.tsx', '.d.ts'],
|
||||
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
|
||||
},
|
||||
|
||||
plugins: {
|
||||
'@typescript-eslint': typescriptEslint,
|
||||
'simple-import-sort': simpleImportSort,
|
||||
// import: fixupPluginRules(_import),
|
||||
'react-refresh': reactRefresh,
|
||||
'jsx-a11y': jsxA11Y,
|
||||
'@stylistic': stylistic,
|
||||
},
|
||||
|
||||
languageOptions: {
|
||||
globals: {
|
||||
Atomics: 'readonly',
|
||||
SharedArrayBuffer: 'readonly',
|
||||
BigInt: 'readonly',
|
||||
SharedArrayBuffer: 'readonly',
|
||||
...(option.languageOptions?.globals || {}),
|
||||
},
|
||||
|
||||
parser: tsParser,
|
||||
...(option.languageOptions || {}),
|
||||
},
|
||||
lessOpinionated: true,
|
||||
plugins: {
|
||||
'@eslint-react': eslintReact,
|
||||
'react-refresh': reactRefresh,
|
||||
'simple-import-sort': simpleImportSort,
|
||||
...(option.plugins || {}),
|
||||
},
|
||||
|
||||
rules: {
|
||||
'brace-style': 'off',
|
||||
'@eslint-react/dom/no-missing-button-type': 0,
|
||||
// to allow `javascript:;`
|
||||
'@eslint-react/dom/no-script-url': 0,
|
||||
'@eslint-react/hooks-extra/no-direct-set-state-in-use-effect': 0,
|
||||
'@eslint-react/hooks-extra/no-unnecessary-use-prefix': 0,
|
||||
'@eslint-react/no-array-index-key': 0,
|
||||
|
||||
'@stylistic/brace-style': ['error', '1tbs', {
|
||||
allowSingleLine: true,
|
||||
}],
|
||||
// ui-default is currently on react 18
|
||||
'@eslint-react/no-prop-types': 0,
|
||||
'@eslint-react/no-string-refs': 0,
|
||||
|
||||
camelcase: 'off',
|
||||
'comma-dangle': 'off',
|
||||
|
||||
'@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',
|
||||
}],
|
||||
|
||||
'comma-spacing': 'off',
|
||||
|
||||
'@stylistic/comma-spacing': ['error', {
|
||||
before: false,
|
||||
after: true,
|
||||
}],
|
||||
'antfu/consistent-chaining': 'off',
|
||||
'antfu/consistent-list-newline': 'off',
|
||||
|
||||
'class-methods-use-this': 0,
|
||||
'consistent-return': 1,
|
||||
curly: ['error', 'multi-line'],
|
||||
'default-param-last': 'off',
|
||||
|
||||
'func-call-spacing': 'off',
|
||||
'function-call-spacing': 'off',
|
||||
'@stylistic/function-call-spacing': ['error', 'never'],
|
||||
indent: 'off',
|
||||
|
||||
'@stylistic/indent': ['warn', 4, {
|
||||
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,
|
||||
}],
|
||||
|
||||
'keyword-spacing': 'off',
|
||||
|
||||
'@stylistic/keyword-spacing': ['error', {
|
||||
before: true,
|
||||
after: true,
|
||||
|
||||
overrides: {
|
||||
return: {
|
||||
after: true,
|
||||
},
|
||||
|
||||
throw: {
|
||||
after: true,
|
||||
},
|
||||
|
||||
case: {
|
||||
after: true,
|
||||
},
|
||||
},
|
||||
}],
|
||||
|
||||
'lines-between-class-members': 'off',
|
||||
|
||||
'@stylistic/lines-between-class-members': ['error', 'always', {
|
||||
exceptAfterSingleLine: true,
|
||||
}],
|
||||
|
||||
'no-array-constructor': 'off',
|
||||
'@typescript-eslint/no-array-constructor': 'error',
|
||||
'no-dupe-class-members': 'off',
|
||||
'@typescript-eslint/no-dupe-class-members': 'error',
|
||||
'no-empty-function': 'off',
|
||||
|
||||
'@typescript-eslint/no-empty-function': ['error', {
|
||||
allow: ['arrowFunctions', 'functions', 'methods'],
|
||||
}],
|
||||
|
||||
'no-extra-parens': 'off',
|
||||
|
||||
'@typescript-eslint/no-extra-parens': ['off', 'all', {
|
||||
conditionalAssign: true,
|
||||
nestedBinaryExpressions: false,
|
||||
returnAssign: false,
|
||||
ignoreJSX: 'all',
|
||||
enforceForArrowConditionals: false,
|
||||
}],
|
||||
|
||||
'no-extra-semi': 'off',
|
||||
'@stylistic/no-extra-semi': 'error',
|
||||
'no-new-func': 'off',
|
||||
'no-loss-of-precision': 'off',
|
||||
'@typescript-eslint/no-loss-of-precision': 'error',
|
||||
'no-loop-func': 'off',
|
||||
'@typescript-eslint/no-loop-func': 'error',
|
||||
'no-magic-numbers': 'off',
|
||||
|
||||
'@typescript-eslint/no-magic-numbers': ['off', {
|
||||
ignore: [],
|
||||
ignoreArrayIndexes: true,
|
||||
enforceConst: true,
|
||||
detectObjects: false,
|
||||
}],
|
||||
|
||||
'no-redeclare': 'off',
|
||||
'@typescript-eslint/no-redeclare': 'error',
|
||||
'no-shadow': 'off',
|
||||
'@typescript-eslint/no-shadow': 'error',
|
||||
'space-before-blocks': 'off',
|
||||
'@stylistic/space-before-blocks': 'error',
|
||||
'no-unused-expressions': 'off',
|
||||
|
||||
'@typescript-eslint/no-unused-expressions': ['error', {
|
||||
allowShortCircuit: false,
|
||||
allowTernary: false,
|
||||
allowTaggedTemplates: false,
|
||||
}],
|
||||
|
||||
'no-unused-vars': 'off',
|
||||
|
||||
'@typescript-eslint/no-unused-vars': ['error', {
|
||||
vars: 'all',
|
||||
args: 'after-used',
|
||||
ignoreRestSiblings: true,
|
||||
caughtErrorsIgnorePattern: '^_|e',
|
||||
argsIgnorePattern: '^_',
|
||||
}],
|
||||
|
||||
'no-use-before-define': 'off',
|
||||
|
||||
'@typescript-eslint/no-use-before-define': ['error', {
|
||||
functions: true,
|
||||
classes: true,
|
||||
variables: true,
|
||||
}],
|
||||
|
||||
'no-useless-constructor': 'off',
|
||||
'@typescript-eslint/no-useless-constructor': 'error',
|
||||
quotes: 'off',
|
||||
|
||||
'@stylistic/quotes': ['warn', 'single', {
|
||||
avoidEscape: true,
|
||||
}],
|
||||
|
||||
semi: 'off',
|
||||
'@stylistic/semi': ['error', 'always'],
|
||||
'space-before-function-paren': 'off',
|
||||
|
||||
'@stylistic/space-before-function-paren': ['error', {
|
||||
anonymous: 'always',
|
||||
named: 'never',
|
||||
asyncArrow: 'always',
|
||||
}],
|
||||
|
||||
'require-await': 'off',
|
||||
'@typescript-eslint/require-await': 'off',
|
||||
'space-infix-ops': 'off',
|
||||
'@stylistic/space-infix-ops': 'error',
|
||||
'object-curly-spacing': 'off',
|
||||
'@stylistic/object-curly-spacing': ['error', 'always'],
|
||||
|
||||
'function-call-argument-newline': 0,
|
||||
|
||||
'no-implicit-coercion': ['warn', {
|
||||
allow: ['!!', '+'],
|
||||
}],
|
||||
|
||||
'no-extra-boolean-cast': ['warn', {
|
||||
enforceForLogicalOperands: true,
|
||||
}],
|
||||
|
||||
'no-empty-pattern': 0,
|
||||
'no-multi-str': 0,
|
||||
|
||||
'dot-notation': 0,
|
||||
|
||||
'@typescript-eslint/naming-convention': [
|
||||
'warn',
|
||||
{
|
||||
selector: 'default',
|
||||
format: ['camelCase'],
|
||||
leadingUnderscore: 'allowSingleOrDouble',
|
||||
}, {
|
||||
selector: 'default',
|
||||
|
||||
filter: {
|
||||
regex: '^([A-Z]|_+id|__call__)$',
|
||||
match: true,
|
||||
},
|
||||
|
||||
format: null,
|
||||
}, {
|
||||
selector: 'variable',
|
||||
modifiers: ['destructured'],
|
||||
format: null,
|
||||
}, {
|
||||
selector: 'import',
|
||||
format: null,
|
||||
}, {
|
||||
selector: 'variable',
|
||||
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
|
||||
modifiers: ['const'],
|
||||
leadingUnderscore: 'allowSingleOrDouble',
|
||||
}, {
|
||||
selector: 'property',
|
||||
format: ['camelCase', 'PascalCase', 'UPPER_CASE', 'snake_case'],
|
||||
leadingUnderscore: 'allowSingleOrDouble',
|
||||
}, {
|
||||
selector: ['function', 'parameter', 'parameterProperty', 'objectLiteralMethod'],
|
||||
|
||||
filter: {
|
||||
regex: '__call__',
|
||||
match: false,
|
||||
},
|
||||
|
||||
format: ['camelCase', 'PascalCase'],
|
||||
leadingUnderscore: 'allowSingleOrDouble',
|
||||
}, {
|
||||
selector: ['objectLiteralProperty'],
|
||||
|
||||
filter: {
|
||||
regex: '^[\\d]+$',
|
||||
match: true,
|
||||
},
|
||||
|
||||
format: null,
|
||||
}, {
|
||||
selector: ['typeProperty', 'typeMethod', 'objectLiteralProperty'],
|
||||
modifiers: ['requiresQuotes'],
|
||||
format: null,
|
||||
}, {
|
||||
selector: ['typeMethod'],
|
||||
format: ['camelCase', 'PascalCase'],
|
||||
}, {
|
||||
selector: ['enum', 'class', 'interface'],
|
||||
format: ['PascalCase'],
|
||||
}, {
|
||||
selector: ['typeAlias', 'enumMember', 'typeParameter'],
|
||||
format: ['PascalCase', 'camelCase', 'UPPER_CASE'],
|
||||
},
|
||||
],
|
||||
|
||||
'@typescript-eslint/no-invalid-this': 0,
|
||||
|
||||
'class-methods-use-this': 0,
|
||||
'eslint-comments/no-unlimited-disable': 'off',
|
||||
'func-names': 0,
|
||||
'function-call-argument-newline': 0,
|
||||
'function-paren-newline': 0,
|
||||
'github/a11y-svg-has-accessible-name': 0,
|
||||
'github/array-foreach': 1,
|
||||
'global-require': 0,
|
||||
'guard-for-in': 0,
|
||||
'implicit-arrow-linebreak': 0,
|
||||
|
||||
'import/consistent-type-specifier-style': 'off',
|
||||
'import/extensions': 0,
|
||||
'import/order': 0,
|
||||
'consistent-return': 1,
|
||||
'func-names': 0,
|
||||
'import/newline-after-import': 0,
|
||||
'import/no-cycle': 0,
|
||||
'import/no-extraneous-dependencies': 0,
|
||||
'import/no-named-as-default': 0,
|
||||
'import/order': 0,
|
||||
'import/prefer-default-export': 0,
|
||||
|
||||
'jsx-a11y/anchor-is-valid': 0,
|
||||
'jsx-a11y/click-events-have-key-events': 0,
|
||||
'jsx-a11y/label-has-associated-control': 0,
|
||||
'jsx-a11y/no-static-element-interactions': 0,
|
||||
|
||||
'logical-assignment-operators': ['warn', 'always', {
|
||||
enforceForIfStatements: true,
|
||||
}],
|
||||
|
||||
'max-classes-per-file': 0,
|
||||
'max-len': ['warn', 150],
|
||||
'newline-per-chained-call': 0,
|
||||
'no-await-in-loop': 1,
|
||||
'no-bitwise': 0,
|
||||
'no-console': 0,
|
||||
'no-continue': 0,
|
||||
'no-extend-native': 0,
|
||||
|
||||
'no-empty': ['warn', {
|
||||
allowEmptyCatch: true,
|
||||
}],
|
||||
|
||||
'no-await-in-loop': 1,
|
||||
'no-empty-pattern': 0,
|
||||
'no-extend-native': 0,
|
||||
'no-extra-boolean-cast': ['warn', {
|
||||
enforceForLogicalOperands: true,
|
||||
}],
|
||||
'no-implicit-coercion': ['warn', {
|
||||
allow: ['!!', '+'],
|
||||
}],
|
||||
'no-multi-assign': 0,
|
||||
'no-return-await': 0,
|
||||
'no-multi-str': 0,
|
||||
'no-nested-ternary': 0,
|
||||
'no-param-reassign': 0,
|
||||
'no-plusplus': 0,
|
||||
'no-underscore-dangle': 0,
|
||||
'no-unmodified-loop-condition': 1,
|
||||
'prefer-destructuring': 0,
|
||||
'function-paren-newline': 0,
|
||||
'simple-import-sort/exports': 0,
|
||||
|
||||
'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: 'LabeledStatement',
|
||||
}, {
|
||||
selector: 'WithStatement',
|
||||
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
|
||||
selector: 'WithStatement',
|
||||
},
|
||||
],
|
||||
'no-return-await': 0,
|
||||
'no-underscore-dangle': 0,
|
||||
'no-unmodified-loop-condition': 1,
|
||||
|
||||
'generator-star-spacing': 0,
|
||||
'node/prefer-global/buffer': 'off',
|
||||
'node/prefer-global/process': 'off',
|
||||
'perfectionist/sort-imports': 'off',
|
||||
'perfectionist/sort-named-imports': 'off',
|
||||
|
||||
'github/array-foreach': 1,
|
||||
'github/a11y-svg-has-accessible-name': 0,
|
||||
'prefer-destructuring': 0,
|
||||
'quote-props': 0,
|
||||
'@stylistic/quote-props': [0, 'as-needed'],
|
||||
'react-hooks/exhaustive-deps': 0,
|
||||
'react-refresh/only-export-components': ['warn', {
|
||||
allowConstantExport: true,
|
||||
}],
|
||||
|
||||
'regexp/prefer-d': 'off',
|
||||
'regexp/prefer-w': 'off',
|
||||
'regexp/use-ignore-case': 'off',
|
||||
|
||||
'simple-import-sort/exports': 0,
|
||||
'simple-import-sort/imports': ['warn', {
|
||||
groups: [
|
||||
['^\\u0000'],
|
||||
@@ -416,50 +151,290 @@ export default defineConfig([
|
||||
],
|
||||
}],
|
||||
|
||||
// ui-default is currently on react 18
|
||||
'@eslint-react/no-prop-types': 0,
|
||||
'@eslint-react/no-string-refs': 0,
|
||||
|
||||
// to allow `javascript:;`
|
||||
'@eslint-react/dom/no-script-url': 0,
|
||||
|
||||
'@eslint-react/no-array-index-key': 0,
|
||||
'@eslint-react/dom/no-missing-button-type': 0,
|
||||
'@eslint-react/dom/no-dangerously-set-innerhtml': 0,
|
||||
'@eslint-react/hooks-extra/no-direct-set-state-in-use-effect': 0,
|
||||
'@eslint-react/hooks-extra/no-unnecessary-use-prefix': 0,
|
||||
'react-hooks/exhaustive-deps': 0,
|
||||
// 'react/prefer-stateless-function': 0,
|
||||
// 'react/function-component-definition': 0,
|
||||
// 'react/static-property-placement': 0,
|
||||
// 'react/self-closing-comp': 0,
|
||||
// 'react/prop-types': 0,
|
||||
// 'react/jsx-filename-extension': 0,
|
||||
// 'react/jsx-one-expression-per-line': 0,
|
||||
// 'react/jsx-props-no-spreading': 0,
|
||||
// 'react/no-string-refs': 0,
|
||||
// 'react/require-default-props': 0,
|
||||
// 'react/react-in-jsx-scope': 0,
|
||||
// 'react/destructuring-assignment': 0,
|
||||
// 'react/button-has-type': 0,
|
||||
// 'react/forbid-prop-types': 0,
|
||||
'jsx-a11y/no-static-element-interactions': 0,
|
||||
'jsx-a11y/anchor-is-valid': 0,
|
||||
'jsx-a11y/click-events-have-key-events': 0,
|
||||
'jsx-a11y/label-has-associated-control': 0,
|
||||
|
||||
'react-refresh/only-export-components': ['warn', {
|
||||
allowConstantExport: true,
|
||||
'style/arrow-parens': ['error', 'always'],
|
||||
'style/brace-style': ['error', '1tbs', {
|
||||
allowSingleLine: true,
|
||||
}],
|
||||
'style/comma-dangle': ['error', {
|
||||
arrays: 'always-multiline',
|
||||
enums: 'always-multiline',
|
||||
exports: 'always-multiline',
|
||||
functions: 'always-multiline',
|
||||
generics: 'always-multiline',
|
||||
imports: 'always-multiline',
|
||||
objects: 'always-multiline',
|
||||
tuples: 'always-multiline',
|
||||
}],
|
||||
'style/comma-spacing': ['error', {
|
||||
after: true,
|
||||
before: false,
|
||||
}],
|
||||
'style/function-call-spacing': ['error', 'never'],
|
||||
'style/generator-star-spacing': ['error', {
|
||||
after: true,
|
||||
anonymous: { after: true, before: false },
|
||||
before: false,
|
||||
method: { after: false, before: true },
|
||||
}],
|
||||
'style/indent': ['warn', option.stylistic?.indent ?? 4, {
|
||||
ArrayExpression: 1,
|
||||
CallExpression: {
|
||||
arguments: 1,
|
||||
},
|
||||
flatTernaryExpressions: false,
|
||||
FunctionDeclaration: {
|
||||
body: 1,
|
||||
parameters: 1,
|
||||
},
|
||||
FunctionExpression: {
|
||||
body: 1,
|
||||
parameters: 1,
|
||||
},
|
||||
ignoreComments: false,
|
||||
ignoredNodes: [
|
||||
// 'JSXElement',
|
||||
// 'JSXElement > *',
|
||||
// 'JSXAttribute',
|
||||
// 'JSXIdentifier',
|
||||
// 'JSXNamespacedName',
|
||||
// 'JSXMemberExpression',
|
||||
// 'JSXSpreadAttribute',
|
||||
// 'JSXExpressionContainer',
|
||||
// 'JSXOpeningElement',
|
||||
// 'JSXClosingElement',
|
||||
// 'JSXFragment',
|
||||
// 'JSXOpeningFragment',
|
||||
// 'JSXClosingFragment',
|
||||
'JSXText',
|
||||
// 'JSXEmptyExpression',
|
||||
// 'JSXSpreadChild',
|
||||
],
|
||||
ImportDeclaration: 1,
|
||||
ObjectExpression: 1,
|
||||
outerIIFEBody: 1,
|
||||
SwitchCase: 1,
|
||||
VariableDeclarator: 1,
|
||||
}],
|
||||
'style/jsx-closing-bracket-location': 'off',
|
||||
'style/jsx-closing-tag-location': 'off',
|
||||
'style/jsx-function-call-newline': 'off',
|
||||
'style/jsx-indent-props': 'off',
|
||||
'style/jsx-one-expression-per-line': 'off',
|
||||
'style/jsx-wrap-multilines': 'off',
|
||||
'style/keyword-spacing': ['error', {
|
||||
after: true,
|
||||
before: true,
|
||||
overrides: {
|
||||
case: {
|
||||
after: true,
|
||||
},
|
||||
return: {
|
||||
after: true,
|
||||
},
|
||||
throw: {
|
||||
after: true,
|
||||
},
|
||||
},
|
||||
}],
|
||||
'style/lines-between-class-members': ['error', 'always', {
|
||||
exceptAfterSingleLine: true,
|
||||
}],
|
||||
'style/max-statements-per-line': ['error', { max: 2 }],
|
||||
'style/member-delimiter-style': ['error', {
|
||||
multiline: {
|
||||
delimiter: 'semi',
|
||||
requireLast: true,
|
||||
},
|
||||
multilineDetection: 'brackets',
|
||||
singleline: {
|
||||
delimiter: 'comma',
|
||||
requireLast: false,
|
||||
},
|
||||
}],
|
||||
'style/multiline-ternary': 'off',
|
||||
'style/no-extra-semi': 'error',
|
||||
'style/object-curly-spacing': ['error', 'always'],
|
||||
'style/operator-linebreak': ['warn', 'before', {
|
||||
overrides: {
|
||||
'=': 'after',
|
||||
},
|
||||
}],
|
||||
'style/quote-props': ['warn', 'as-needed'],
|
||||
'style/quotes': ['warn', 'single', {
|
||||
avoidEscape: true,
|
||||
}],
|
||||
'style/space-before-blocks': 'error',
|
||||
'style/space-before-function-paren': ['error', {
|
||||
anonymous: 'always',
|
||||
asyncArrow: 'always',
|
||||
named: 'never',
|
||||
}],
|
||||
'style/space-infix-ops': 'error',
|
||||
|
||||
'test/no-import-node-test': 'off',
|
||||
|
||||
'ts/ban-ts-comment': 'off',
|
||||
'ts/consistent-type-imports': 'off',
|
||||
'ts/method-signature-style': 'off',
|
||||
'ts/no-array-constructor': 'error',
|
||||
'ts/no-dupe-class-members': 'error',
|
||||
'ts/no-empty-function': ['error', {
|
||||
allow: ['arrowFunctions', 'functions', 'methods'],
|
||||
}],
|
||||
'ts/no-extra-parens': ['off', 'all', {
|
||||
conditionalAssign: true,
|
||||
enforceForArrowConditionals: false,
|
||||
ignoreJSX: 'all',
|
||||
nestedBinaryExpressions: false,
|
||||
returnAssign: false,
|
||||
}],
|
||||
'ts/no-invalid-this': 'off',
|
||||
'ts/no-loop-func': 'error',
|
||||
'ts/no-loss-of-precision': 'error',
|
||||
'ts/no-magic-numbers': 'off',
|
||||
'ts/no-namespace': 'off',
|
||||
'ts/no-redeclare': 'off',
|
||||
'ts/no-require-imports': 'off',
|
||||
'ts/no-shadow': 'error',
|
||||
'ts/no-this-alias': 'off',
|
||||
'ts/no-unused-expressions': ['error', {
|
||||
allowShortCircuit: false,
|
||||
allowTaggedTemplates: false,
|
||||
allowTernary: false,
|
||||
}],
|
||||
'ts/no-unused-vars': ['error', {
|
||||
args: 'after-used',
|
||||
argsIgnorePattern: '^_',
|
||||
caughtErrorsIgnorePattern: '^_|e',
|
||||
ignoreRestSiblings: true,
|
||||
vars: 'all',
|
||||
}],
|
||||
'ts/no-use-before-define': ['error', {
|
||||
classes: true,
|
||||
functions: true,
|
||||
variables: true,
|
||||
}],
|
||||
'ts/no-useless-constructor': 'error',
|
||||
'ts/prefer-as-const': 'off',
|
||||
'ts/require-await': 'off',
|
||||
|
||||
'unicorn/error-message': 'off',
|
||||
'unicorn/no-instanceof-builtins': 'off',
|
||||
'unicorn/prefer-node-protocol': 'off',
|
||||
|
||||
'unused-imports/no-unused-vars': 'off',
|
||||
|
||||
...(option.rules || {}),
|
||||
},
|
||||
settings: {
|
||||
'import/extensions': ['.js', '.mjs', '.jsx', '.ts', '.tsx', '.d.ts'],
|
||||
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
|
||||
'import/resolver': {
|
||||
node: {
|
||||
extensions: ['.mjs', '.js', '.json', '.ts', '.d.ts'],
|
||||
},
|
||||
},
|
||||
...(option.settings || {}),
|
||||
},
|
||||
stylistic: {
|
||||
indent: 4,
|
||||
quotes: undefined,
|
||||
semi: true,
|
||||
...(typeof option.stylistic === 'object' ? option.stylistic : {}),
|
||||
},
|
||||
},
|
||||
github.getFlatConfigs().react,
|
||||
deMorgan.configs.recommended,
|
||||
{
|
||||
files: ['**/*.vue'],
|
||||
rules: {
|
||||
'vue/block-order': ['warn', { order: ['template', 'script[setup]', 'script:not([setup])', 'style[scoped]', 'style:not([scoped])'] }],
|
||||
'vue/singleline-html-element-content-newline': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.ts', '**/*.tsx'],
|
||||
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.cjs', '**/*.cts', '**/*.mjs', '**/*.mts'],
|
||||
|
||||
languageOptions: {
|
||||
parser: tsParser,
|
||||
},
|
||||
|
||||
rules: {
|
||||
'ts/naming-convention': [
|
||||
'warn',
|
||||
{
|
||||
format: ['camelCase'],
|
||||
leadingUnderscore: 'allowSingleOrDouble',
|
||||
selector: 'default',
|
||||
}, {
|
||||
filter: {
|
||||
match: true,
|
||||
regex: '^([A-Z]|_+id|__call__)$',
|
||||
},
|
||||
format: null,
|
||||
selector: 'default',
|
||||
}, {
|
||||
format: null,
|
||||
modifiers: ['destructured'],
|
||||
selector: 'variable',
|
||||
}, {
|
||||
format: null,
|
||||
selector: 'import',
|
||||
}, {
|
||||
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
|
||||
leadingUnderscore: 'allowSingleOrDouble',
|
||||
modifiers: ['const'],
|
||||
selector: 'variable',
|
||||
}, {
|
||||
format: ['camelCase', 'PascalCase', 'UPPER_CASE', 'snake_case'],
|
||||
leadingUnderscore: 'allowSingleOrDouble',
|
||||
selector: 'property',
|
||||
}, {
|
||||
filter: {
|
||||
match: false,
|
||||
regex: '__call__',
|
||||
},
|
||||
format: ['camelCase', 'PascalCase'],
|
||||
leadingUnderscore: 'allowSingleOrDouble',
|
||||
selector: ['function', 'parameter', 'parameterProperty', 'objectLiteralMethod'],
|
||||
}, {
|
||||
filter: {
|
||||
match: true,
|
||||
regex: '^[\\d]+$',
|
||||
},
|
||||
format: null,
|
||||
selector: ['objectLiteralProperty'],
|
||||
}, {
|
||||
format: null,
|
||||
modifiers: ['requiresQuotes'],
|
||||
selector: ['typeProperty', 'typeMethod', 'objectLiteralProperty'],
|
||||
}, {
|
||||
format: ['camelCase', 'PascalCase'],
|
||||
selector: ['typeMethod'],
|
||||
}, {
|
||||
format: ['PascalCase'],
|
||||
selector: ['enum', 'class', 'interface'],
|
||||
}, {
|
||||
format: ['PascalCase', 'camelCase', 'UPPER_CASE'],
|
||||
selector: ['typeAlias', 'enumMember', 'typeParameter'],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'],
|
||||
|
||||
languageOptions: {
|
||||
parser: tsParser,
|
||||
},
|
||||
|
||||
// Hand over to tsc
|
||||
rules: {
|
||||
'constructor-super': 'off',
|
||||
'getter-return': 'off',
|
||||
'import/named': 'off',
|
||||
'import/no-named-as-default-member': 'off',
|
||||
'import/no-unresolved': 'off',
|
||||
'no-const-assign': 'off',
|
||||
'no-dupe-args': 'off',
|
||||
'no-dupe-class-members': 'off',
|
||||
@@ -475,9 +450,15 @@ export default defineConfig([
|
||||
'no-unreachable': 'off',
|
||||
'no-unsafe-negation': 'off',
|
||||
'valid-typeof': 'off',
|
||||
'import/named': 'off',
|
||||
'import/no-named-as-default-member': 'off',
|
||||
'import/no-unresolved': 'off',
|
||||
},
|
||||
},
|
||||
]);
|
||||
{
|
||||
files: ['**/*.yaml', '**/*.yml'],
|
||||
rules: {
|
||||
'style/no-multi-spaces': 'off',
|
||||
},
|
||||
},
|
||||
...args,
|
||||
);
|
||||
|
||||
export default base;
|
||||
@@ -1,22 +1,16 @@
|
||||
{
|
||||
"name": "@hydrooj/eslint-config",
|
||||
"version": "2.0.3",
|
||||
"version": "3.0.0",
|
||||
"license": "MIT",
|
||||
"main": "base.mjs",
|
||||
"repository": "https://github.com/hydro-dev/Hydro",
|
||||
"dependencies": {
|
||||
"@antfu/eslint-config": "^5.2.0",
|
||||
"@eslint-react/eslint-plugin": "^1.52.3",
|
||||
"@eslint/compat": "^1.3.1",
|
||||
"@eslint/eslintrc": "^3.3.1",
|
||||
"@stylistic/eslint-plugin": "^5.2.2",
|
||||
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
||||
"@typescript-eslint/parser": "^8.38.0",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
"eslint-config-airbnb-base": "^15.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.39.0",
|
||||
"@typescript-eslint/parser": "^8.39.0",
|
||||
"eslint-plugin-de-morgan": "^1.3.1",
|
||||
"eslint-plugin-github": "^6.0.0",
|
||||
"eslint-plugin-import": "2.31.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.20",
|
||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||
|
||||
Reference in new issue
Block a user