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