@so1ve/eslint-plugin 0.78.5 → 0.79.0
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.cjs +19 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +19 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -276,19 +276,30 @@ const noInlineTypeImport = createEslintRule({
|
|
|
276
276
|
}
|
|
277
277
|
});
|
|
278
278
|
|
|
279
|
-
const RULE_NAME$1 = "no-negated-
|
|
280
|
-
const
|
|
279
|
+
const RULE_NAME$1 = "no-negated-comparison";
|
|
280
|
+
const negatedToPositive = {
|
|
281
|
+
"==": "!=",
|
|
282
|
+
"===": "!==",
|
|
283
|
+
"!=": "==",
|
|
284
|
+
"!==": "===",
|
|
285
|
+
"<": ">=",
|
|
286
|
+
"<=": ">",
|
|
287
|
+
">": "<=",
|
|
288
|
+
">=": "<"
|
|
289
|
+
};
|
|
290
|
+
const negatives = Object.keys(negatedToPositive);
|
|
291
|
+
const noNegatedComparison = createEslintRule({
|
|
281
292
|
name: RULE_NAME$1,
|
|
282
293
|
meta: {
|
|
283
294
|
type: "problem",
|
|
284
295
|
docs: {
|
|
285
|
-
description: "Disallow negated
|
|
296
|
+
description: "Disallow negated comparison.",
|
|
286
297
|
recommended: "error"
|
|
287
298
|
},
|
|
288
299
|
fixable: "code",
|
|
289
300
|
schema: [],
|
|
290
301
|
messages: {
|
|
291
|
-
|
|
302
|
+
noNegatedComparison: "Expect no negated comparison."
|
|
292
303
|
}
|
|
293
304
|
},
|
|
294
305
|
defaultOptions: [],
|
|
@@ -298,14 +309,14 @@ const noNegatedEqual = createEslintRule({
|
|
|
298
309
|
if (!parent) {
|
|
299
310
|
return;
|
|
300
311
|
}
|
|
301
|
-
if (
|
|
312
|
+
if (negatives.includes(node.operator) && parent.type === types.AST_NODE_TYPES.UnaryExpression && // Is this necessary?
|
|
302
313
|
parent.operator === "!") {
|
|
303
314
|
context.report({
|
|
304
315
|
node,
|
|
305
|
-
messageId: "
|
|
316
|
+
messageId: "noNegatedComparison",
|
|
306
317
|
*fix(fixer) {
|
|
307
318
|
const operatorRange = [left.range[1], right.range[0]];
|
|
308
|
-
const fixedOperator = operator
|
|
319
|
+
const fixedOperator = negatedToPositive[operator];
|
|
309
320
|
yield fixer.replaceTextRange(operatorRange, fixedOperator);
|
|
310
321
|
yield fixer.removeRange([parent.range[0], parent.range[0] + 1]);
|
|
311
322
|
}
|
|
@@ -356,7 +367,7 @@ const index = {
|
|
|
356
367
|
"import-dedupe": importDedupe,
|
|
357
368
|
"no-inline-type-import": noInlineTypeImport,
|
|
358
369
|
"no-useless-template-string": noUselessTemplateString,
|
|
359
|
-
"no-negated-
|
|
370
|
+
"no-negated-comparison": noNegatedComparison
|
|
360
371
|
}
|
|
361
372
|
};
|
|
362
373
|
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ declare const _default: {
|
|
|
8
8
|
"import-dedupe": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"importDedupe", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
9
9
|
"no-inline-type-import": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noInlineTypeImport", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
10
10
|
"no-useless-template-string": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noUselessTemplateString", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
11
|
-
"no-negated-
|
|
11
|
+
"no-negated-comparison": _typescript_eslint_utils_dist_ts_eslint_Rule.RuleModule<"noNegatedComparison", [], _typescript_eslint_utils_dist_ts_eslint_Rule.RuleListener>;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
|
package/dist/index.mjs
CHANGED
|
@@ -274,19 +274,30 @@ const noInlineTypeImport = createEslintRule({
|
|
|
274
274
|
}
|
|
275
275
|
});
|
|
276
276
|
|
|
277
|
-
const RULE_NAME$1 = "no-negated-
|
|
278
|
-
const
|
|
277
|
+
const RULE_NAME$1 = "no-negated-comparison";
|
|
278
|
+
const negatedToPositive = {
|
|
279
|
+
"==": "!=",
|
|
280
|
+
"===": "!==",
|
|
281
|
+
"!=": "==",
|
|
282
|
+
"!==": "===",
|
|
283
|
+
"<": ">=",
|
|
284
|
+
"<=": ">",
|
|
285
|
+
">": "<=",
|
|
286
|
+
">=": "<"
|
|
287
|
+
};
|
|
288
|
+
const negatives = Object.keys(negatedToPositive);
|
|
289
|
+
const noNegatedComparison = createEslintRule({
|
|
279
290
|
name: RULE_NAME$1,
|
|
280
291
|
meta: {
|
|
281
292
|
type: "problem",
|
|
282
293
|
docs: {
|
|
283
|
-
description: "Disallow negated
|
|
294
|
+
description: "Disallow negated comparison.",
|
|
284
295
|
recommended: "error"
|
|
285
296
|
},
|
|
286
297
|
fixable: "code",
|
|
287
298
|
schema: [],
|
|
288
299
|
messages: {
|
|
289
|
-
|
|
300
|
+
noNegatedComparison: "Expect no negated comparison."
|
|
290
301
|
}
|
|
291
302
|
},
|
|
292
303
|
defaultOptions: [],
|
|
@@ -296,14 +307,14 @@ const noNegatedEqual = createEslintRule({
|
|
|
296
307
|
if (!parent) {
|
|
297
308
|
return;
|
|
298
309
|
}
|
|
299
|
-
if (
|
|
310
|
+
if (negatives.includes(node.operator) && parent.type === AST_NODE_TYPES.UnaryExpression && // Is this necessary?
|
|
300
311
|
parent.operator === "!") {
|
|
301
312
|
context.report({
|
|
302
313
|
node,
|
|
303
|
-
messageId: "
|
|
314
|
+
messageId: "noNegatedComparison",
|
|
304
315
|
*fix(fixer) {
|
|
305
316
|
const operatorRange = [left.range[1], right.range[0]];
|
|
306
|
-
const fixedOperator = operator
|
|
317
|
+
const fixedOperator = negatedToPositive[operator];
|
|
307
318
|
yield fixer.replaceTextRange(operatorRange, fixedOperator);
|
|
308
319
|
yield fixer.removeRange([parent.range[0], parent.range[0] + 1]);
|
|
309
320
|
}
|
|
@@ -354,7 +365,7 @@ const index = {
|
|
|
354
365
|
"import-dedupe": importDedupe,
|
|
355
366
|
"no-inline-type-import": noInlineTypeImport,
|
|
356
367
|
"no-useless-template-string": noUselessTemplateString,
|
|
357
|
-
"no-negated-
|
|
368
|
+
"no-negated-comparison": noNegatedComparison
|
|
358
369
|
}
|
|
359
370
|
};
|
|
360
371
|
|