@discourse/lint-configs 2.25.0 → 2.27.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/eslint-rules/theme-imports.mjs +58 -7
- package/eslint.mjs +0 -4
- package/package.json +7 -7
|
@@ -24,24 +24,75 @@ export default {
|
|
|
24
24
|
fix(fixer) {
|
|
25
25
|
const fixes = [fixer.remove(node)];
|
|
26
26
|
|
|
27
|
+
let addImport = false;
|
|
27
28
|
const importName = node.specifiers[0].local.name;
|
|
28
29
|
const themeSetting = moduleScope.variables.find(
|
|
29
30
|
(v) => v.name === importName
|
|
30
31
|
);
|
|
31
32
|
themeSetting.references.forEach((ref) => {
|
|
32
33
|
const expression = ref.identifier.parent.parent;
|
|
34
|
+
|
|
33
35
|
const param = expression?.params[0];
|
|
36
|
+
if (param?.value) {
|
|
37
|
+
if (expression?.type === "GlimmerMustacheStatement") {
|
|
38
|
+
fixes.push(
|
|
39
|
+
fixer.replaceText(
|
|
40
|
+
expression,
|
|
41
|
+
`{{settings.${param.value}}}`
|
|
42
|
+
)
|
|
43
|
+
);
|
|
44
|
+
} else if (expression?.type === "GlimmerSubExpression") {
|
|
45
|
+
fixes.push(
|
|
46
|
+
fixer.replaceText(expression, `settings.${param.value}`)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
// the complex params case
|
|
51
|
+
if (
|
|
52
|
+
[
|
|
53
|
+
"GlimmerMustacheStatement",
|
|
54
|
+
"GlimmerSubExpression",
|
|
55
|
+
].includes(expression?.type)
|
|
56
|
+
) {
|
|
57
|
+
if (param) {
|
|
58
|
+
addImport = true;
|
|
59
|
+
fixes.push(
|
|
60
|
+
fixer.replaceText(ref.identifier, "get settings")
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
34
66
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
67
|
+
if (addImport) {
|
|
68
|
+
const getFunction = moduleScope.variables.find(
|
|
69
|
+
(v) => v.name === "get"
|
|
70
|
+
);
|
|
71
|
+
if (getFunction) {
|
|
72
|
+
const importBindingDefinition = getFunction.defs[0];
|
|
73
|
+
if (importBindingDefinition.node.imported.name === "get") {
|
|
74
|
+
if (
|
|
75
|
+
importBindingDefinition.parent.source.value ===
|
|
76
|
+
"@ember/object"
|
|
77
|
+
) {
|
|
78
|
+
// no need to add the import
|
|
79
|
+
} else {
|
|
80
|
+
// can't autofix
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
// can't autofix
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
40
88
|
fixes.push(
|
|
41
|
-
fixer.
|
|
89
|
+
fixer.insertTextAfter(
|
|
90
|
+
node,
|
|
91
|
+
`import { get } from "@ember/object";`
|
|
92
|
+
)
|
|
42
93
|
);
|
|
43
94
|
}
|
|
44
|
-
}
|
|
95
|
+
}
|
|
45
96
|
|
|
46
97
|
return fixes;
|
|
47
98
|
},
|
package/eslint.mjs
CHANGED
|
@@ -153,7 +153,6 @@ export default [
|
|
|
153
153
|
"no-iterator": "error",
|
|
154
154
|
"no-loop-func": "error",
|
|
155
155
|
"no-misleading-character-class": "off",
|
|
156
|
-
"no-mixed-spaces-and-tabs": "error",
|
|
157
156
|
"no-multi-str": "error",
|
|
158
157
|
"no-new": "error",
|
|
159
158
|
"no-proto": "error",
|
|
@@ -163,7 +162,6 @@ export default [
|
|
|
163
162
|
"no-sequences": "error",
|
|
164
163
|
"no-shadow": "error",
|
|
165
164
|
"no-this-before-super": "error",
|
|
166
|
-
"no-trailing-spaces": "error",
|
|
167
165
|
"no-undef": "error",
|
|
168
166
|
"no-unexpected-multiline": "off",
|
|
169
167
|
"no-unused-vars": "error",
|
|
@@ -171,9 +169,7 @@ export default [
|
|
|
171
169
|
"no-var": "error",
|
|
172
170
|
"no-with": "error",
|
|
173
171
|
radix: "error",
|
|
174
|
-
semi: "error",
|
|
175
172
|
"valid-typeof": "error",
|
|
176
|
-
"wrap-iife": ["error", "inside"],
|
|
177
173
|
curly: "error",
|
|
178
174
|
"import/no-duplicates": "error",
|
|
179
175
|
"object-shorthand": ["error", "properties"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@discourse/lint-configs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.27.0",
|
|
4
4
|
"description": "Shareable lint configs for Discourse core, plugins, and themes",
|
|
5
5
|
"author": "Discourse",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"@babel/core": "^7.27.4",
|
|
34
34
|
"@babel/eslint-parser": "^7.27.5",
|
|
35
35
|
"@babel/plugin-proposal-decorators": "^7.27.1",
|
|
36
|
-
"ember-template-lint": "^7.
|
|
37
|
-
"eslint": "^9.
|
|
36
|
+
"ember-template-lint": "^7.9.1",
|
|
37
|
+
"eslint": "^9.29.0",
|
|
38
38
|
"eslint-plugin-decorator-position": "^6.0.0",
|
|
39
39
|
"eslint-plugin-ember": "^12.5.0",
|
|
40
40
|
"eslint-plugin-import": "^2.31.0",
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
"eslint-plugin-sort-class-members": "^1.21.0",
|
|
44
44
|
"globals": "^16.2.0",
|
|
45
45
|
"prettier": "^3.5.3",
|
|
46
|
-
"prettier-plugin-ember-template-tag": "^2.0.
|
|
46
|
+
"prettier-plugin-ember-template-tag": "^2.0.6",
|
|
47
47
|
"stylelint": "^16.20.0",
|
|
48
48
|
"stylelint-config-standard": "^38.0.0",
|
|
49
49
|
"stylelint-config-standard-scss": "^15.0.1",
|
|
50
|
-
"stylelint-scss": "^6.12.
|
|
50
|
+
"stylelint-scss": "^6.12.1",
|
|
51
51
|
"typescript": "^5.8.3"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"ember-template-lint": "7.
|
|
55
|
-
"eslint": "9.
|
|
54
|
+
"ember-template-lint": "7.9.1",
|
|
55
|
+
"eslint": "9.29.0",
|
|
56
56
|
"prettier": "3.5.3",
|
|
57
57
|
"stylelint": "16.20.0"
|
|
58
58
|
}
|