f0f371e0ff772cb761ed8288ed1df6e50993c131
[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', '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 'browserslist',
38 'builtins',
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 'standard-with-typescript',
86 'plugin:import/typescript'
87 ],
88 rules: {
89 // We have some intentionally empty functions
90 '@typescript-eslint/no-empty-function': 'off',
91
92 '@typescript-eslint/no-inferrable-types': [
93 'error',
94 { ignoreProperties: true }
95 ],
96
97 'no-useless-constructor': 'off',
98
99 'jsdoc/match-description': [
100 'warn',
101 {
102 contexts: ['any'],
103 tags: {
104 param: true,
105 returns: true
106 }
107 }
108 ],
109 'jsdoc/no-types': 'error',
110 'jsdoc/require-jsdoc': [
111 'warn',
112 {
113 contexts: [
114 'ClassDeclaration',
115 'ClassProperty:not([accessibility=/(private|protected)/])',
116 'ExportNamedDeclaration:has(VariableDeclaration)',
117 'FunctionExpression',
118 'MethodDefinition:not([accessibility=/(private|protected)/]) > FunctionExpression',
119 'TSEnumDeclaration',
120 'TSInterfaceDeclaration',
121 'TSMethodSignature',
122 // 'TSPropertySignature',
123 'TSTypeAliasDeclaration'
124 ]
125 }
126 ],
127 'jsdoc/require-param-type': 'off',
128 'jsdoc/require-returns-type': 'off'
129 }
130 },
131 {
132 files: ['examples/typescript/**/*.ts'],
133 rules: {
134 'import/no-unresolved': 'off',
135 'jsdoc/require-jsdoc': 'off',
136 '@typescript-eslint/no-unsafe-argument': 'off',
137 '@typescript-eslint/no-unsafe-call': 'off',
138 '@typescript-eslint/no-unsafe-assignment': 'off'
139 }
140 },
141 {
142 files: ['**/*.js'],
143 extends: ['plugin:n/recommended', 'standard']
144 },
145 {
146 files: ['tests/**/*.js'],
147 rules: {
148 'jsdoc/require-jsdoc': 'off'
149 }
150 },
151 {
152 files: ['tests/pools/selection-strategies/**/*.js'],
153 rules: {
154 'n/no-missing-require': 'off'
155 }
156 },
157 {
158 files: ['benchmarks/**/*.js'],
159 rules: {
160 'jsdoc/require-jsdoc': 'off'
161 }
162 },
163 {
164 files: ['benchmarks/versus-external-pools/**/*.js'],
165 rules: {
166 'n/no-missing-require': 'off'
167 }
168 },
169 {
170 files: ['examples/**/*.js'],
171 rules: {
172 'n/no-missing-require': 'off',
173 'jsdoc/require-jsdoc': 'off'
174 }
175 }
176 ],
177 settings: {
178 jsdoc: {
179 mode: 'typescript'
180 }
181 }
182 })