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