| 1 | // @ts-check |
| 2 | const { defineConfig } = require('eslint-define-config') |
| 3 | |
| 4 | module.exports = defineConfig({ |
| 5 | env: { |
| 6 | es2021: true, |
| 7 | node: true, |
| 8 | mocha: true |
| 9 | }, |
| 10 | parser: '@typescript-eslint/parser', |
| 11 | parserOptions: { |
| 12 | ecmaVersion: 2020, |
| 13 | sourceType: 'module', |
| 14 | warnOnUnsupportedTypeScriptVersion: false |
| 15 | }, |
| 16 | plugins: [ |
| 17 | '@typescript-eslint', |
| 18 | 'promise', |
| 19 | 'prettierx', |
| 20 | 'jsdoc', |
| 21 | 'spellcheck' |
| 22 | ], |
| 23 | extends: [ |
| 24 | 'standard', |
| 25 | 'eslint:recommended', |
| 26 | 'plugin:import/recommended', |
| 27 | 'plugin:jsdoc/recommended', |
| 28 | 'plugin:promise/recommended', |
| 29 | 'plugin:prettierx/standardx' |
| 30 | ], |
| 31 | rules: { |
| 32 | 'no-void': 'off', |
| 33 | |
| 34 | 'sort-imports': [ |
| 35 | 'warn', |
| 36 | { |
| 37 | ignoreMemberSort: true, |
| 38 | ignoreDeclarationSort: true |
| 39 | } |
| 40 | ], |
| 41 | |
| 42 | 'spellcheck/spell-checker': [ |
| 43 | 'warn', |
| 44 | { |
| 45 | skipWords: [ |
| 46 | 'christopher', |
| 47 | 'comparator', |
| 48 | 'ecma', |
| 49 | 'enum', |
| 50 | 'inheritdoc', |
| 51 | 'jsdoc', |
| 52 | 'poolifier', |
| 53 | 'readonly', |
| 54 | 'serializable', |
| 55 | 'unregister', |
| 56 | 'workerpool' |
| 57 | ], |
| 58 | skipIfMatch: ['^@.*', '^plugin:.*'] |
| 59 | } |
| 60 | ] |
| 61 | }, |
| 62 | overrides: [ |
| 63 | { |
| 64 | files: ['**/*.ts'], |
| 65 | extends: [ |
| 66 | 'plugin:@typescript-eslint/recommended', |
| 67 | 'plugin:import/typescript' |
| 68 | ], |
| 69 | rules: { |
| 70 | // We have some intentionally empty functions |
| 71 | '@typescript-eslint/no-empty-function': 'off', |
| 72 | |
| 73 | '@typescript-eslint/no-inferrable-types': [ |
| 74 | 'error', |
| 75 | { ignoreProperties: true } |
| 76 | ], |
| 77 | |
| 78 | 'no-useless-constructor': 'off', |
| 79 | |
| 80 | 'jsdoc/match-description': [ |
| 81 | 'warn', |
| 82 | { |
| 83 | // mainDescription: |
| 84 | // '/^[A-Z`].+?(\\.|:)(\\n\\n.*((\\n{1,2}- .+)|(_.+_)|`.+`|\\n\\n---))?$/us', |
| 85 | // matchDescription: '^[A-Z`].+(\\.|`.+`)$', |
| 86 | contexts: ['any'], |
| 87 | tags: { |
| 88 | param: true, |
| 89 | returns: true |
| 90 | } |
| 91 | } |
| 92 | ], |
| 93 | 'jsdoc/no-types': 'error', |
| 94 | 'jsdoc/require-jsdoc': [ |
| 95 | 'warn', |
| 96 | { |
| 97 | contexts: [ |
| 98 | 'ClassDeclaration', |
| 99 | 'ClassProperty:not([accessibility=/(private|protected)/])', |
| 100 | 'ExportNamedDeclaration:has(VariableDeclaration)', |
| 101 | 'FunctionExpression', |
| 102 | 'MethodDefinition:not([accessibility=/(private|protected)/]) > FunctionExpression', |
| 103 | 'TSEnumDeclaration', |
| 104 | 'TSInterfaceDeclaration', |
| 105 | 'TSMethodSignature', |
| 106 | // 'TSPropertySignature', |
| 107 | 'TSTypeAliasDeclaration' |
| 108 | ] |
| 109 | } |
| 110 | ], |
| 111 | 'jsdoc/require-param-type': 'off', |
| 112 | 'jsdoc/require-returns-type': 'off' |
| 113 | } |
| 114 | }, |
| 115 | { |
| 116 | files: ['**/*.js'], |
| 117 | extends: 'plugin:node/recommended' |
| 118 | }, |
| 119 | { |
| 120 | files: ['tests/**/*.js'], |
| 121 | rules: { |
| 122 | 'jsdoc/require-jsdoc': 'off' |
| 123 | } |
| 124 | }, |
| 125 | { |
| 126 | files: ['benchmarks/**/*.js'], |
| 127 | rules: { |
| 128 | 'jsdoc/require-jsdoc': 'off' |
| 129 | } |
| 130 | }, |
| 131 | { |
| 132 | files: ['examples/**/*.js'], |
| 133 | rules: { |
| 134 | 'node/no-missing-require': 'off', |
| 135 | 'jsdoc/require-jsdoc': 'off' |
| 136 | } |
| 137 | }, |
| 138 | { |
| 139 | files: ['examples/typescript/**/*.ts'], |
| 140 | rules: { |
| 141 | 'import/no-unresolved': 'off', |
| 142 | 'jsdoc/require-jsdoc': 'off' |
| 143 | } |
| 144 | } |
| 145 | ], |
| 146 | settings: { |
| 147 | jsdoc: { |
| 148 | mode: 'typescript' |
| 149 | } |
| 150 | } |
| 151 | }) |