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