Repository navigation
Expand file tree
/
Copy pathxo.config.js
More file actions
195 lines (192 loc) · 5.7 KB
/
Copy pathxo.config.js
File metadata and controls
195 lines (192 loc) · 5.7 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// @ts-check
import markdown from '@eslint/markdown';
import tseslint from 'typescript-eslint';
import {importPathRule} from './lint-rules/import-path.js';
import {sourceFilesExtensionRule} from './lint-rules/source-files-extension.js';
import {requireExportedTypesRule} from './lint-rules/require-exported-types.js';
import {requireExportRule} from './lint-rules/require-export.js';
import {validateJSDocCodeblocksRule} from './lint-rules/validate-jsdoc-codeblocks.js';
import {readmeJSDocSyncRule} from './lint-rules/readme-jsdoc-sync.js';
import {jsdocLinkImportsRule} from './lint-rules/jsdoc-link-imports.js';
import {jsdocCodeblocksProcessor} from './lint-processors/jsdoc-codeblocks.js';
/**
@type {Array<import('eslint').Linter.Config>}
*/
const xoConfig = [
{
files: ['**/*.{js,ts}'],
rules: {
'@typescript-eslint/no-extraneous-class': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-redeclare': 'off',
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-restricted-types': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-deprecated': 'off',
'@typescript-eslint/no-wrapper-object-types': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/unified-signatures': 'off', // Temp
'@typescript-eslint/no-unnecessary-type-arguments': 'off',
'@typescript-eslint/no-unsafe-type-assertion': 'off',
'@stylistic/quote-props': 'off',
'@stylistic/function-paren-newline': 'off',
'@stylistic/object-curly-newline': 'off',
'@stylistic/curly-newline': 'off',
'@stylistic/operator-linebreak': ['error', 'before', {overrides: {'=': 'after'}}],
'n/file-extension-in-import': 'off',
'object-curly-newline': [
'error',
{
multiline: true,
consistent: true,
},
],
'import-x/consistent-type-specifier-style': [
'error',
'prefer-top-level',
],
},
},
{
files: ['source/**/*.d.ts', 'index.d.ts'],
rules: {
'no-restricted-imports': [
'error',
{
paths: ['nz'],
},
],
'unicorn/require-module-specifiers': 'off',
// Categories like `@category Change case` are a fixed set and naturally repeat the type name.
'jsdoc/informative-docs': ['error', {excludedTags: ['default', 'category']}],
},
},
{
files: ['test-d/**/*.ts'],
rules: {
'unicorn/no-immediate-mutation': 'off',
'require-unicode-regexp': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
// Test names describe the type under test (for example, `declare const string: IsArray<string>`), not a boolean.
'unicorn/consistent-boolean-name': 'off',
},
},
{
files: ['lint-rules/*.test.js'],
rules: {
// Test fixtures are composed from nested template helpers like `exportTypeAndOption(jsdoc(fence(code)))`.
'unicorn/max-nested-calls': 'off',
},
},
{
files: ['**/*'],
plugins: {
'type-fest': {
rules: {
'import-path': importPathRule,
'source-files-extension': sourceFilesExtensionRule,
'require-exported-types': requireExportedTypesRule,
'require-export': requireExportRule,
'validate-jsdoc-codeblocks': validateJSDocCodeblocksRule,
'readme-jsdoc-sync': readmeJSDocSyncRule,
'jsdoc-link-imports': jsdocLinkImportsRule,
},
processors: {
'jsdoc-codeblocks': jsdocCodeblocksProcessor,
},
},
},
},
{
files: ['source/**/*.d.ts', 'test-d/**/*.ts', 'index.d.ts'],
rules: {
'type-fest/import-path': 'error',
},
},
{
files: ['source/**/*'],
rules: {
'type-fest/source-files-extension': 'error',
},
},
{
files: ['source/**/*.d.ts'],
rules: {
'type-fest/jsdoc-link-imports': 'error',
},
},
{
files: ['source/**/*.d.ts'],
ignores: ['source/internal/**/*.d.ts'],
rules: {
'type-fest/require-exported-types': 'error',
'type-fest/require-export': 'error',
'type-fest/validate-jsdoc-codeblocks': 'error',
},
},
// Register processor for all source `.d.ts` files
{
files: ['source/**/*.d.ts'],
processor: 'type-fest/jsdoc-codeblocks',
},
{
// Virtual files created by the `jsdoc-codeblocks` processor
files: ['source/**/*.d.ts/*.ts'],
...tseslint.configs.disableTypeChecked,
},
{
// Virtual files created by the `jsdoc-codeblocks` processor
files: ['source/**/*.d.ts/*.ts'],
rules: {
'type-fest/source-files-extension': 'off',
'@stylistic/eol-last': 'off',
'capitalized-comments': 'off',
'unicorn/prefer-structured-clone': 'off',
'unicorn/no-immediate-mutation': 'off',
// Examples show usage as top-level statements.
'unicorn/no-top-level-side-effects': 'off',
// Examples mirror real-world APIs, like `available: boolean`.
'unicorn/consistent-boolean-name': 'off',
},
},
{
// Virtual files created by the `jsdoc-codeblocks` processor
files: ['source/is-float.d.ts/*.ts', 'source/is-integer.d.ts/*.ts', 'source/numeric.d.ts/*.ts'],
rules: {
'unicorn/no-zero-fractions': 'off',
},
},
{
// Virtual files created by the `jsdoc-codeblocks` processor
files: ['source/as-extendable.d.ts/*.ts', 'source/find-global-type.d.ts/*.ts', 'source/jsonify.d.ts/*.ts', 'source/simplify.d.ts/*.ts'],
rules: {
'@typescript-eslint/consistent-type-definitions': 'off',
},
},
{
files: ['lint-rules/testing-utilities.js'],
rules: {
'no-irregular-whitespace': [
'error',
{
'skipComments': true,
},
],
},
},
{
files: ['readme.md'],
language: 'markdown/commonmark',
plugins: {
markdown,
},
rules: {
'type-fest/readme-jsdoc-sync': 'error',
},
},
];
export default xoConfig;