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