eslint-plugin-react-dom 2.0.0-next.5 → 2.0.0-next.50
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.ts +7 -2
- package/dist/index.js +27 -8
- package/package.json +15 -15
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { CamelCase } from 'string-ts';
|
|
1
2
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
3
|
import { RulePreset } from '@eslint-react/kit';
|
|
3
4
|
|
|
5
|
+
declare const RULE_NAME = "no-missing-button-type";
|
|
6
|
+
type MessageID = CamelCase<typeof RULE_NAME> | RuleSuggestMessageID;
|
|
7
|
+
type RuleSuggestMessageID = "addButtonType";
|
|
8
|
+
|
|
4
9
|
declare const _default: {
|
|
5
10
|
configs: {
|
|
6
11
|
recommended: {
|
|
@@ -16,7 +21,7 @@ declare const _default: {
|
|
|
16
21
|
readonly "no-find-dom-node": _typescript_eslint_utils_ts_eslint.RuleModule<"noFindDomNode", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
17
22
|
readonly "no-flush-sync": _typescript_eslint_utils_ts_eslint.RuleModule<"noFlushSync", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
18
23
|
readonly "no-hydrate": _typescript_eslint_utils_ts_eslint.RuleModule<"noHydrate", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
19
|
-
readonly "no-missing-button-type": _typescript_eslint_utils_ts_eslint.RuleModule<
|
|
24
|
+
readonly "no-missing-button-type": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
20
25
|
readonly "no-missing-iframe-sandbox": _typescript_eslint_utils_ts_eslint.RuleModule<"noMissingIframeSandbox", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
21
26
|
readonly "no-namespace": _typescript_eslint_utils_ts_eslint.RuleModule<"noNamespace", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
22
27
|
readonly "no-render": _typescript_eslint_utils_ts_eslint.RuleModule<"noRender", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
@@ -48,7 +53,7 @@ declare const _default: {
|
|
|
48
53
|
readonly "no-find-dom-node": _typescript_eslint_utils_ts_eslint.RuleModule<"noFindDomNode", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
49
54
|
readonly "no-flush-sync": _typescript_eslint_utils_ts_eslint.RuleModule<"noFlushSync", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
50
55
|
readonly "no-hydrate": _typescript_eslint_utils_ts_eslint.RuleModule<"noHydrate", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
51
|
-
readonly "no-missing-button-type": _typescript_eslint_utils_ts_eslint.RuleModule<
|
|
56
|
+
readonly "no-missing-button-type": _typescript_eslint_utils_ts_eslint.RuleModule<MessageID, [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
52
57
|
readonly "no-missing-iframe-sandbox": _typescript_eslint_utils_ts_eslint.RuleModule<"noMissingIframeSandbox", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
53
58
|
readonly "no-namespace": _typescript_eslint_utils_ts_eslint.RuleModule<"noNamespace", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
54
59
|
readonly "no-render": _typescript_eslint_utils_ts_eslint.RuleModule<"noRender", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import * as AST from '@eslint-react/ast';
|
|
|
5
5
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
6
6
|
import { compare } from 'compare-versions';
|
|
7
7
|
import { RegExp, Reporter } from '@eslint-react/kit';
|
|
8
|
-
import {
|
|
8
|
+
import { unit } from '@eslint-react/eff';
|
|
9
9
|
|
|
10
10
|
var __defProp = Object.defineProperty;
|
|
11
11
|
var __export = (target, all) => {
|
|
@@ -44,7 +44,7 @@ var settings = {
|
|
|
44
44
|
|
|
45
45
|
// package.json
|
|
46
46
|
var name2 = "eslint-plugin-react-dom";
|
|
47
|
-
var version = "2.0.0-next.
|
|
47
|
+
var version = "2.0.0-next.50";
|
|
48
48
|
function createJsxElementResolver(context) {
|
|
49
49
|
const { components, polymorphicPropName } = getSettingsFromContext(context);
|
|
50
50
|
return {
|
|
@@ -323,7 +323,10 @@ function getFix(context, node) {
|
|
|
323
323
|
};
|
|
324
324
|
}
|
|
325
325
|
var RULE_NAME6 = "no-missing-button-type";
|
|
326
|
-
var RULE_FEATURES6 = [
|
|
326
|
+
var RULE_FEATURES6 = [
|
|
327
|
+
"FIX"
|
|
328
|
+
];
|
|
329
|
+
var BUTTON_TYPES = ["button", "submit", "reset"];
|
|
327
330
|
var no_missing_button_type_default = createRule({
|
|
328
331
|
meta: {
|
|
329
332
|
type: "problem",
|
|
@@ -331,7 +334,9 @@ var no_missing_button_type_default = createRule({
|
|
|
331
334
|
description: "Enforces explicit `type` attribute for `button` elements.",
|
|
332
335
|
[Symbol.for("rule_features")]: RULE_FEATURES6
|
|
333
336
|
},
|
|
337
|
+
hasSuggestions: true,
|
|
334
338
|
messages: {
|
|
339
|
+
addButtonType: "Add 'type' attribute with value '{{type}}'.",
|
|
335
340
|
noMissingButtonType: "Add missing 'type' attribute on 'button' component."
|
|
336
341
|
},
|
|
337
342
|
schema: []
|
|
@@ -360,10 +365,13 @@ function create6(context) {
|
|
|
360
365
|
attributeNode,
|
|
361
366
|
propNameOnJsx
|
|
362
367
|
);
|
|
363
|
-
if (attributeValue.kind
|
|
368
|
+
if (attributeValue.kind !== "some" || typeof attributeValue.value !== "string") {
|
|
364
369
|
context.report({
|
|
365
370
|
messageId: "noMissingButtonType",
|
|
366
|
-
node: attributeNode
|
|
371
|
+
node: attributeNode,
|
|
372
|
+
suggest: getSuggest((type) => (fixer) => {
|
|
373
|
+
return fixer.replaceText(attributeNode, `${propNameOnJsx}="${type}"`);
|
|
374
|
+
})
|
|
367
375
|
});
|
|
368
376
|
}
|
|
369
377
|
return;
|
|
@@ -371,12 +379,22 @@ function create6(context) {
|
|
|
371
379
|
if (typeof customComponentProp?.defaultValue !== "string") {
|
|
372
380
|
context.report({
|
|
373
381
|
messageId: "noMissingButtonType",
|
|
374
|
-
node
|
|
382
|
+
node,
|
|
383
|
+
suggest: getSuggest((type) => (fixer) => {
|
|
384
|
+
return fixer.insertTextAfter(node.openingElement.name, ` type="${type}"`);
|
|
385
|
+
})
|
|
375
386
|
});
|
|
376
387
|
}
|
|
377
388
|
}
|
|
378
389
|
};
|
|
379
390
|
}
|
|
391
|
+
function getSuggest(getFix4) {
|
|
392
|
+
return BUTTON_TYPES.map((type) => ({
|
|
393
|
+
messageId: "addButtonType",
|
|
394
|
+
data: { type },
|
|
395
|
+
fix: getFix4(type)
|
|
396
|
+
}));
|
|
397
|
+
}
|
|
380
398
|
var RULE_NAME7 = "no-missing-iframe-sandbox";
|
|
381
399
|
var RULE_FEATURES7 = [];
|
|
382
400
|
var validTypes = [
|
|
@@ -1834,7 +1852,7 @@ function create14(context) {
|
|
|
1834
1852
|
if (attributeValue.kind === "some" && typeof attributeValue.value === "string") {
|
|
1835
1853
|
return attributeValue.value;
|
|
1836
1854
|
}
|
|
1837
|
-
return
|
|
1855
|
+
return unit;
|
|
1838
1856
|
};
|
|
1839
1857
|
if (getAttributeStringValue("target") !== "_blank") {
|
|
1840
1858
|
return;
|
|
@@ -1965,9 +1983,10 @@ var no_void_elements_with_children_default = createRule({
|
|
|
1965
1983
|
defaultOptions: []
|
|
1966
1984
|
});
|
|
1967
1985
|
function create16(context) {
|
|
1986
|
+
const resolver = createJsxElementResolver(context);
|
|
1968
1987
|
return {
|
|
1969
1988
|
JSXElement(node) {
|
|
1970
|
-
const elementName =
|
|
1989
|
+
const { domElementType: elementName } = resolver.resolve(node);
|
|
1971
1990
|
if (elementName.length === 0 || !voidElements.has(elementName)) {
|
|
1972
1991
|
return;
|
|
1973
1992
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-dom",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.50",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React DOM related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -35,27 +35,27 @@
|
|
|
35
35
|
"./package.json"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
39
|
-
"@typescript-eslint/types": "^8.
|
|
40
|
-
"@typescript-eslint/utils": "^8.
|
|
38
|
+
"@typescript-eslint/scope-manager": "^8.34.1",
|
|
39
|
+
"@typescript-eslint/types": "^8.34.1",
|
|
40
|
+
"@typescript-eslint/utils": "^8.34.1",
|
|
41
41
|
"compare-versions": "^6.1.1",
|
|
42
42
|
"string-ts": "^2.2.1",
|
|
43
|
-
"ts-pattern": "^5.7.
|
|
44
|
-
"@eslint-react/ast": "2.0.0-next.
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/core": "2.0.0-next.
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
43
|
+
"ts-pattern": "^5.7.1",
|
|
44
|
+
"@eslint-react/ast": "2.0.0-next.50",
|
|
45
|
+
"@eslint-react/eff": "2.0.0-next.50",
|
|
46
|
+
"@eslint-react/kit": "2.0.0-next.50",
|
|
47
|
+
"@eslint-react/core": "2.0.0-next.50",
|
|
48
|
+
"@eslint-react/shared": "2.0.0-next.50",
|
|
49
|
+
"@eslint-react/var": "2.0.0-next.50"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@types/react": "^19.1.
|
|
53
|
-
"@types/react-dom": "^19.1.
|
|
54
|
-
"tsup": "^8.
|
|
52
|
+
"@types/react": "^19.1.8",
|
|
53
|
+
"@types/react-dom": "^19.1.6",
|
|
54
|
+
"tsup": "^8.5.0",
|
|
55
55
|
"@local/configs": "0.0.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"eslint": "^9.
|
|
58
|
+
"eslint": "^9.29.0",
|
|
59
59
|
"typescript": "^4.9.5 || ^5.4.5"
|
|
60
60
|
},
|
|
61
61
|
"peerDependenciesMeta": {
|