Refine eslint configuration
[poolifier.git] / .eslintrc.js
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', 'prettierx', 'jsdoc', 'spellcheck'],
16 extends: [
17 'standard',
18 'eslint:recommended',
19 'plugin:import/recommended',
20 'plugin:jsdoc/recommended',
21 'plugin:promise/recommended',
22 'plugin:prettierx/standardx'
23 ],
24 rules: {
25 'no-void': 'off',
26
27 'sort-imports': [
28 'warn',
29 {
30 ignoreMemberSort: true,
31 ignoreDeclarationSort: true
32 }
33 ],
34
35 'spellcheck/spell-checker': [
36 'warn',
37 {
38 skipWords: [
39 'browserslist',
40 'builtins',
41 'christopher',
42 'cjs',
43 'comparator',
44 'cpu',
45 'cpus',
46 'ctx',
47 'ecma',
48 'enum',
49 'fibonacci',
50 'fs',
51 'inheritDoc',
52 'jsdoc',
53 'microjob',
54 'num',
55 'os',
56 'piscina',
57 'poolifier',
58 'poolify',
59 'readonly',
60 'serializable',
61 'sinon',
62 'threadjs',
63 'threadwork',
64 'tsconfig',
65 'typedoc',
66 'unlink',
67 'unregister',
68 'utf8',
69 'workerpool'
70 ],
71 skipIfMatch: ['^@.*', '^plugin:.*']
72 }
73 ]
74 },
75 overrides: [
76 {
77 files: ['**/*.ts'],
78 parser: '@typescript-eslint/parser',
79 parserOptions: {
80 project: './tsconfig.json'
81 },
82 plugins: ['@typescript-eslint'],
83 extends: [
84 'plugin:@typescript-eslint/eslint-recommended',
85 'plugin:@typescript-eslint/recommended',
86 'plugin:@typescript-eslint/recommended-requiring-type-checking',
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']
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 })