-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.cjs
157 lines (155 loc) · 4.1 KB
/
.eslintrc.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* Copyright IBM Corp. 2023, 2023
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
const path = require('path')
const noUnusedVarsOptions = { args: 'all', argsIgnorePattern: '^_', varsIgnorePattern: '^_' }
module.exports = {
env: {
browser: true,
es2021: true
},
extends: [
'standard-with-typescript',
'plugin:@typescript-eslint/strict',
'plugin:eslint-comments/recommended',
'plugin:jsdoc/recommended-typescript',
'plugin:n/recommended'
],
overrides: [
// Special rules for config files
{
env: {
node: true
},
files: ['.*rc.{js,cjs}'],
parserOptions: {
sourceType: 'script'
},
rules: {
'@typescript-eslint/no-var-requires': 'off'
}
},
// Special rules for test files
{
files: ['**/*.test.ts'],
plugins: ['vitest'],
extends: ['plugin:vitest/all'],
rules: {
'vitest/no-hooks': 'off'
}
}
],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: 'tsconfig.eslint.json'
},
plugins: ['jsdoc', 'notice', 'simple-import-sort'],
root: true,
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': ['warn', noUnusedVarsOptions],
'@typescript-eslint/space-before-function-paren': [
'warn',
{
anonymous: 'always',
named: 'never',
asyncArrow: 'always'
}
],
'@typescript-eslint/strict-boolean-expressions': [
'warn',
{
allowString: true,
allowNumber: true,
allowNullableObject: true,
allowNullableBoolean: true,
allowNullableString: false,
allowNullableNumber: false,
allowNullableEnum: false,
allowAny: false
}
],
'eslint-comments/require-description': 'warn',
indent: [
'warn',
2,
{
ignoredNodes: [
'PropertyDefinition[decorators]',
'VariableDeclaration[declarations.length=0]'
],
SwitchCase: 1
}
],
'jsdoc/check-tag-names': 'off', // To support JSON schema file generation based on TypeScript
'jsdoc/require-description': [
'warn',
{
contexts: [
'ClassDeclaration',
'FunctionDeclaration',
'MethodDefinition',
'PropertyDefinition',
'TSAbstractMethodDefinition'
]
}
],
'jsdoc/require-description-complete-sentence': 'warn',
'jsdoc/require-hyphen-before-param-description': 'warn',
'jsdoc/require-jsdoc': [
'warn',
{
// publicOnly: true,
require: {
// ArrowFunctionExpression: true,
// ClassDeclaration: true,
// ClassExpression: false,
FunctionDeclaration: false
// FunctionExpression: false,
// MethodDefinition: true
},
contexts: [
'ClassDeclaration',
'ExportNamedDeclaration > FunctionDeclaration',
'MethodDefinition[accessibility="protected"][override=false]',
'MethodDefinition[accessibility="public"][override=false]',
'TSAbstractMethodDefinition[accessibility="public"]',
'TSAbstractMethodDefinition[accessibility="protected"]'
]
}
],
'jsdoc/require-param-description': 'warn',
'jsdoc/require-throws': 'warn',
'jsdoc/tag-lines': [
'warn',
'any',
{
startLines: 1,
endLines: 0,
tags: { param: { lines: 'never' }, returns: { lines: 'never' } }
}
],
'max-len': [
'warn',
{
code: 150, // Effectively disable this rule and allow Prettier to handle it
comments: 100
}
],
'n/no-unpublished-import': ['error', { allowModules: ['vitest'] }],
'n/shebang': 'off',
'notice/notice': [
'warn',
{
templateFile: path.join(__dirname, '.copyright.js')
}
],
'simple-import-sort/imports': 'warn',
'simple-import-sort/exports': 'warn'
}
}