| 1 | // @ts-check |
| 2 | const { defineConfig } = require('eslint-define-config') |
| 3 | |
| 4 | module.exports = defineConfig({ |
| 5 | root: true, |
| 6 | env: { |
| 7 | es2021: true, |
| 8 | node: true, |
| 9 | mocha: true |
| 10 | }, |
| 11 | parserOptions: { |
| 12 | ecmaVersion: 2021, |
| 13 | sourceType: 'module' |
| 14 | }, |
| 15 | plugins: ['promise', 'jsdoc', 'spellcheck'], |
| 16 | extends: [ |
| 17 | 'eslint:recommended', |
| 18 | 'plugin:import/recommended', |
| 19 | 'plugin:jsdoc/recommended', |
| 20 | 'plugin:promise/recommended' |
| 21 | ], |
| 22 | rules: { |
| 23 | 'no-void': 'off', |
| 24 | |
| 25 | 'sort-imports': [ |
| 26 | 'warn', |
| 27 | { |
| 28 | ignoreMemberSort: true, |
| 29 | ignoreDeclarationSort: true |
| 30 | } |
| 31 | ], |
| 32 | |
| 33 | 'spellcheck/spell-checker': [ |
| 34 | 'warn', |
| 35 | { |
| 36 | skipWords: [ |
| 37 | 'benny', |
| 38 | 'browserslist', |
| 39 | 'builtins', |
| 40 | 'christopher', |
| 41 | 'cjs', |
| 42 | 'comparator', |
| 43 | 'cpu', |
| 44 | 'cpus', |
| 45 | 'ctx', |
| 46 | 'ecma', |
| 47 | 'enum', |
| 48 | 'fibonacci', |
| 49 | 'fs', |
| 50 | 'inheritDoc', |
| 51 | 'jsdoc', |
| 52 | 'microjob', |
| 53 | 'num', |
| 54 | 'os', |
| 55 | 'piscina', |
| 56 | 'poolifier', |
| 57 | 'poolify', |
| 58 | 'readonly', |
| 59 | 'serializable', |
| 60 | 'sinon', |
| 61 | 'threadjs', |
| 62 | 'threadwork', |
| 63 | 'tsconfig', |
| 64 | 'typedoc', |
| 65 | 'unlink', |
| 66 | 'unregister', |
| 67 | 'utf8', |
| 68 | 'workerpool' |
| 69 | ], |
| 70 | skipIfMatch: ['^@.*', '^plugin:.*'] |
| 71 | } |
| 72 | ] |
| 73 | }, |
| 74 | overrides: [ |
| 75 | { |
| 76 | files: ['**/*.ts'], |
| 77 | parser: '@typescript-eslint/parser', |
| 78 | parserOptions: { |
| 79 | project: './tsconfig.json' |
| 80 | }, |
| 81 | plugins: ['@typescript-eslint'], |
| 82 | extends: [ |
| 83 | 'plugin:@typescript-eslint/eslint-recommended', |
| 84 | 'plugin:@typescript-eslint/recommended', |
| 85 | 'plugin:@typescript-eslint/recommended-requiring-type-checking', |
| 86 | 'standard-with-typescript', |
| 87 | 'plugin:import/typescript' |
| 88 | ], |
| 89 | rules: { |
| 90 | // We have some intentionally empty functions |
| 91 | '@typescript-eslint/no-empty-function': 'off', |
| 92 | |
| 93 | '@typescript-eslint/no-inferrable-types': [ |
| 94 | 'error', |
| 95 | { ignoreProperties: true } |
| 96 | ], |
| 97 | |
| 98 | 'no-useless-constructor': 'off', |
| 99 | |
| 100 | 'jsdoc/match-description': [ |
| 101 | 'warn', |
| 102 | { |
| 103 | contexts: ['any'], |
| 104 | tags: { |
| 105 | param: true, |
| 106 | returns: true |
| 107 | } |
| 108 | } |
| 109 | ], |
| 110 | 'jsdoc/no-types': 'error', |
| 111 | 'jsdoc/require-jsdoc': [ |
| 112 | 'warn', |
| 113 | { |
| 114 | contexts: [ |
| 115 | 'ClassDeclaration', |
| 116 | 'ClassProperty:not([accessibility=/(private|protected)/])', |
| 117 | 'ExportNamedDeclaration:has(VariableDeclaration)', |
| 118 | 'FunctionExpression', |
| 119 | 'MethodDefinition:not([accessibility=/(private|protected)/]) > FunctionExpression', |
| 120 | 'TSEnumDeclaration', |
| 121 | 'TSInterfaceDeclaration', |
| 122 | 'TSMethodSignature', |
| 123 | // 'TSPropertySignature', |
| 124 | 'TSTypeAliasDeclaration' |
| 125 | ] |
| 126 | } |
| 127 | ], |
| 128 | 'jsdoc/require-param-type': 'off', |
| 129 | 'jsdoc/require-returns-type': 'off' |
| 130 | } |
| 131 | }, |
| 132 | { |
| 133 | files: ['examples/typescript/**/*.ts'], |
| 134 | rules: { |
| 135 | 'import/no-unresolved': 'off', |
| 136 | 'jsdoc/require-jsdoc': 'off', |
| 137 | '@typescript-eslint/no-unsafe-argument': 'off', |
| 138 | '@typescript-eslint/no-unsafe-call': 'off', |
| 139 | '@typescript-eslint/no-unsafe-assignment': 'off' |
| 140 | } |
| 141 | }, |
| 142 | { |
| 143 | files: ['**/*.js'], |
| 144 | extends: ['plugin:n/recommended', 'standard'] |
| 145 | }, |
| 146 | { |
| 147 | files: ['tests/**/*.js'], |
| 148 | rules: { |
| 149 | 'jsdoc/require-jsdoc': 'off' |
| 150 | } |
| 151 | }, |
| 152 | { |
| 153 | files: ['tests/pools/selection-strategies/**/*.js'], |
| 154 | rules: { |
| 155 | 'n/no-missing-require': 'off' |
| 156 | } |
| 157 | }, |
| 158 | { |
| 159 | files: ['benchmarks/**/*.js'], |
| 160 | rules: { |
| 161 | 'jsdoc/require-jsdoc': 'off' |
| 162 | } |
| 163 | }, |
| 164 | { |
| 165 | files: ['benchmarks/versus-external-pools/**/*.js'], |
| 166 | rules: { |
| 167 | 'n/no-missing-require': 'off' |
| 168 | } |
| 169 | }, |
| 170 | { |
| 171 | files: ['examples/**/*.js'], |
| 172 | rules: { |
| 173 | 'n/no-missing-require': 'off', |
| 174 | 'jsdoc/require-jsdoc': 'off' |
| 175 | } |
| 176 | } |
| 177 | ], |
| 178 | settings: { |
| 179 | jsdoc: { |
| 180 | mode: 'typescript' |
| 181 | } |
| 182 | } |
| 183 | }) |