@starci/eslint-canon-fe 1.3.2 → 1.4.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/naming.mjs +36 -7
- package/package.json +1 -1
package/naming.mjs
CHANGED
|
@@ -44,7 +44,7 @@ export const preferArrowExport = {
|
|
|
44
44
|
// -- NAMING-2 --------------------------------------------------------------------------------------
|
|
45
45
|
|
|
46
46
|
/** Something a reader triggers is named `onX`, so the name survives being passed. */
|
|
47
|
-
export const handlerOnPrefix = {
|
|
47
|
+
export const handlerOnPrefix = {
|
|
48
48
|
meta: {
|
|
49
49
|
type: "suggestion",
|
|
50
50
|
docs: { description: "Handlers are named `onX`, not `handleX`." },
|
|
@@ -70,7 +70,35 @@ export const handlerOnPrefix = {
|
|
|
70
70
|
},
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
|
-
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// -- machine-only identity -------------------------------------------------------------------------
|
|
76
|
+
|
|
77
|
+
/** A const introduces a value; it does not merely give an existing identifier a second name. */
|
|
78
|
+
export const noDirectConstAlias = {
|
|
79
|
+
meta: {
|
|
80
|
+
type: "problem",
|
|
81
|
+
docs: { description: "A const must not be a direct identifier-to-identifier alias." },
|
|
82
|
+
schema: [],
|
|
83
|
+
messages: {
|
|
84
|
+
alias:
|
|
85
|
+
"`const {{alias}} = {{original}}` gives one value two names without adding behavior. Use `{{original}}` directly, or make `{{alias}}` the result of the transformation it claims to represent.",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
create(context) {
|
|
89
|
+
return {
|
|
90
|
+
VariableDeclarator(node) {
|
|
91
|
+
if (node.parent?.kind !== "const") return
|
|
92
|
+
if (node.id?.type !== "Identifier" || node.init?.type !== "Identifier") return
|
|
93
|
+
context.report({
|
|
94
|
+
node: node.id,
|
|
95
|
+
messageId: "alias",
|
|
96
|
+
data: { alias: node.id.name, original: node.init.name },
|
|
97
|
+
})
|
|
98
|
+
},
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
}
|
|
74
102
|
|
|
75
103
|
/** The rules this law contributes to the plugin. */
|
|
76
104
|
// -- NAMING-3 --------------------------------------------------------------------------------------
|
|
@@ -134,11 +162,12 @@ export const noSecondLanguageInPath = {
|
|
|
134
162
|
},
|
|
135
163
|
}
|
|
136
164
|
|
|
137
|
-
export const rules = {
|
|
138
|
-
"prefer-arrow-export": preferArrowExport,
|
|
139
|
-
"handler-on-prefix": handlerOnPrefix,
|
|
140
|
-
"no-second-language-in-path": noSecondLanguageInPath,
|
|
141
|
-
|
|
165
|
+
export const rules = {
|
|
166
|
+
"prefer-arrow-export": preferArrowExport,
|
|
167
|
+
"handler-on-prefix": handlerOnPrefix,
|
|
168
|
+
"no-second-language-in-path": noSecondLanguageInPath,
|
|
169
|
+
"no-direct-const-alias": noDirectConstAlias,
|
|
170
|
+
}
|
|
142
171
|
|
|
143
172
|
/**
|
|
144
173
|
* The level this law asks for, as the plugin's own opinion.
|
package/package.json
CHANGED