@eslint-react/jsx 0.8.9-beta.1 → 0.8.9-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/node_modules/@eslint-react/ast/dist/index.d.mts +1 -1
- package/node_modules/@eslint-react/ast/dist/index.d.ts +1 -1
- package/node_modules/@eslint-react/ast/package.json +2 -1
- package/node_modules/@eslint-react/shared/dist/index.cjs +424 -0
- package/node_modules/@eslint-react/shared/dist/index.d.mts +128 -0
- package/node_modules/@eslint-react/shared/dist/index.d.ts +128 -0
- package/node_modules/@eslint-react/shared/dist/index.js +424 -0
- package/node_modules/@eslint-react/shared/dist/index.mjs +390 -0
- package/node_modules/@eslint-react/shared/package.json +49 -0
- package/node_modules/@eslint-react/tools/package.json +1 -1
- package/node_modules/@eslint-react/types/dist/index.d.mts +1 -56
- package/node_modules/@eslint-react/types/dist/index.d.ts +1 -56
- package/node_modules/@eslint-react/types/package.json +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import dedent from 'dedent';
|
|
2
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
3
|
+
import { deepmergeCustom } from 'deepmerge-ts';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copied from https://github.com/epaew/eslint-plugin-filenames-simple/blob/master/src/utils/split-name.ts
|
|
7
|
+
* Split the file/variable name written in camelCase, kebab-case, PascalCase, and snake_case.
|
|
8
|
+
*/ const splitName = (name)=>{
|
|
9
|
+
return name.replaceAll("_", "-").replaceAll(/([\da-z])([A-Z])|([A-Z])([A-Z])(?=[a-z])/gu, "$1$3-$2$4").toLowerCase().split("-");
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/* eslint-disable security/detect-object-injection */ /* eslint-disable security/detect-non-literal-regexp */ // Copied from https://github.com/epaew/eslint-plugin-filenames-simple/blob/master/src/utils/preset-rules.ts
|
|
13
|
+
const presetRules = {
|
|
14
|
+
PascalCase: {
|
|
15
|
+
expression: /^[A-Z][\dA-Za-z]*$/u,
|
|
16
|
+
recommendationBuilder: (name)=>{
|
|
17
|
+
return splitName(name).map((word)=>{
|
|
18
|
+
const [first, ...rest] = word;
|
|
19
|
+
return `${first?.toUpperCase() ?? ""}${rest.join("")}`;
|
|
20
|
+
}).join("");
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
camelCase: {
|
|
24
|
+
expression: /^[a-z][\dA-Za-z]*$/u,
|
|
25
|
+
recommendationBuilder: (name)=>{
|
|
26
|
+
return splitName(name).map((word, i)=>{
|
|
27
|
+
if (i === 0) {
|
|
28
|
+
return word;
|
|
29
|
+
}
|
|
30
|
+
const [first, ...rest] = word;
|
|
31
|
+
return `${first?.toUpperCase() ?? ""}${rest.join("")}`;
|
|
32
|
+
}).join("");
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"kebab-case": {
|
|
36
|
+
expression: /^[a-z][\d\-a-z]*$/u,
|
|
37
|
+
recommendationBuilder: (name)=>{
|
|
38
|
+
return splitName(name).join("-");
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
snake_case: {
|
|
42
|
+
expression: /^[a-z][\d_a-z]*$/u,
|
|
43
|
+
recommendationBuilder: (name)=>{
|
|
44
|
+
return splitName(name).join("_");
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
// eslint-disable-next-line perfectionist/sort-objects
|
|
48
|
+
CONSTANT_CASE: {
|
|
49
|
+
expression: /^[A-Z][\d_A-Z]*$/u,
|
|
50
|
+
recommendationBuilder: (name)=>{
|
|
51
|
+
return splitName(name).join("_").toUpperCase();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const getRule = (expression, preset = presetRules)=>{
|
|
56
|
+
const rule = preset[expression];
|
|
57
|
+
return rule ?? {
|
|
58
|
+
expression: new RegExp(`^${expression}$`, "u")
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/* eslint-disable functional/no-this-expressions */ /* eslint-disable functional/no-expression-statements */ /* eslint-disable functional/no-classes */ /* eslint-disable functional/no-throw-statements */ /* eslint-disable functional/prefer-immutable-types */ /* eslint-disable security/detect-non-literal-regexp */ // Copied from https://github.com/epaew/eslint-plugin-filenames-simple/blob/master/src/utils/case-validator.ts
|
|
63
|
+
class CaseValidator {
|
|
64
|
+
#expression;
|
|
65
|
+
#ignorePatterns;
|
|
66
|
+
#recommendationBuilder;
|
|
67
|
+
constructor(expression, ignorePatterns, recommendationBuilder = ()=>{
|
|
68
|
+
// eslint-disable-next-line functional-core/purity
|
|
69
|
+
throw new Error("Not implemented");
|
|
70
|
+
}){
|
|
71
|
+
this.#expression = expression;
|
|
72
|
+
this.#ignorePatterns = ignorePatterns;
|
|
73
|
+
this.#recommendationBuilder = recommendationBuilder;
|
|
74
|
+
}
|
|
75
|
+
getRecommendedName(name) {
|
|
76
|
+
const recommendedName = this.#recommendationBuilder(name);
|
|
77
|
+
if (this.#expression.test(recommendedName)) {
|
|
78
|
+
return recommendedName;
|
|
79
|
+
}
|
|
80
|
+
// eslint-disable-next-line functional-core/purity
|
|
81
|
+
throw new Error("Failed to build recommendation.");
|
|
82
|
+
}
|
|
83
|
+
validate(name) {
|
|
84
|
+
if (this.#ignorePatterns.some((re)=>re.test(name))) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
return this.#expression.test(name);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const getCaseValidator = (ruleName, ignorePattern = [])=>{
|
|
91
|
+
const { expression, recommendationBuilder } = getRule(ruleName);
|
|
92
|
+
return new CaseValidator(expression, ignorePattern.map((pattern)=>new RegExp(`^${pattern}$`, "u")), recommendationBuilder);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// eslint-disable-next-line functional-core/purity
|
|
96
|
+
const createElementComponent = "const CreateElementComponent = () => React.createElement('div', null, null)";
|
|
97
|
+
const arrowFunctionComponent = "const FunctionComponent = () => <div></div>";
|
|
98
|
+
const functionComponent = dedent`
|
|
99
|
+
function FunctionComponent() {
|
|
100
|
+
return <div></div>
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
const memoComponent = dedent`
|
|
104
|
+
import { memo } from 'react'
|
|
105
|
+
|
|
106
|
+
const MemoComponent = memo(() => <div></div>)
|
|
107
|
+
`;
|
|
108
|
+
const forwardRefComponent = dedent`
|
|
109
|
+
import { forwardRef } from 'react'
|
|
110
|
+
|
|
111
|
+
const ForwardRefComponent = forwardRef(() => <div></div>)
|
|
112
|
+
`;
|
|
113
|
+
const memoForwardRefComponent = dedent`
|
|
114
|
+
import { memo, forwardRef } from 'react'
|
|
115
|
+
|
|
116
|
+
const MemoForwardRefComponent = memo(forwardRef(() => <div></div>))
|
|
117
|
+
`;
|
|
118
|
+
const allComponents = [
|
|
119
|
+
arrowFunctionComponent,
|
|
120
|
+
functionComponent,
|
|
121
|
+
createElementComponent,
|
|
122
|
+
memoComponent,
|
|
123
|
+
forwardRefComponent,
|
|
124
|
+
memoForwardRefComponent
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
// eslint-disable-next-line functional-core/purity
|
|
128
|
+
const fn = "const fn = () => null";
|
|
129
|
+
const fnWithReturn = dedent`
|
|
130
|
+
function fnWithReturn() {
|
|
131
|
+
return null
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
const renderFunction = "const renderFunction = (id: string, name: string) => <div key={id} id={id}>{name}</div>";
|
|
135
|
+
const renderFunctionWithReturn = dedent`
|
|
136
|
+
function renderFunctionWithReturn(id: string, name: string) {
|
|
137
|
+
return <div key={id} id={id}>{name}</div>
|
|
138
|
+
}
|
|
139
|
+
`;
|
|
140
|
+
const allFunctions = [
|
|
141
|
+
fn,
|
|
142
|
+
fnWithReturn,
|
|
143
|
+
renderFunction,
|
|
144
|
+
renderFunctionWithReturn
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
const allValid = [
|
|
148
|
+
...allComponents,
|
|
149
|
+
...allFunctions
|
|
150
|
+
];
|
|
151
|
+
|
|
152
|
+
const NPM_SCOPE = "@eslint-react";
|
|
153
|
+
const GITHUB_URL = "https://github.com/rel1cx/eslint-react/blob/main";
|
|
154
|
+
const WEBSITE_URL = "https://eslint-react.xyz";
|
|
155
|
+
const JSX_EXTENSIONS = [
|
|
156
|
+
".jsx",
|
|
157
|
+
".tsx"
|
|
158
|
+
];
|
|
159
|
+
// @see https://github.com/facebook/react/blob/6db7f4209e6f32ebde298a0b7451710dd6aa3e19/packages/react-dom-bindings/src/shared/sanitizeURL.js#L22
|
|
160
|
+
// dprint-ignore
|
|
161
|
+
// eslint-disable-next-line no-control-regex
|
|
162
|
+
const RE_JAVASCRIPT_PROTOCOL = /^[\u0000-\u001F ]*j[\t\n\r]*a[\t\n\r]*v[\t\n\r]*a[\t\n\r]*s[\t\n\r]*c[\t\n\r]*r[\t\n\r]*i[\t\n\r]*p[\t\n\r]*t[\t\n\r]*:/iu;
|
|
163
|
+
|
|
164
|
+
// eslint-disable-next-line functional-core/purity
|
|
165
|
+
const getDocsUrl = (pluginName)=>(ruleName)=>{
|
|
166
|
+
return `${WEBSITE_URL}/rules/${pluginName}-${ruleName}`;
|
|
167
|
+
};
|
|
168
|
+
const createRuleForPlugin = (pluginName)=>ESLintUtils.RuleCreator(getDocsUrl(pluginName));
|
|
169
|
+
|
|
170
|
+
const ReactHostHTMLComponent = 0;
|
|
171
|
+
const ReactHostSVGComponent = 1;
|
|
172
|
+
const ReactHostWebComponent = 2;
|
|
173
|
+
/* eslint-disable functional-core/purity */ // source: https://react.dev/reference/react-dom/components#all-html-components
|
|
174
|
+
const HostHTMLComponentTypes = [
|
|
175
|
+
"aside",
|
|
176
|
+
"audio",
|
|
177
|
+
"b",
|
|
178
|
+
"base",
|
|
179
|
+
"bdi",
|
|
180
|
+
"bdo",
|
|
181
|
+
"blockquote",
|
|
182
|
+
"body",
|
|
183
|
+
"br",
|
|
184
|
+
"button",
|
|
185
|
+
"canvas",
|
|
186
|
+
"caption",
|
|
187
|
+
"cite",
|
|
188
|
+
"code",
|
|
189
|
+
"col",
|
|
190
|
+
"colgroup",
|
|
191
|
+
"data",
|
|
192
|
+
"datalist",
|
|
193
|
+
"dd",
|
|
194
|
+
"del",
|
|
195
|
+
"details",
|
|
196
|
+
"dfn",
|
|
197
|
+
"dialog",
|
|
198
|
+
"div",
|
|
199
|
+
"dl",
|
|
200
|
+
"dt",
|
|
201
|
+
"em",
|
|
202
|
+
"embed",
|
|
203
|
+
"fieldset",
|
|
204
|
+
"figcaption",
|
|
205
|
+
"figure",
|
|
206
|
+
"footer",
|
|
207
|
+
"form",
|
|
208
|
+
"h1",
|
|
209
|
+
"head",
|
|
210
|
+
"header",
|
|
211
|
+
"hgroup",
|
|
212
|
+
"hr",
|
|
213
|
+
"html",
|
|
214
|
+
"i",
|
|
215
|
+
"iframe",
|
|
216
|
+
"img",
|
|
217
|
+
"input",
|
|
218
|
+
"ins",
|
|
219
|
+
"kbd",
|
|
220
|
+
"label",
|
|
221
|
+
"legend",
|
|
222
|
+
"li",
|
|
223
|
+
"link",
|
|
224
|
+
"main",
|
|
225
|
+
"map",
|
|
226
|
+
"mark",
|
|
227
|
+
"menu",
|
|
228
|
+
"meta",
|
|
229
|
+
"meter",
|
|
230
|
+
"nav",
|
|
231
|
+
"noscript",
|
|
232
|
+
"object",
|
|
233
|
+
"ol",
|
|
234
|
+
"optgroup",
|
|
235
|
+
"option",
|
|
236
|
+
"output",
|
|
237
|
+
"p",
|
|
238
|
+
"picture",
|
|
239
|
+
"pre",
|
|
240
|
+
"progress",
|
|
241
|
+
"q",
|
|
242
|
+
"rp",
|
|
243
|
+
"rt",
|
|
244
|
+
"ruby",
|
|
245
|
+
"s",
|
|
246
|
+
"samp",
|
|
247
|
+
"script",
|
|
248
|
+
"section",
|
|
249
|
+
"select",
|
|
250
|
+
"slot",
|
|
251
|
+
"small",
|
|
252
|
+
"source",
|
|
253
|
+
"span",
|
|
254
|
+
"strong",
|
|
255
|
+
"style",
|
|
256
|
+
"sub",
|
|
257
|
+
"summary",
|
|
258
|
+
"sup",
|
|
259
|
+
"table",
|
|
260
|
+
"tbody",
|
|
261
|
+
"td",
|
|
262
|
+
"template",
|
|
263
|
+
"textarea",
|
|
264
|
+
"tfoot",
|
|
265
|
+
"th",
|
|
266
|
+
"thead",
|
|
267
|
+
"time",
|
|
268
|
+
"title",
|
|
269
|
+
"tr",
|
|
270
|
+
"track",
|
|
271
|
+
"u",
|
|
272
|
+
"ul",
|
|
273
|
+
"var",
|
|
274
|
+
"video",
|
|
275
|
+
"wbr"
|
|
276
|
+
];
|
|
277
|
+
// source: https://react.dev/reference/react-dom/components#all-svg-components
|
|
278
|
+
const HostSVGComponentTypes = [
|
|
279
|
+
"a",
|
|
280
|
+
"animate",
|
|
281
|
+
"animateMotion",
|
|
282
|
+
"animateTransform",
|
|
283
|
+
"circle",
|
|
284
|
+
"clipPath",
|
|
285
|
+
"defs",
|
|
286
|
+
"desc",
|
|
287
|
+
"discard",
|
|
288
|
+
"ellipse",
|
|
289
|
+
"feBlend",
|
|
290
|
+
"feColorMatrix",
|
|
291
|
+
"feComponentTransfer",
|
|
292
|
+
"feComposite",
|
|
293
|
+
"feConvolveMatrix",
|
|
294
|
+
"feDiffuseLighting",
|
|
295
|
+
"feDisplacementMap",
|
|
296
|
+
"feDistantLight",
|
|
297
|
+
"feDropShadow",
|
|
298
|
+
"feFlood",
|
|
299
|
+
"feFuncA",
|
|
300
|
+
"feFuncB",
|
|
301
|
+
"feFuncG",
|
|
302
|
+
"feFuncR",
|
|
303
|
+
"feGaussianBlur",
|
|
304
|
+
"feImage",
|
|
305
|
+
"feMerge",
|
|
306
|
+
"feMergeNode",
|
|
307
|
+
"feMorphology",
|
|
308
|
+
"feOffset",
|
|
309
|
+
"fePointLight",
|
|
310
|
+
"feSpecularLighting",
|
|
311
|
+
"feSpotLight",
|
|
312
|
+
"feTile",
|
|
313
|
+
"feTurbulence",
|
|
314
|
+
"filter",
|
|
315
|
+
"foreignObject",
|
|
316
|
+
"g",
|
|
317
|
+
"hatch",
|
|
318
|
+
"hatchpath",
|
|
319
|
+
"image",
|
|
320
|
+
"line",
|
|
321
|
+
"linearGradient",
|
|
322
|
+
"marker",
|
|
323
|
+
"mask",
|
|
324
|
+
"metadata",
|
|
325
|
+
"mpath",
|
|
326
|
+
"path",
|
|
327
|
+
"pattern",
|
|
328
|
+
"polygon",
|
|
329
|
+
"polyline",
|
|
330
|
+
"radialGradient",
|
|
331
|
+
"rect",
|
|
332
|
+
"script",
|
|
333
|
+
"set",
|
|
334
|
+
"stop",
|
|
335
|
+
"style",
|
|
336
|
+
"svg",
|
|
337
|
+
"switch",
|
|
338
|
+
"symbol",
|
|
339
|
+
"text",
|
|
340
|
+
"textPath",
|
|
341
|
+
"title",
|
|
342
|
+
"tspan",
|
|
343
|
+
"use",
|
|
344
|
+
"view"
|
|
345
|
+
];
|
|
346
|
+
function isHostHTMLComponentName(name) {
|
|
347
|
+
return HostHTMLComponentTypes.includes(name);
|
|
348
|
+
}
|
|
349
|
+
function isHostSVGComponentName(name) {
|
|
350
|
+
return HostSVGComponentTypes.includes(name);
|
|
351
|
+
}
|
|
352
|
+
function isHostWebComponentName() {
|
|
353
|
+
// TODO: implement this following the spec in https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/* eslint-disable functional-core/purity */ // Copied from https://github.com/eslint-functional/eslint-plugin-functional/blob/e4bd4ad79502ff77ae26e703e1761ab80a46868b/src/utils/merge-configs.ts
|
|
357
|
+
const mergeConfigs = deepmergeCustom({
|
|
358
|
+
mergeArrays (values, utils, meta) {
|
|
359
|
+
if (meta !== undefined && meta.keyPath.length >= 2 && meta.keyPath[0] === "rules") {
|
|
360
|
+
return utils.defaultMergeFunctions.mergeOthers(values);
|
|
361
|
+
}
|
|
362
|
+
return utils.actions.defaultMerge;
|
|
363
|
+
},
|
|
364
|
+
metaDataUpdater: (previousMeta, metaMeta)=>{
|
|
365
|
+
if (previousMeta === undefined) {
|
|
366
|
+
if (metaMeta.key === undefined) {
|
|
367
|
+
return {
|
|
368
|
+
keyPath: []
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
return {
|
|
372
|
+
keyPath: [
|
|
373
|
+
metaMeta.key
|
|
374
|
+
]
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
if (metaMeta.key === undefined) {
|
|
378
|
+
return previousMeta;
|
|
379
|
+
}
|
|
380
|
+
return {
|
|
381
|
+
...metaMeta,
|
|
382
|
+
keyPath: [
|
|
383
|
+
...previousMeta.keyPath,
|
|
384
|
+
metaMeta.key
|
|
385
|
+
]
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
export { CaseValidator, GITHUB_URL, HostHTMLComponentTypes, HostSVGComponentTypes, JSX_EXTENSIONS, NPM_SCOPE, RE_JAVASCRIPT_PROTOCOL, ReactHostHTMLComponent, ReactHostSVGComponent, ReactHostWebComponent, WEBSITE_URL, allComponents, allFunctions, allValid, arrowFunctionComponent, createElementComponent, createRuleForPlugin, fn, fnWithReturn, forwardRefComponent, functionComponent, getCaseValidator, getRule, isHostHTMLComponentName, isHostSVGComponentName, isHostWebComponentName, memoComponent, memoForwardRefComponent, mergeConfigs, presetRules, renderFunction, renderFunctionWithReturn, splitName };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eslint-react/shared",
|
|
3
|
+
"version": "0.8.9-beta.2",
|
|
4
|
+
"description": "ESLint x React's shared constants and utilities.",
|
|
5
|
+
"homepage": "https://github.com/rel1cx/eslint-react",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/rel1cx/eslint-react/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/rel1cx/eslint-react.git",
|
|
12
|
+
"directory": "packages/shared"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Eva1ent<let@ik.me>",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./dist/index.d.mts",
|
|
20
|
+
"default": "./dist/index.mjs"
|
|
21
|
+
},
|
|
22
|
+
"require": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"main": "dist/index.js",
|
|
30
|
+
"module": "dist/index.mjs",
|
|
31
|
+
"types": "dist/index.d.ts",
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"./package.json"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "rollup -c rollup.config.ts --configPlugin swc3 && cp dist/index.d.ts dist/index.d.mts",
|
|
38
|
+
"lint:publish": "bun run --bun publint",
|
|
39
|
+
"lint:type": "bun run --bun tsc --noEmit",
|
|
40
|
+
"publish": "pnpm run build && pnpm run lint:publish"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@eslint-react/tools": "workspace:*",
|
|
44
|
+
"@typescript-eslint/utils": "6.10.0",
|
|
45
|
+
"dedent": "1.5.1",
|
|
46
|
+
"deepmerge-ts": "5.1.0",
|
|
47
|
+
"tslib": "2.6.2"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ReadonlyDeep } from 'type-fest';
|
|
2
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
3
2
|
|
|
4
3
|
type ReactSettings = ReadonlyDeep<{
|
|
5
4
|
[key: string]: unknown;
|
|
@@ -8,58 +7,4 @@ type ReactSettings = ReadonlyDeep<{
|
|
|
8
7
|
version: string;
|
|
9
8
|
}>;
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
* Rule application condition.
|
|
13
|
-
* @since 0.0.1
|
|
14
|
-
*/
|
|
15
|
-
type Cond = "always" | "never";
|
|
16
|
-
/**
|
|
17
|
-
* Rule severity.
|
|
18
|
-
* @since 0.0.1
|
|
19
|
-
*/
|
|
20
|
-
type Severity = "error" | "off" | "warn";
|
|
21
|
-
/**
|
|
22
|
-
* Rule declaration.
|
|
23
|
-
* @since 0.0.1
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
type RuleDeclaration = [Severity, Record<string, unknown>?] | Severity;
|
|
27
|
-
/**
|
|
28
|
-
* Rule config preset.
|
|
29
|
-
* @since 0.0.1
|
|
30
|
-
*/
|
|
31
|
-
type RulePreset = Record<string, RuleDeclaration>;
|
|
32
|
-
/**
|
|
33
|
-
* Rule creator function.
|
|
34
|
-
* @since 0.0.1
|
|
35
|
-
*/
|
|
36
|
-
type CreateRule = Parameters<ReturnType<typeof ESLintUtils.RuleCreator>>[0]["create"];
|
|
37
|
-
/**
|
|
38
|
-
* Rule context.
|
|
39
|
-
* @since 0.0.1
|
|
40
|
-
*/
|
|
41
|
-
type RuleContext = Parameters<CreateRule>[0];
|
|
42
|
-
/**
|
|
43
|
-
* Rule options.
|
|
44
|
-
* @since 0.0.1
|
|
45
|
-
*/
|
|
46
|
-
type RuleOptions = Parameters<CreateRule>[1];
|
|
47
|
-
|
|
48
|
-
type RuleCategory = "complexity" | "correctness" | "debug" | "deprecated" | "nursery" | "pedantic" | "perf" | "restriction" | "security" | "style" | "suspicious" | "verbose";
|
|
49
|
-
|
|
50
|
-
type Namespace = "debug" | "experimental" | "jsx" | "naming-convention" | "react" | "react-hooks";
|
|
51
|
-
type Ban = "ban";
|
|
52
|
-
type PositiveModifier = "ensure" | "prefer" | "strict";
|
|
53
|
-
type NegativeModifier = "no";
|
|
54
|
-
type NeutralModifier = "max" | "min";
|
|
55
|
-
type Modifier = NegativeModifier | NeutralModifier | PositiveModifier;
|
|
56
|
-
type NegativeDescriptive = "complicated" | "confusing" | "constructed" | "duplicate" | "empty" | "extra" | "falsely" | "implicit" | "invalid" | "leaked" | "legacy" | "missing" | "misused" | "mixing" | "nested" | "redundant" | "suppressing" | "suspicious" | "unknown" | "unreachable" | "unsafe" | "unsorted" | "unstable" | "unused" | "useless";
|
|
57
|
-
type PositiveDescriptive = "explicit" | "optimal" | "optimized" | "standard" | "strict";
|
|
58
|
-
type NeutralDescriptive = "access" | "calling" | "inside" | "outside";
|
|
59
|
-
type Descriptive = NegativeDescriptive | NeutralDescriptive | PositiveDescriptive;
|
|
60
|
-
type Term = "argument" | "array" | "array-index" | "arrow-function" | "attribute" | "callback" | "children" | "class" | "class-component" | "class-method" | "class-property" | "clone-element" | "comment" | "component" | "components" | "computed" | "computed-property" | "conditional-rendering" | "const" | "constant" | "constructor" | "context" | "context-consumer" | "context-provider" | "context-value" | "create-ref" | "custom-hooks" | "default-props" | "deps" | "destructuring" | "destructuring-assignment" | "direct-mutation" | "display-name" | "document" | "effect" | "element" | "error" | "event" | "event-handler" | "exhaustive-deps" | "expression" | "false" | "filename" | "forward-ref" | "fragment" | "function" | "function-component" | "function-name" | "global" | "handler" | "hook" | "html" | "id" | "index" | "input" | "key" | "list-rendering" | "literal" | "map" | "memo" | "memoized-function" | "method" | "name" | "namespace" | "node" | "parameter" | "prop" | "ref" | "render" | "return" | "spread" | "state" | "string" | "string-refs" | "style" | "textnodes" | "use-callback" | "use-context" | "use-effect" | "use-imperative-handle" | "use-layout-effect" | "use-memo" | "use-reducer" | "use-ref" | "use-state" | "value" | "variable";
|
|
61
|
-
type Additional = string;
|
|
62
|
-
type RuleName = `${Ban}-${Term}` | `${NeutralModifier}-${Term}` | `${NegativeModifier}-${NegativeDescriptive}-${Term}` | `${NegativeModifier}-${NeutralDescriptive}-${Term}` | `${PositiveModifier}-${NeutralDescriptive}-${Term}` | `${PositiveModifier}-${PositiveDescriptive}-${Term}`;
|
|
63
|
-
type RuleNameWithAdditional = `${RuleName}-${Additional}`;
|
|
64
|
-
|
|
65
|
-
export type { Additional, Ban, Cond, CreateRule, Descriptive, Modifier, Namespace, NegativeDescriptive, NegativeModifier, NeutralDescriptive, NeutralModifier, PositiveDescriptive, PositiveModifier, ReactSettings, RuleCategory, RuleContext, RuleDeclaration, RuleName, RuleNameWithAdditional, RuleOptions, RulePreset, Severity, Term };
|
|
10
|
+
export type { ReactSettings };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ReadonlyDeep } from 'type-fest';
|
|
2
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
3
2
|
|
|
4
3
|
type ReactSettings = ReadonlyDeep<{
|
|
5
4
|
[key: string]: unknown;
|
|
@@ -8,58 +7,4 @@ type ReactSettings = ReadonlyDeep<{
|
|
|
8
7
|
version: string;
|
|
9
8
|
}>;
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
* Rule application condition.
|
|
13
|
-
* @since 0.0.1
|
|
14
|
-
*/
|
|
15
|
-
type Cond = "always" | "never";
|
|
16
|
-
/**
|
|
17
|
-
* Rule severity.
|
|
18
|
-
* @since 0.0.1
|
|
19
|
-
*/
|
|
20
|
-
type Severity = "error" | "off" | "warn";
|
|
21
|
-
/**
|
|
22
|
-
* Rule declaration.
|
|
23
|
-
* @since 0.0.1
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
type RuleDeclaration = [Severity, Record<string, unknown>?] | Severity;
|
|
27
|
-
/**
|
|
28
|
-
* Rule config preset.
|
|
29
|
-
* @since 0.0.1
|
|
30
|
-
*/
|
|
31
|
-
type RulePreset = Record<string, RuleDeclaration>;
|
|
32
|
-
/**
|
|
33
|
-
* Rule creator function.
|
|
34
|
-
* @since 0.0.1
|
|
35
|
-
*/
|
|
36
|
-
type CreateRule = Parameters<ReturnType<typeof ESLintUtils.RuleCreator>>[0]["create"];
|
|
37
|
-
/**
|
|
38
|
-
* Rule context.
|
|
39
|
-
* @since 0.0.1
|
|
40
|
-
*/
|
|
41
|
-
type RuleContext = Parameters<CreateRule>[0];
|
|
42
|
-
/**
|
|
43
|
-
* Rule options.
|
|
44
|
-
* @since 0.0.1
|
|
45
|
-
*/
|
|
46
|
-
type RuleOptions = Parameters<CreateRule>[1];
|
|
47
|
-
|
|
48
|
-
type RuleCategory = "complexity" | "correctness" | "debug" | "deprecated" | "nursery" | "pedantic" | "perf" | "restriction" | "security" | "style" | "suspicious" | "verbose";
|
|
49
|
-
|
|
50
|
-
type Namespace = "debug" | "experimental" | "jsx" | "naming-convention" | "react" | "react-hooks";
|
|
51
|
-
type Ban = "ban";
|
|
52
|
-
type PositiveModifier = "ensure" | "prefer" | "strict";
|
|
53
|
-
type NegativeModifier = "no";
|
|
54
|
-
type NeutralModifier = "max" | "min";
|
|
55
|
-
type Modifier = NegativeModifier | NeutralModifier | PositiveModifier;
|
|
56
|
-
type NegativeDescriptive = "complicated" | "confusing" | "constructed" | "duplicate" | "empty" | "extra" | "falsely" | "implicit" | "invalid" | "leaked" | "legacy" | "missing" | "misused" | "mixing" | "nested" | "redundant" | "suppressing" | "suspicious" | "unknown" | "unreachable" | "unsafe" | "unsorted" | "unstable" | "unused" | "useless";
|
|
57
|
-
type PositiveDescriptive = "explicit" | "optimal" | "optimized" | "standard" | "strict";
|
|
58
|
-
type NeutralDescriptive = "access" | "calling" | "inside" | "outside";
|
|
59
|
-
type Descriptive = NegativeDescriptive | NeutralDescriptive | PositiveDescriptive;
|
|
60
|
-
type Term = "argument" | "array" | "array-index" | "arrow-function" | "attribute" | "callback" | "children" | "class" | "class-component" | "class-method" | "class-property" | "clone-element" | "comment" | "component" | "components" | "computed" | "computed-property" | "conditional-rendering" | "const" | "constant" | "constructor" | "context" | "context-consumer" | "context-provider" | "context-value" | "create-ref" | "custom-hooks" | "default-props" | "deps" | "destructuring" | "destructuring-assignment" | "direct-mutation" | "display-name" | "document" | "effect" | "element" | "error" | "event" | "event-handler" | "exhaustive-deps" | "expression" | "false" | "filename" | "forward-ref" | "fragment" | "function" | "function-component" | "function-name" | "global" | "handler" | "hook" | "html" | "id" | "index" | "input" | "key" | "list-rendering" | "literal" | "map" | "memo" | "memoized-function" | "method" | "name" | "namespace" | "node" | "parameter" | "prop" | "ref" | "render" | "return" | "spread" | "state" | "string" | "string-refs" | "style" | "textnodes" | "use-callback" | "use-context" | "use-effect" | "use-imperative-handle" | "use-layout-effect" | "use-memo" | "use-reducer" | "use-ref" | "use-state" | "value" | "variable";
|
|
61
|
-
type Additional = string;
|
|
62
|
-
type RuleName = `${Ban}-${Term}` | `${NeutralModifier}-${Term}` | `${NegativeModifier}-${NegativeDescriptive}-${Term}` | `${NegativeModifier}-${NeutralDescriptive}-${Term}` | `${PositiveModifier}-${NeutralDescriptive}-${Term}` | `${PositiveModifier}-${PositiveDescriptive}-${Term}`;
|
|
63
|
-
type RuleNameWithAdditional = `${RuleName}-${Additional}`;
|
|
64
|
-
|
|
65
|
-
export type { Additional, Ban, Cond, CreateRule, Descriptive, Modifier, Namespace, NegativeDescriptive, NegativeModifier, NeutralDescriptive, NeutralModifier, PositiveDescriptive, PositiveModifier, ReactSettings, RuleCategory, RuleContext, RuleDeclaration, RuleName, RuleNameWithAdditional, RuleOptions, RulePreset, Severity, Term };
|
|
10
|
+
export type { ReactSettings };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/jsx",
|
|
3
|
-
"version": "0.8.9-beta.
|
|
3
|
+
"version": "0.8.9-beta.2",
|
|
4
4
|
"description": "ESLint x React's TSESTree AST utility module for static analysis of JSX.",
|
|
5
5
|
"homepage": "https://github.com/rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -40,14 +40,16 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"micro-memoize": "4.1.2",
|
|
43
|
-
"@eslint-react/ast": "0.8.9-beta.
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/
|
|
43
|
+
"@eslint-react/ast": "0.8.9-beta.2",
|
|
44
|
+
"@eslint-react/tools": "0.8.9-beta.2",
|
|
45
|
+
"@eslint-react/types": "0.8.9-beta.2",
|
|
46
|
+
"@eslint-react/shared": "0.8.9-beta.2"
|
|
46
47
|
},
|
|
47
48
|
"bundleDependencies": [
|
|
48
49
|
"@eslint-react/ast",
|
|
49
50
|
"@eslint-react/tools",
|
|
50
51
|
"@eslint-react/types",
|
|
52
|
+
"@eslint-react/shared",
|
|
51
53
|
"micro-memoize"
|
|
52
54
|
],
|
|
53
55
|
"scripts": {
|