Properly integrate standard JS tools for JS and TS code
[poolifier.git] / .eslintrc.js
CommitLineData
6a6e81d0
S
1// @ts-check
2const { defineConfig } = require('eslint-define-config')
3
4module.exports = defineConfig({
97c16550 5 root: true,
777b7824
S
6 env: {
7 es2021: true,
8 node: true,
9 mocha: true
10 },
6d0425b4
JB
11 parserOptions: {
12 ecmaVersion: 2021,
13 sourceType: 'module'
14 },
78cea37e 15 plugins: ['promise', 'jsdoc', 'spellcheck'],
777b7824 16 extends: [
777b7824 17 'eslint:recommended',
305aeaa7
JB
18 'plugin:import/recommended',
19 'plugin:jsdoc/recommended',
78cea37e 20 'plugin:promise/recommended'
777b7824
S
21 ],
22 rules: {
23 'no-void': 'off',
24
fa699c42
JB
25 'sort-imports': [
26 'warn',
27 {
28 ignoreMemberSort: true,
50aa7901 29 ignoreDeclarationSort: true
fa699c42 30 }
5c5a1fb7
S
31 ],
32
33 'spellcheck/spell-checker': [
34 'warn',
35 {
36 skipWords: [
fe2f6f84 37 'browserslist',
e4bc7a49 38 'builtins',
5c5a1fb7 39 'christopher',
7a6a0a96 40 'cjs',
74750c7f 41 'comparator',
23ff945a
JB
42 'cpu',
43 'cpus',
7a6a0a96 44 'ctx',
5c5a1fb7 45 'ecma',
3832ad95 46 'enum',
bdaf31cd 47 'fibonacci',
7a6a0a96 48 'fs',
a76fac14 49 'inheritDoc',
5c5a1fb7 50 'jsdoc',
7a6a0a96 51 'microjob',
fe2f6f84 52 'num',
23ff945a 53 'os',
7a6a0a96 54 'piscina',
a35560ba 55 'poolifier',
7a6a0a96 56 'poolify',
5c5a1fb7
S
57 'readonly',
58 'serializable',
a3809289 59 'sinon',
7a6a0a96
JB
60 'threadjs',
61 'threadwork',
7d82d90e 62 'tsconfig',
fe2f6f84 63 'typedoc',
7a6a0a96 64 'unlink',
5c5a1fb7 65 'unregister',
7a6a0a96 66 'utf8',
5c5a1fb7
S
67 'workerpool'
68 ],
69 skipIfMatch: ['^@.*', '^plugin:.*']
70 }
777b7824 71 ]
3c5eaeb9
JB
72 },
73 overrides: [
50eceb07 74 {
a17cc27a 75 files: ['**/*.ts'],
815d4289 76 parser: '@typescript-eslint/parser',
f3636726 77 parserOptions: {
f3636726
JB
78 project: './tsconfig.json'
79 },
815d4289 80 plugins: ['@typescript-eslint'],
a17cc27a 81 extends: [
f3636726 82 'plugin:@typescript-eslint/eslint-recommended',
a17cc27a 83 'plugin:@typescript-eslint/recommended',
f3636726 84 'plugin:@typescript-eslint/recommended-requiring-type-checking',
78cea37e 85 'standard-with-typescript',
a17cc27a
JB
86 'plugin:import/typescript'
87 ],
50eceb07 88 rules: {
a17cc27a
JB
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
a35560ba
S
97 'no-useless-constructor': 'off',
98
3832ad95
S
99 'jsdoc/match-description': [
100 'warn',
101 {
3832ad95
S
102 contexts: ['any'],
103 tags: {
104 param: true,
105 returns: true
106 }
107 }
108 ],
50eceb07 109 'jsdoc/no-types': 'error',
3832ad95
S
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 ],
50eceb07
S
127 'jsdoc/require-param-type': 'off',
128 'jsdoc/require-returns-type': 'off'
129 }
130 },
7a6a0a96
JB
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 },
3c5eaeb9 141 {
e99dbb69 142 files: ['**/*.js'],
78cea37e 143 extends: ['plugin:n/recommended', 'standard']
fa699c42
JB
144 },
145 {
305aeaa7
JB
146 files: ['tests/**/*.js'],
147 rules: {
148 'jsdoc/require-jsdoc': 'off'
149 }
150 },
4bf99d51
JB
151 {
152 files: ['tests/pools/selection-strategies/**/*.js'],
153 rules: {
2f8c5b5c 154 'n/no-missing-require': 'off'
4bf99d51
JB
155 }
156 },
305aeaa7
JB
157 {
158 files: ['benchmarks/**/*.js'],
fa699c42 159 rules: {
a17cc27a 160 'jsdoc/require-jsdoc': 'off'
fa699c42 161 }
583a27ce 162 },
d44e66fc
JB
163 {
164 files: ['benchmarks/versus-external-pools/**/*.js'],
165 rules: {
2f8c5b5c 166 'n/no-missing-require': 'off'
d44e66fc
JB
167 }
168 },
583a27ce
JB
169 {
170 files: ['examples/**/*.js'],
171 rules: {
2f8c5b5c 172 'n/no-missing-require': 'off',
305aeaa7
JB
173 'jsdoc/require-jsdoc': 'off'
174 }
3c5eaeb9 175 }
3832ad95
S
176 ],
177 settings: {
178 jsdoc: {
179 mode: 'typescript'
180 }
181 }
6a6e81d0 182})