eslint-plugin-react-x 1.37.2-next.0 → 1.37.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.js +12 -2
- package/dist/index.mjs +12 -2
- package/package.json +8 -7
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ var typeUtils = require('@typescript-eslint/type-utils');
|
|
|
13
13
|
var utils = require('@typescript-eslint/utils');
|
|
14
14
|
var tsApiUtils = require('ts-api-utils');
|
|
15
15
|
var ts = require('typescript');
|
|
16
|
+
var isImmutableType = require('is-immutable-type');
|
|
16
17
|
|
|
17
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
19
|
|
|
@@ -135,7 +136,7 @@ var settings3 = {
|
|
|
135
136
|
|
|
136
137
|
// package.json
|
|
137
138
|
var name4 = "eslint-plugin-react-x";
|
|
138
|
-
var version = "1.37.2
|
|
139
|
+
var version = "1.37.2";
|
|
139
140
|
var createRule = shared.createRuleForPlugin("x");
|
|
140
141
|
|
|
141
142
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -3252,7 +3253,7 @@ function create49(context) {
|
|
|
3252
3253
|
continue;
|
|
3253
3254
|
}
|
|
3254
3255
|
const propsType = typeUtils.getConstrainedTypeAtLocation(services, props);
|
|
3255
|
-
if (
|
|
3256
|
+
if (isTypeReadonlyLoose(services, propsType)) {
|
|
3256
3257
|
continue;
|
|
3257
3258
|
}
|
|
3258
3259
|
context.report({ messageId: "preferReadOnlyProps", node: props });
|
|
@@ -3260,6 +3261,15 @@ function create49(context) {
|
|
|
3260
3261
|
}
|
|
3261
3262
|
};
|
|
3262
3263
|
}
|
|
3264
|
+
function isTypeReadonlyLoose(services, type) {
|
|
3265
|
+
if (typeUtils.isTypeReadonly(services.program, type)) return true;
|
|
3266
|
+
try {
|
|
3267
|
+
const im = isImmutableType.getTypeImmutability(services.program, type);
|
|
3268
|
+
return isImmutableType.isUnknown(im) || isImmutableType.isImmutable(im) || isImmutableType.isReadonlyShallow(im) || isImmutableType.isReadonlyDeep(im);
|
|
3269
|
+
} catch {
|
|
3270
|
+
return true;
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3263
3273
|
var RULE_NAME50 = "prefer-shorthand-boolean";
|
|
3264
3274
|
var RULE_FEATURES49 = [
|
|
3265
3275
|
"FIX"
|
package/dist/index.mjs
CHANGED
|
@@ -11,6 +11,7 @@ import { getConstrainedTypeAtLocation, isTypeReadonly } from '@typescript-eslint
|
|
|
11
11
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
12
12
|
import { unionConstituents, isTypeFlagSet, isTrueLiteralType, isFalseLiteralType } from 'ts-api-utils';
|
|
13
13
|
import ts from 'typescript';
|
|
14
|
+
import { getTypeImmutability, isUnknown, isImmutable, isReadonlyShallow, isReadonlyDeep } from 'is-immutable-type';
|
|
14
15
|
|
|
15
16
|
var __defProp = Object.defineProperty;
|
|
16
17
|
var __export = (target, all) => {
|
|
@@ -108,7 +109,7 @@ var settings3 = {
|
|
|
108
109
|
|
|
109
110
|
// package.json
|
|
110
111
|
var name4 = "eslint-plugin-react-x";
|
|
111
|
-
var version = "1.37.2
|
|
112
|
+
var version = "1.37.2";
|
|
112
113
|
var createRule = createRuleForPlugin("x");
|
|
113
114
|
|
|
114
115
|
// src/rules/avoid-shorthand-boolean.ts
|
|
@@ -3225,7 +3226,7 @@ function create49(context) {
|
|
|
3225
3226
|
continue;
|
|
3226
3227
|
}
|
|
3227
3228
|
const propsType = getConstrainedTypeAtLocation(services, props);
|
|
3228
|
-
if (
|
|
3229
|
+
if (isTypeReadonlyLoose(services, propsType)) {
|
|
3229
3230
|
continue;
|
|
3230
3231
|
}
|
|
3231
3232
|
context.report({ messageId: "preferReadOnlyProps", node: props });
|
|
@@ -3233,6 +3234,15 @@ function create49(context) {
|
|
|
3233
3234
|
}
|
|
3234
3235
|
};
|
|
3235
3236
|
}
|
|
3237
|
+
function isTypeReadonlyLoose(services, type) {
|
|
3238
|
+
if (isTypeReadonly(services.program, type)) return true;
|
|
3239
|
+
try {
|
|
3240
|
+
const im = getTypeImmutability(services.program, type);
|
|
3241
|
+
return isUnknown(im) || isImmutable(im) || isReadonlyShallow(im) || isReadonlyDeep(im);
|
|
3242
|
+
} catch {
|
|
3243
|
+
return true;
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3236
3246
|
var RULE_NAME50 = "prefer-shorthand-boolean";
|
|
3237
3247
|
var RULE_FEATURES49 = [
|
|
3238
3248
|
"FIX"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-x",
|
|
3
|
-
"version": "1.37.2
|
|
3
|
+
"version": "1.37.2",
|
|
4
4
|
"description": "A set of composable linting rules for libraries and frameworks that use React as a UI runtime.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -47,14 +47,15 @@
|
|
|
47
47
|
"@typescript-eslint/types": "^8.27.0",
|
|
48
48
|
"@typescript-eslint/utils": "^8.27.0",
|
|
49
49
|
"compare-versions": "^6.1.1",
|
|
50
|
+
"is-immutable-type": "^5.0.1",
|
|
50
51
|
"string-ts": "^2.2.1",
|
|
51
52
|
"ts-pattern": "^5.6.2",
|
|
52
|
-
"@eslint-react/ast": "1.37.2
|
|
53
|
-
"@eslint-react/eff": "1.37.2
|
|
54
|
-
"@eslint-react/
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
57
|
-
"@eslint-react/
|
|
53
|
+
"@eslint-react/ast": "1.37.2",
|
|
54
|
+
"@eslint-react/eff": "1.37.2",
|
|
55
|
+
"@eslint-react/shared": "1.37.2",
|
|
56
|
+
"@eslint-react/var": "1.37.2",
|
|
57
|
+
"@eslint-react/core": "1.37.2",
|
|
58
|
+
"@eslint-react/jsx": "1.37.2"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
61
|
"@types/react": "^19.0.12",
|