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 parser: '@typescript-eslint/parser',
11 parserOptions: {
12 ecmaVersion: 2020,
13 sourceType: 'module',
14 warnOnUnsupportedTypeScriptVersion: false
15 },
16 plugins: [
17 '@typescript-eslint',
18 'promise',
19 'prettierx',
20 'jsdoc',
21 'spellcheck'
22 ],
23 extends: [
24 'standard',
25 'eslint:recommended',
26 'plugin:@typescript-eslint/recommended',
27 'plugin:import/errors',
28 'plugin:import/warnings',
29 'plugin:import/typescript',
30 'plugin:promise/recommended',
31 'plugin:prettierx/standardx'
32 ],
33 rules: {
34 'no-void': 'off',
35
36 // We have some intentionally empty functions
37 '@typescript-eslint/no-empty-function': 'off',
38
39 '@typescript-eslint/no-inferrable-types': [
40 'error',
41 { ignoreProperties: true }
42 ],
43
44 'sort-imports': [
45 'warn',
46 {
47 ignoreMemberSort: true,
48 ignoreDeclarationSort: true
49 }
50 ],
51
52 'spellcheck/spell-checker': [
53 'warn',
54 {
55 skipWords: [
56 'christopher',
57 'comparator',
58 'ecma',
59 'enum',
60 'inheritdoc',
61 'jsdoc',
62 'poolifier',
63 'readonly',
64 'serializable',
65 'unregister',
66 'workerpool'
67 ],
68 skipIfMatch: ['^@.*', '^plugin:.*']
69 }
70 ]
71 },
72 overrides: [
73 {
74 files: ['src/**/*.ts'],
75 extends: 'plugin:jsdoc/recommended',
76 rules: {
77 'no-useless-constructor': 'off',
78
79 'jsdoc/match-description': [
80 'warn',
81 {
82 mainDescription:
83 '/^[A-Z`].+?(\\.|:)(\\n\\n.*((\\n{1,2}- .+)|(_.+_)|`.+`|\\n\\n---))?$/us',
84 matchDescription: '^[A-Z`].+(\\.|`.+`)$',
85 contexts: ['any'],
86 tags: {
87 param: true,
88 returns: true
89 }
90 }
91 ],
92 'jsdoc/no-types': 'error',
93 'jsdoc/require-jsdoc': [
94 'warn',
95 {
96 contexts: [
97 'ClassDeclaration',
98 'ClassProperty:not([accessibility=/(private|protected)/])',
99 'ExportNamedDeclaration:has(VariableDeclaration)',
100 'FunctionExpression',
101 'MethodDefinition:not([accessibility=/(private|protected)/]) > FunctionExpression',
102 'TSEnumDeclaration',
103 'TSInterfaceDeclaration',
104 'TSMethodSignature',
105 // 'TSPropertySignature',
106 'TSTypeAliasDeclaration'
107 ]
108 }
109 ],
110 'jsdoc/require-param-type': 'off',
111 'jsdoc/require-returns-type': 'off'
112 }
113 },
114 {
115 files: ['**/*.js'],
116 extends: 'plugin:node/recommended',
117 rules: {
118 '@typescript-eslint/no-unused-vars': 'off',
119 '@typescript-eslint/no-var-requires': 'off'
120 }
121 },
122 {
123 files: ['examples/typescript/**/*.ts'],
124 rules: {
125 'import/no-unresolved': 'off'
126 }
127 },
128 {
129 files: ['examples/**/*.js'],
130 rules: {
131 'node/no-missing-require': 'off'
132 }
133 }
134 ],
135 settings: {
136 jsdoc: {
137 mode: 'typescript'
138 }
139 }
140 })