Skip to content

Commit a0ede83

Browse files
committed
Remove no-shadow-underscore rule and related tests
1 parent d7e08a3 commit a0ede83

File tree

6 files changed

+6
-170
lines changed

6 files changed

+6
-170
lines changed

.pkgs/eslint-plugin-local/dist/index.js

Lines changed: 6 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import * as AST from "@eslint-react/ast";
22
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
3-
import { unit } from "@eslint-react/eff";
4-
import { findVariable } from "@eslint-react/var";
5-
import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from "@typescript-eslint/types";
63
import { NullThrowsReasons, nullThrows } from "@typescript-eslint/utils/eslint-utils";
74

85
//#region package.json
@@ -16,87 +13,28 @@ function getDocsUrl() {
1613
}
1714
const createRule = ESLintUtils.RuleCreator(getDocsUrl);
1815

19-
//#endregion
20-
//#region src/utils/is-initialized-from-source.ts
21-
/**
22-
* Check if an identifier is initialized from the given source
23-
* @param name The top-level identifier's name
24-
* @param source The import source to check against
25-
* @param initialScope Initial scope to search for the identifier
26-
* @returns Whether the identifier is initialized from the given source
27-
*/
28-
function isInitializedFromSource(name$1, source, initialScope) {
29-
const latestDef = findVariable(name$1, initialScope)?.defs.at(-1);
30-
if (latestDef == null) return false;
31-
const { node, parent } = latestDef;
32-
if (node.type === AST_NODE_TYPES$1.VariableDeclarator && node.init != null) {
33-
const { init } = node;
34-
if (init.type === AST_NODE_TYPES$1.MemberExpression && init.object.type === AST_NODE_TYPES$1.Identifier) return isInitializedFromSource(init.object.name, source, initialScope);
35-
if (init.type === AST_NODE_TYPES$1.Identifier) return isInitializedFromSource(init.name, source, initialScope);
36-
const arg0 = getRequireExpressionArguments(init)?.[0];
37-
if (arg0 == null || !AST.isLiteral(arg0, "string")) return false;
38-
return arg0.value === source || arg0.value.startsWith(`${source}/`);
39-
}
40-
return parent?.type === AST_NODE_TYPES$1.ImportDeclaration && parent.source.value === source;
41-
}
42-
function getRequireExpressionArguments(node) {
43-
switch (true) {
44-
case node.type === AST_NODE_TYPES$1.CallExpression && node.callee.type === AST_NODE_TYPES$1.Identifier && node.callee.name === "require": return node.arguments;
45-
case node.type === AST_NODE_TYPES$1.MemberExpression: return getRequireExpressionArguments(node.object);
46-
}
47-
return unit;
48-
}
49-
5016
//#endregion
5117
//#region src/rules/avoid-multiline-template-expression.ts
52-
const RULE_NAME$2 = "avoid-multiline-template-expression";
53-
const RULE_FEATURES$1 = [];
18+
const RULE_NAME$1 = "avoid-multiline-template-expression";
19+
const RULE_FEATURES = [];
5420
var avoid_multiline_template_expression_default = createRule({
5521
meta: {
5622
type: "problem",
5723
docs: {
5824
description: "disallow multiline template expressions",
59-
[Symbol.for("rule_features")]: RULE_FEATURES$1
60-
},
61-
messages: { avoidMultilineTemplateExpression: "Avoid multiline template expressions." },
62-
schema: []
63-
},
64-
name: RULE_NAME$2,
65-
create: create$2,
66-
defaultOptions: []
67-
});
68-
function create$2(context) {
69-
return { TemplateLiteral: (node) => {
70-
if (AST.isMultiLine(node)) context.report({
71-
messageId: "avoidMultilineTemplateExpression",
72-
node
73-
});
74-
} };
75-
}
76-
77-
//#endregion
78-
//#region src/rules/no-shadow-underscore.ts
79-
const RULE_NAME$1 = "no-shadow-underscore";
80-
const RULE_FEATURES = [];
81-
var no_shadow_underscore_default = createRule({
82-
meta: {
83-
type: "problem",
84-
docs: {
85-
description: "disallow shadowing of the underscore identifier",
8625
[Symbol.for("rule_features")]: RULE_FEATURES
8726
},
88-
messages: { noShadowUnderscore: "In this codebase, '_' is used to represent the undefined. Avoid shadowing it." },
27+
messages: { avoidMultilineTemplateExpression: "Avoid multiline template expressions." },
8928
schema: []
9029
},
9130
name: RULE_NAME$1,
9231
create: create$1,
9332
defaultOptions: []
9433
});
9534
function create$1(context) {
96-
return { "Identifier[name='_']"(node) {
97-
const initialScope = context.sourceCode.getScope(node);
98-
if (!isInitializedFromSource("_", "@eslint-react/eff", initialScope)) context.report({
99-
messageId: "noShadowUnderscore",
35+
return { TemplateLiteral: (node) => {
36+
if (AST.isMultiLine(node)) context.report({
37+
messageId: "avoidMultilineTemplateExpression",
10038
node
10139
});
10240
} };
@@ -162,7 +100,6 @@ const plugin = {
162100
},
163101
rules: {
164102
"avoid-multiline-template-expression": avoid_multiline_template_expression_default,
165-
"no-shadow-underscore": no_shadow_underscore_default,
166103
"prefer-eqeq-nullish-comparison": prefer_eqeq_nullish_comparison_default
167104
}
168105
};

.pkgs/eslint-plugin-local/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { name, version } from "../package.json";
33
import type { CompatiblePlugin } from "@eslint-react/kit";
44

55
import avoidMultilineTemplateExpression from "./rules/avoid-multiline-template-expression";
6-
import noShadowingUnderscore from "./rules/no-shadow-underscore";
76
import preferEqeqNullishComparison from "./rules/prefer-eqeq-nullish-comparison";
87

98
const plugin: CompatiblePlugin = {
@@ -13,7 +12,6 @@ const plugin: CompatiblePlugin = {
1312
},
1413
rules: {
1514
"avoid-multiline-template-expression": avoidMultilineTemplateExpression,
16-
"no-shadow-underscore": noShadowingUnderscore,
1715
"prefer-eqeq-nullish-comparison": preferEqeqNullishComparison,
1816
},
1917
};

.pkgs/eslint-plugin-local/src/rules/no-shadow-underscore.spec.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.

.pkgs/eslint-plugin-local/src/rules/no-shadow-underscore.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.

eslint.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ export default defineConfig([
7474
rules: {
7575
// Part: local rules
7676
"local/avoid-multiline-template-expression": "warn",
77-
"local/no-shadow-underscore": "error",
7877
"local/prefer-eqeq-nullish-comparison": "warn",
7978

8079
"fast-import/no-unused-exports": "off",

packages/utilities/eff/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
/* eslint-disable @typescript-eslint/unified-signatures */
6161
/* eslint-disable jsdoc/check-param-names */
6262
/* eslint-disable jsdoc/require-param-description */
63-
/* eslint-disable local/no-shadow-underscore */
6463
/* eslint-disable local/prefer-eqeq-nullish-comparison */
6564
/* eslint-disable prefer-rest-params */
6665

0 commit comments

Comments
 (0)