eslint-plugin-react-x 1.22.2-next.8 → 1.22.2-next.9
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.js +38 -47
- package/dist/index.mjs +39 -48
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
|
42
42
|
|
|
43
43
|
// package.json
|
|
44
44
|
var name = "eslint-plugin-react-x";
|
|
45
|
-
var version = "1.22.2-next.
|
|
45
|
+
var version = "1.22.2-next.9";
|
|
46
46
|
var createRule = shared.createRuleForPlugin("x");
|
|
47
47
|
|
|
48
48
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -1728,7 +1728,7 @@ var no_nested_components_default = createRule({
|
|
|
1728
1728
|
}
|
|
1729
1729
|
}
|
|
1730
1730
|
for (const { name: name2, node: component } of classComponents) {
|
|
1731
|
-
if (eff.O.isNone(AST11__namespace.traverseUp(component, (
|
|
1731
|
+
if (eff.O.isNone(AST11__namespace.traverseUp(component, eff.or(isClassComponent11, isFunctionComponent)))) {
|
|
1732
1732
|
continue;
|
|
1733
1733
|
}
|
|
1734
1734
|
context.report({
|
|
@@ -1858,22 +1858,19 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
1858
1858
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
1859
1859
|
function getReportDescriptor(node) {
|
|
1860
1860
|
if (!core.isThisSetState(node)) return eff.O.none();
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
AST11__namespace.
|
|
1861
|
+
return eff.F.pipe(
|
|
1862
|
+
eff.O.Do,
|
|
1863
|
+
eff.O.bind("clazz", () => AST11__namespace.traverseUpGuard(node, core.isClassComponent)),
|
|
1864
|
+
eff.O.bind("method", ({ clazz }) => AST11__namespace.traverseUpStop(node, clazz, isComponentDidMount)),
|
|
1865
|
+
eff.O.bind("upperScope", () => eff.O.fromNullable(context.sourceCode.getScope(node).upper)),
|
|
1866
|
+
eff.O.filter(
|
|
1867
|
+
({ clazz, method, upperScope }) => method.parent === clazz.body && upperScope === context.sourceCode.getScope(method)
|
|
1868
|
+
),
|
|
1869
|
+
eff.O.map(() => ({
|
|
1870
|
+
messageId: "noSetStateInComponentDidMount",
|
|
1871
|
+
node
|
|
1872
|
+
}))
|
|
1864
1873
|
);
|
|
1865
|
-
if (eff.O.isNone(maybeParentClass)) return eff.O.none();
|
|
1866
|
-
const parentClass = maybeParentClass.value;
|
|
1867
|
-
if (!core.isClassComponent(parentClass)) return eff.O.none();
|
|
1868
|
-
const maybeParentMethod = AST11__namespace.traverseUp(node, isComponentDidMount);
|
|
1869
|
-
if (eff.O.isNone(maybeParentMethod)) return eff.O.none();
|
|
1870
|
-
const parentMethod = maybeParentMethod.value;
|
|
1871
|
-
if (parentMethod.parent !== parentClass.body) return eff.O.none();
|
|
1872
|
-
if (context.sourceCode.getScope(node).upper !== context.sourceCode.getScope(parentMethod)) return eff.O.none();
|
|
1873
|
-
return eff.O.some({
|
|
1874
|
-
messageId: "noSetStateInComponentDidMount",
|
|
1875
|
-
node
|
|
1876
|
-
});
|
|
1877
1874
|
}
|
|
1878
1875
|
return {
|
|
1879
1876
|
CallExpression: eff.F.flow(getReportDescriptor, eff.O.map(context.report))
|
|
@@ -1905,22 +1902,19 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
1905
1902
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
1906
1903
|
function getReportDescriptor(node) {
|
|
1907
1904
|
if (!core.isThisSetState(node)) return eff.O.none();
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
AST11__namespace.
|
|
1905
|
+
return eff.F.pipe(
|
|
1906
|
+
eff.O.Do,
|
|
1907
|
+
eff.O.bind("clazz", () => AST11__namespace.traverseUpGuard(node, core.isClassComponent)),
|
|
1908
|
+
eff.O.bind("method", ({ clazz }) => AST11__namespace.traverseUpStop(node, clazz, isComponentDidUpdate)),
|
|
1909
|
+
eff.O.bind("upperScope", () => eff.O.fromNullable(context.sourceCode.getScope(node).upper)),
|
|
1910
|
+
eff.O.filter(
|
|
1911
|
+
({ clazz, method, upperScope }) => method.parent === clazz.body && upperScope === context.sourceCode.getScope(method)
|
|
1912
|
+
),
|
|
1913
|
+
eff.O.map(() => ({
|
|
1914
|
+
messageId: "noSetStateInComponentDidUpdate",
|
|
1915
|
+
node
|
|
1916
|
+
}))
|
|
1911
1917
|
);
|
|
1912
|
-
if (eff.O.isNone(maybeParentClass)) return eff.O.none();
|
|
1913
|
-
const parentClass = maybeParentClass.value;
|
|
1914
|
-
if (!core.isClassComponent(parentClass)) return eff.O.none();
|
|
1915
|
-
const maybeParentMethod = AST11__namespace.traverseUp(node, isComponentDidUpdate);
|
|
1916
|
-
if (eff.O.isNone(maybeParentMethod)) return eff.O.none();
|
|
1917
|
-
const parentMethod = maybeParentMethod.value;
|
|
1918
|
-
if (parentMethod.parent !== parentClass.body) return eff.O.none();
|
|
1919
|
-
if (context.sourceCode.getScope(node).upper !== context.sourceCode.getScope(parentMethod)) return eff.O.none();
|
|
1920
|
-
return eff.O.some({
|
|
1921
|
-
messageId: "noSetStateInComponentDidUpdate",
|
|
1922
|
-
node
|
|
1923
|
-
});
|
|
1924
1918
|
}
|
|
1925
1919
|
return {
|
|
1926
1920
|
CallExpression: eff.F.flow(getReportDescriptor, eff.O.map(context.report))
|
|
@@ -1952,22 +1946,19 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
1952
1946
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
1953
1947
|
function getReportDescriptor(node) {
|
|
1954
1948
|
if (!core.isThisSetState(node)) return eff.O.none();
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
AST11__namespace.
|
|
1949
|
+
return eff.F.pipe(
|
|
1950
|
+
eff.O.Do,
|
|
1951
|
+
eff.O.bind("clazz", () => AST11__namespace.traverseUpGuard(node, core.isClassComponent)),
|
|
1952
|
+
eff.O.bind("method", ({ clazz }) => AST11__namespace.traverseUpStop(node, clazz, isComponentWillUpdate3)),
|
|
1953
|
+
eff.O.bind("upperScope", () => eff.O.fromNullable(context.sourceCode.getScope(node).upper)),
|
|
1954
|
+
eff.O.filter(
|
|
1955
|
+
({ clazz, method, upperScope }) => method.parent === clazz.body && upperScope === context.sourceCode.getScope(method)
|
|
1956
|
+
),
|
|
1957
|
+
eff.O.map(() => ({
|
|
1958
|
+
messageId: "noSetStateInComponentWillUpdate",
|
|
1959
|
+
node
|
|
1960
|
+
}))
|
|
1958
1961
|
);
|
|
1959
|
-
if (eff.O.isNone(maybeParentClass)) return eff.O.none();
|
|
1960
|
-
const parentClass = maybeParentClass.value;
|
|
1961
|
-
if (!core.isClassComponent(parentClass)) return eff.O.none();
|
|
1962
|
-
const maybeParentMethod = AST11__namespace.traverseUp(node, isComponentWillUpdate3);
|
|
1963
|
-
if (eff.O.isNone(maybeParentMethod)) return eff.O.none();
|
|
1964
|
-
const parentMethod = maybeParentMethod.value;
|
|
1965
|
-
if (parentMethod.parent !== parentClass.body) return eff.O.none();
|
|
1966
|
-
if (context.sourceCode.getScope(node).upper !== context.sourceCode.getScope(parentMethod)) return eff.O.none();
|
|
1967
|
-
return eff.O.some({
|
|
1968
|
-
messageId: "noSetStateInComponentWillUpdate",
|
|
1969
|
-
node
|
|
1970
|
-
});
|
|
1971
1962
|
}
|
|
1972
1963
|
return {
|
|
1973
1964
|
CallExpression: eff.F.flow(getReportDescriptor, eff.O.map(context.report))
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F, O, isString, isNullable } from '@eslint-react/eff';
|
|
1
|
+
import { F, O, isString, or, isNullable } from '@eslint-react/eff';
|
|
2
2
|
import * as JSX7 from '@eslint-react/jsx';
|
|
3
3
|
import { createRuleForPlugin, normalizeSettings, decodeSettings, unsafeReadSettings } from '@eslint-react/shared';
|
|
4
4
|
import * as AST11 from '@eslint-react/ast';
|
|
@@ -15,7 +15,7 @@ import { getTypeImmutability, isUnknown, isImmutable, isReadonlyShallow, isReado
|
|
|
15
15
|
|
|
16
16
|
// package.json
|
|
17
17
|
var name = "eslint-plugin-react-x";
|
|
18
|
-
var version = "1.22.2-next.
|
|
18
|
+
var version = "1.22.2-next.9";
|
|
19
19
|
var createRule = createRuleForPlugin("x");
|
|
20
20
|
|
|
21
21
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -1701,7 +1701,7 @@ var no_nested_components_default = createRule({
|
|
|
1701
1701
|
}
|
|
1702
1702
|
}
|
|
1703
1703
|
for (const { name: name2, node: component } of classComponents) {
|
|
1704
|
-
if (O.isNone(AST11.traverseUp(component, (
|
|
1704
|
+
if (O.isNone(AST11.traverseUp(component, or(isClassComponent11, isFunctionComponent)))) {
|
|
1705
1705
|
continue;
|
|
1706
1706
|
}
|
|
1707
1707
|
context.report({
|
|
@@ -1831,22 +1831,19 @@ var no_set_state_in_component_did_mount_default = createRule({
|
|
|
1831
1831
|
if (!context.sourceCode.text.includes("componentDidMount")) return {};
|
|
1832
1832
|
function getReportDescriptor(node) {
|
|
1833
1833
|
if (!isThisSetState(node)) return O.none();
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
AST11.
|
|
1834
|
+
return F.pipe(
|
|
1835
|
+
O.Do,
|
|
1836
|
+
O.bind("clazz", () => AST11.traverseUpGuard(node, isClassComponent)),
|
|
1837
|
+
O.bind("method", ({ clazz }) => AST11.traverseUpStop(node, clazz, isComponentDidMount)),
|
|
1838
|
+
O.bind("upperScope", () => O.fromNullable(context.sourceCode.getScope(node).upper)),
|
|
1839
|
+
O.filter(
|
|
1840
|
+
({ clazz, method, upperScope }) => method.parent === clazz.body && upperScope === context.sourceCode.getScope(method)
|
|
1841
|
+
),
|
|
1842
|
+
O.map(() => ({
|
|
1843
|
+
messageId: "noSetStateInComponentDidMount",
|
|
1844
|
+
node
|
|
1845
|
+
}))
|
|
1837
1846
|
);
|
|
1838
|
-
if (O.isNone(maybeParentClass)) return O.none();
|
|
1839
|
-
const parentClass = maybeParentClass.value;
|
|
1840
|
-
if (!isClassComponent(parentClass)) return O.none();
|
|
1841
|
-
const maybeParentMethod = AST11.traverseUp(node, isComponentDidMount);
|
|
1842
|
-
if (O.isNone(maybeParentMethod)) return O.none();
|
|
1843
|
-
const parentMethod = maybeParentMethod.value;
|
|
1844
|
-
if (parentMethod.parent !== parentClass.body) return O.none();
|
|
1845
|
-
if (context.sourceCode.getScope(node).upper !== context.sourceCode.getScope(parentMethod)) return O.none();
|
|
1846
|
-
return O.some({
|
|
1847
|
-
messageId: "noSetStateInComponentDidMount",
|
|
1848
|
-
node
|
|
1849
|
-
});
|
|
1850
1847
|
}
|
|
1851
1848
|
return {
|
|
1852
1849
|
CallExpression: F.flow(getReportDescriptor, O.map(context.report))
|
|
@@ -1878,22 +1875,19 @@ var no_set_state_in_component_did_update_default = createRule({
|
|
|
1878
1875
|
if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
|
|
1879
1876
|
function getReportDescriptor(node) {
|
|
1880
1877
|
if (!isThisSetState(node)) return O.none();
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
AST11.
|
|
1878
|
+
return F.pipe(
|
|
1879
|
+
O.Do,
|
|
1880
|
+
O.bind("clazz", () => AST11.traverseUpGuard(node, isClassComponent)),
|
|
1881
|
+
O.bind("method", ({ clazz }) => AST11.traverseUpStop(node, clazz, isComponentDidUpdate)),
|
|
1882
|
+
O.bind("upperScope", () => O.fromNullable(context.sourceCode.getScope(node).upper)),
|
|
1883
|
+
O.filter(
|
|
1884
|
+
({ clazz, method, upperScope }) => method.parent === clazz.body && upperScope === context.sourceCode.getScope(method)
|
|
1885
|
+
),
|
|
1886
|
+
O.map(() => ({
|
|
1887
|
+
messageId: "noSetStateInComponentDidUpdate",
|
|
1888
|
+
node
|
|
1889
|
+
}))
|
|
1884
1890
|
);
|
|
1885
|
-
if (O.isNone(maybeParentClass)) return O.none();
|
|
1886
|
-
const parentClass = maybeParentClass.value;
|
|
1887
|
-
if (!isClassComponent(parentClass)) return O.none();
|
|
1888
|
-
const maybeParentMethod = AST11.traverseUp(node, isComponentDidUpdate);
|
|
1889
|
-
if (O.isNone(maybeParentMethod)) return O.none();
|
|
1890
|
-
const parentMethod = maybeParentMethod.value;
|
|
1891
|
-
if (parentMethod.parent !== parentClass.body) return O.none();
|
|
1892
|
-
if (context.sourceCode.getScope(node).upper !== context.sourceCode.getScope(parentMethod)) return O.none();
|
|
1893
|
-
return O.some({
|
|
1894
|
-
messageId: "noSetStateInComponentDidUpdate",
|
|
1895
|
-
node
|
|
1896
|
-
});
|
|
1897
1891
|
}
|
|
1898
1892
|
return {
|
|
1899
1893
|
CallExpression: F.flow(getReportDescriptor, O.map(context.report))
|
|
@@ -1925,22 +1919,19 @@ var no_set_state_in_component_will_update_default = createRule({
|
|
|
1925
1919
|
if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
|
|
1926
1920
|
function getReportDescriptor(node) {
|
|
1927
1921
|
if (!isThisSetState(node)) return O.none();
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
AST11.
|
|
1922
|
+
return F.pipe(
|
|
1923
|
+
O.Do,
|
|
1924
|
+
O.bind("clazz", () => AST11.traverseUpGuard(node, isClassComponent)),
|
|
1925
|
+
O.bind("method", ({ clazz }) => AST11.traverseUpStop(node, clazz, isComponentWillUpdate3)),
|
|
1926
|
+
O.bind("upperScope", () => O.fromNullable(context.sourceCode.getScope(node).upper)),
|
|
1927
|
+
O.filter(
|
|
1928
|
+
({ clazz, method, upperScope }) => method.parent === clazz.body && upperScope === context.sourceCode.getScope(method)
|
|
1929
|
+
),
|
|
1930
|
+
O.map(() => ({
|
|
1931
|
+
messageId: "noSetStateInComponentWillUpdate",
|
|
1932
|
+
node
|
|
1933
|
+
}))
|
|
1931
1934
|
);
|
|
1932
|
-
if (O.isNone(maybeParentClass)) return O.none();
|
|
1933
|
-
const parentClass = maybeParentClass.value;
|
|
1934
|
-
if (!isClassComponent(parentClass)) return O.none();
|
|
1935
|
-
const maybeParentMethod = AST11.traverseUp(node, isComponentWillUpdate3);
|
|
1936
|
-
if (O.isNone(maybeParentMethod)) return O.none();
|
|
1937
|
-
const parentMethod = maybeParentMethod.value;
|
|
1938
|
-
if (parentMethod.parent !== parentClass.body) return O.none();
|
|
1939
|
-
if (context.sourceCode.getScope(node).upper !== context.sourceCode.getScope(parentMethod)) return O.none();
|
|
1940
|
-
return O.some({
|
|
1941
|
-
messageId: "noSetStateInComponentWillUpdate",
|
|
1942
|
-
node
|
|
1943
|
-
});
|
|
1944
1935
|
}
|
|
1945
1936
|
return {
|
|
1946
1937
|
CallExpression: F.flow(getReportDescriptor, O.map(context.report))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "1.22.2-next.
|
|
3
|
+
"version": "1.22.2-next.9",
|
|
4
4
|
"description": "A set of composable ESLint rules for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"string-ts": "^2.2.0",
|
|
50
50
|
"ts-api-utils": "^2.0.0",
|
|
51
51
|
"ts-pattern": "^5.6.0",
|
|
52
|
-
"@eslint-react/ast": "1.22.2-next.
|
|
53
|
-
"@eslint-react/core": "1.22.2-next.
|
|
54
|
-
"@eslint-react/jsx": "1.22.2-next.
|
|
55
|
-
"@eslint-react/eff": "1.22.2-next.
|
|
56
|
-
"@eslint-react/shared": "1.22.2-next.
|
|
57
|
-
"@eslint-react/types": "1.22.2-next.
|
|
58
|
-
"@eslint-react/var": "1.22.2-next.
|
|
52
|
+
"@eslint-react/ast": "1.22.2-next.9",
|
|
53
|
+
"@eslint-react/core": "1.22.2-next.9",
|
|
54
|
+
"@eslint-react/jsx": "1.22.2-next.9",
|
|
55
|
+
"@eslint-react/eff": "1.22.2-next.9",
|
|
56
|
+
"@eslint-react/shared": "1.22.2-next.9",
|
|
57
|
+
"@eslint-react/types": "1.22.2-next.9",
|
|
58
|
+
"@eslint-react/var": "1.22.2-next.9"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/react": "^19.0.2",
|