eslint-rules/.eslintrc.js
2024-08-13 03:37:00 -04:00

196 lines
6.8 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module.exports = {
root: true,
plugins: ['unicorn', 'jsdoc', 'import-x'],
env: { node: true, browser: true, es2023: true },
reportUnusedDisableDirectives: true,
parserOptions: {
project: true,
},
ignorePatterns: [],
globals: {},
extends: [
'eslint:recommended',
'prettier',
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:jsdoc/recommended-typescript',
],
overrides: [
{
files: ['repl.ts', 'scripts/**/*.ts'],
rules: { 'no-console': 'off' },
},
{
files: ['.eslintrc.js', '.eslintrc.cjs', '*.config.js', 'index.js'],
extends: ['plugin:@typescript-eslint/disable-type-checked'],
rules: { 'rules/restrict-template-expressions': 'off' },
},
{
files: ['*.d.ts'],
rules: { '@typescript-eslint/consistent-type-imports': 'off' },
},
],
rules: {
'import-x/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
],
'newlines-between': 'always-and-inside-groups',
alphabetize: { order: 'asc', caseInsensitive: true },
},
],
'arrow-body-style': ['error', 'as-needed'],
'class-methods-use-this': 'warn',
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
'no-async-promise-executor': 'off',
'no-case-declarations': 'off',
'no-console': 'warn',
'no-constant-condition': ['error', { checkLoops: false }],
'no-debugger': 'warn',
'no-duplicate-imports': 'off',
'no-empty': ['error', { allowEmptyCatch: true }],
'no-inner-declarations': 'off',
'no-lonely-if': 'error',
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'crypto',
importNames: ['webcrypto'],
message: 'Use global `crypto` instead',
},
],
},
],
'no-template-curly-in-string': 'error',
'no-var': 'error',
'object-shorthand': ['error', 'always', { ignoreConstructors: true }],
'one-var': ['error', { var: 'never', let: 'never', const: 'never' }],
'prefer-arrow-callback': 'off',
'prefer-const': ['error', { destructuring: 'all' }],
'prefer-destructuring': [
'warn',
{ AssignmentExpression: { array: false, object: false } },
],
'prefer-object-spread': 'error',
'prefer-rest-params': 'warn',
'prefer-spread': 'warn',
'quote-props': ['error', 'as-needed'],
'sort-imports': ['warn', { ignoreDeclarationSort: true }],
'spaced-comment': [
'error',
'always',
{ markers: ['/', '#', '@'], block: { exceptions: ['@'] } },
],
complexity: ['warn', { max: 100 }],
curly: ['error', 'multi-line', 'consistent'],
eqeqeq: ['error', 'smart'],
yoda: ['error', 'never', { exceptRange: true }],
'jsdoc/require-jsdoc': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-expect-error': 'allow-with-description',
'ts-check': false,
'ts-ignore': 'allow-with-description',
'ts-nocheck': 'allow-with-description',
},
],
'@typescript-eslint/consistent-type-imports': [
'error',
{
disallowTypeAnnotations: false,
fixStyle: 'inline-type-imports',
},
],
'@typescript-eslint/explicit-member-accessibility': [
'warn',
{ accessibility: 'no-public' },
],
'@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/unbound-method': 'off',
'unicorn/better-regex': 'error',
'unicorn/consistent-function-scoping': 'warn',
'unicorn/escape-case': 'error',
'unicorn/no-array-for-each': 'warn',
'unicorn/no-array-method-this-argument': 'error',
'unicorn/no-array-push-push': 'warn',
'unicorn/no-console-spaces': 'warn',
'unicorn/no-for-loop': 'warn',
'unicorn/no-instanceof-array': 'error',
'unicorn/no-lonely-if': 'warn',
'unicorn/no-static-only-class': 'error',
'unicorn/no-typeof-undefined': 'error',
'unicorn/no-useless-fallback-in-spread': 'error',
'unicorn/no-useless-promise-resolve-reject': 'error',
'unicorn/no-useless-spread': 'error',
'unicorn/no-useless-switch-case': 'error',
'unicorn/prefer-array-find': 'error',
'unicorn/prefer-array-flat-map': 'error',
'unicorn/prefer-array-some': 'error',
'unicorn/prefer-at': 'error',
'unicorn/prefer-blob-reading-methods': 'error',
'unicorn/prefer-date-now': 'error',
'unicorn/prefer-default-parameters': 'warn',
'unicorn/prefer-dom-node-dataset': 'error',
'unicorn/prefer-dom-node-remove': 'error',
'unicorn/prefer-export-from': ['error', { ignoreUsedVariables: false }],
'unicorn/prefer-includes': 'error',
'unicorn/prefer-keyboard-event-key': 'warn',
'unicorn/prefer-logical-operator-over-ternary': 'warn',
'unicorn/prefer-math-trunc': 'error',
'unicorn/prefer-modern-math-apis': 'error',
'unicorn/prefer-negative-index': 'error',
'unicorn/prefer-node-protocol': 'error',
'unicorn/prefer-object-from-entries': 'error',
'unicorn/prefer-optional-catch-binding': 'error',
'unicorn/prefer-reflect-apply': 'error',
'unicorn/prefer-regexp-test': 'error',
'unicorn/prefer-set-has': 'warn',
'unicorn/prefer-string-slice': 'error',
'unicorn/prefer-string-starts-ends-with': 'warn',
'unicorn/prefer-string-trim-start-end': 'error',
'unicorn/prefer-ternary': 'warn',
'unicorn/string-content': [
'warn',
{
patterns: {
'->': { suggest: '→', fix: false },
'=>': { suggest: '⇒', fix: false },
'<-': { suggest: '←', fix: false },
'<=': { suggest: '≤', fix: false },
'>=': { suggest: '≥', fix: false },
'!=': { suggest: '≠', fix: false },
'<=>': { suggest: '⇔', fix: false },
'\\.\\.\\.': { suggest: '…', fix: false },
"'s ": { suggest: 's ', fix: false },
},
},
],
'unicorn/template-indent': 'warn',
},
parser: '@typescript-eslint/parser',
};