@discourse/lint-configs 2.32.0 → 2.33.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/.prettierrc.cjs +2 -0
- package/eslint-rules/no-route-template.mjs +55 -0
- package/eslint.mjs +3 -0
- package/package.json +1 -1
package/.prettierrc.cjs
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
meta: {
|
|
3
|
+
type: "suggestion",
|
|
4
|
+
docs: {
|
|
5
|
+
description: "Disallow RouteTemplate wrapper for route templates.",
|
|
6
|
+
},
|
|
7
|
+
fixable: "code",
|
|
8
|
+
schema: [],
|
|
9
|
+
messages: {
|
|
10
|
+
removeRouteTemplate: "Remove RouteTemplate wrapper for route templates.",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
create(context) {
|
|
15
|
+
return {
|
|
16
|
+
ExportDefaultDeclaration(node) {
|
|
17
|
+
if (
|
|
18
|
+
node.declaration &&
|
|
19
|
+
node.declaration.type === "CallExpression" &&
|
|
20
|
+
node.declaration.callee.name === "RouteTemplate" &&
|
|
21
|
+
node.declaration.arguments.length === 1
|
|
22
|
+
) {
|
|
23
|
+
context.report({
|
|
24
|
+
node,
|
|
25
|
+
messageId: "removeRouteTemplate",
|
|
26
|
+
fix(fixer) {
|
|
27
|
+
const sourceCode = context.getSourceCode();
|
|
28
|
+
const arg = node.declaration.arguments[0];
|
|
29
|
+
// Find import of RouteTemplate
|
|
30
|
+
const importDecl = sourceCode.ast.body.find(
|
|
31
|
+
(n) =>
|
|
32
|
+
n.type === "ImportDeclaration" &&
|
|
33
|
+
n.specifiers.some(
|
|
34
|
+
(s) =>
|
|
35
|
+
s.type === "ImportDefaultSpecifier" &&
|
|
36
|
+
s.local.name === "RouteTemplate"
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// Only remove the import and replace the export, do not touch whitespace/indentation
|
|
41
|
+
const fixes = [];
|
|
42
|
+
if (importDecl) {
|
|
43
|
+
fixes.push(fixer.remove(importDecl));
|
|
44
|
+
}
|
|
45
|
+
fixes.push(
|
|
46
|
+
fixer.replaceText(node.declaration, sourceCode.getText(arg))
|
|
47
|
+
);
|
|
48
|
+
return fixes;
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
};
|
package/eslint.mjs
CHANGED
|
@@ -24,6 +24,7 @@ import lineBeforeDefaultExport from "./eslint-rules/line-before-default-export.m
|
|
|
24
24
|
import linesBetweenClassMembers from "./eslint-rules/lines-between-class-members.mjs";
|
|
25
25
|
import noCurlyComponents from "./eslint-rules/no-curly-components.mjs";
|
|
26
26
|
import noOnclick from "./eslint-rules/no-onclick.mjs";
|
|
27
|
+
import noRouteTemplate from "./eslint-rules/no-route-template.mjs";
|
|
27
28
|
import noSimpleQuerySelector from "./eslint-rules/no-simple-query-selector.mjs";
|
|
28
29
|
import noUnusedServices from "./eslint-rules/no-unused-services.mjs";
|
|
29
30
|
import pluginApiNoVersion from "./eslint-rules/plugin-api-no-version.mjs";
|
|
@@ -136,6 +137,7 @@ export default [
|
|
|
136
137
|
"no-curly-components": noCurlyComponents,
|
|
137
138
|
"capital-components": capitalComponents,
|
|
138
139
|
"no-onclick": noOnclick,
|
|
140
|
+
"no-route-template": noRouteTemplate,
|
|
139
141
|
},
|
|
140
142
|
},
|
|
141
143
|
},
|
|
@@ -312,6 +314,7 @@ export default [
|
|
|
312
314
|
"discourse/no-curly-components": ["error"],
|
|
313
315
|
"discourse/capital-components": ["error"],
|
|
314
316
|
"discourse/no-onclick": ["error"],
|
|
317
|
+
// "discourse/no-route-template": ["error"], // Enable by default once Ember 6.6 is on stable
|
|
315
318
|
},
|
|
316
319
|
},
|
|
317
320
|
{
|