-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
144 lines (141 loc) · 3.92 KB
/
eslint.config.mjs
File metadata and controls
144 lines (141 loc) · 3.92 KB
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
import { defineConfig } from 'eslint/config';
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import prettier from "eslint-config-prettier";
import { jsdoc } from 'eslint-plugin-jsdoc';
import importPlugin from 'eslint-plugin-import';
/**
* The config for ESlint. A JavaScript, and TypeScript linter.
* I've set it to the strictest settings to ensure you catch
* as many real bugs, and follow as many good practices as
* humanly possible.
*/
export default defineConfig(
eslint.configs.all,
tseslint.configs.all,
{
files: [ 'browser/**/*.ts', 'src/**/*.ts', 'lib/**/*.ts'],
extends: [
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript
],
rules: {
"import/no-cycle": ["error", {
maxDepth: Infinity,
ignoreExternal: true
}],
"import/no-duplicates": "error",
"import/first": "error",
"import/newline-after-import": "error",
"import/no-useless-path-segments": ["error", { noUselessIndex: true }],
"import/no-default-export": "error",
"import/no-extraneous-dependencies": ["error", {
devDependencies: [
"**/*.test.ts",
"**/*.spec.ts",
"**/test/**",
"**/*.config.*"
]
}],
"import/no-webpack-loader-syntax": "error",
"import/no-self-import": "error",
}
},
jsdoc({
config: "flat/recommended",
files: [ 'browser/**/*.ts', 'src/**/*.ts', 'lib/**/*.ts'],
rules: {
"jsdoc/require-description": "error",
"jsdoc/require-param": "off",
"jsdoc/require-returns": "off",
"jsdoc/require-yields": "off",
"jsdoc/require-jsdoc": [
"error",
{
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true,
"ArrowFunctionExpression": true,
"FunctionExpression": true,
"ClassExpression": true,
},
publicOnly: true,
enableFixer: false,
"contexts": [
"ExportNamedDeclaration",
"ExportDefaultDeclaration"
],
},
],
},
}),
{
ignores: [ 'node_modules', 'dist', './*.config.*js' ],
languageOptions: {
parserOptions: {
projectService: true,
},
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.json',
},
},
},
rules: {
"no-restricted-syntax": [
"error",
{
selector:
"ArrowFunctionExpression[body.type='BlockStatement'][body.body.length>1]",
message: "Arrow functions must have a single-line body."
},
],
"no-continue": "off",
"one-var": "off",
'@typescript-eslint/naming-convention': [
'error',
{
"selector": "classProperty",
"modifiers": ["static", "readonly"],
"format": ["UPPER_CASE"],
},
],
"max-statements": ["error", 15],
"@typescript-eslint/no-magic-numbers": [ "error", { "ignore": [0, 1] }, ],
"lines-around-comment": [
"error",
{
"beforeBlockComment": false,
}
],
},
},
//
// Making tests files use less strict linting
//
{
// Since test functions are not for production, we can use unsafe things,
// if they fail that is even better.
files: ['test/**/*.ts'],
rules: {
'no-restricted-syntax': 'off',
'max-lines-per-function': 'off',
'max-statements': 'off',
"no-unsafe-type-assertion": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-function-type": "off",
"@typescript-eslint/no-unsafe-type-assertion": "off",
"@typescript-eslint/no-magic-numbers": "off",
"max-lines-per-function": "off",
"no-plusplus": "off"
},
},
//
// FORMATTING
//
prettier,
);