@discourse/lint-configs 2.24.0 → 2.26.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.
|
@@ -2,7 +2,8 @@ export default {
|
|
|
2
2
|
meta: {
|
|
3
3
|
type: "problem",
|
|
4
4
|
docs: {
|
|
5
|
-
description:
|
|
5
|
+
description:
|
|
6
|
+
"Do not use themeSetting, themeI18n, or themePrefix helpers.",
|
|
6
7
|
},
|
|
7
8
|
fixable: "code",
|
|
8
9
|
schema: [], // no options
|
|
@@ -23,24 +24,100 @@ export default {
|
|
|
23
24
|
fix(fixer) {
|
|
24
25
|
const fixes = [fixer.remove(node)];
|
|
25
26
|
|
|
27
|
+
let addImport = false;
|
|
26
28
|
const importName = node.specifiers[0].local.name;
|
|
27
29
|
const themeSetting = moduleScope.variables.find(
|
|
28
30
|
(v) => v.name === importName
|
|
29
31
|
);
|
|
30
32
|
themeSetting.references.forEach((ref) => {
|
|
31
33
|
const expression = ref.identifier.parent.parent;
|
|
34
|
+
|
|
32
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
|
+
});
|
|
33
66
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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 {
|
|
39
88
|
fixes.push(
|
|
40
|
-
fixer.
|
|
89
|
+
fixer.insertTextAfter(
|
|
90
|
+
node,
|
|
91
|
+
`import { get } from "@ember/object";`
|
|
92
|
+
)
|
|
41
93
|
);
|
|
42
94
|
}
|
|
43
|
-
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return fixes;
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
} else if (modulePath === "discourse/helpers/theme-prefix") {
|
|
101
|
+
context.report({
|
|
102
|
+
node,
|
|
103
|
+
message: `Importing themePrefix is not allowed.`,
|
|
104
|
+
fix(fixer) {
|
|
105
|
+
const fixes = [fixer.remove(node)];
|
|
106
|
+
|
|
107
|
+
const importName = node.specifiers[0].local.name;
|
|
108
|
+
|
|
109
|
+
if (importName !== "themePrefix") {
|
|
110
|
+
const themePrefix = moduleScope.variables.find(
|
|
111
|
+
(v) => v.name === importName
|
|
112
|
+
);
|
|
113
|
+
themePrefix.references.forEach((ref) => {
|
|
114
|
+
const ident = ref.identifier;
|
|
115
|
+
|
|
116
|
+
if (ident?.type === "VarHead") {
|
|
117
|
+
fixes.push(fixer.replaceText(ident, "themePrefix"));
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
44
121
|
|
|
45
122
|
return fixes;
|
|
46
123
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@discourse/lint-configs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.26.0",
|
|
4
4
|
"description": "Shareable lint configs for Discourse core, plugins, and themes",
|
|
5
5
|
"author": "Discourse",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/core": "^7.27.4",
|
|
34
|
-
"@babel/eslint-parser": "^7.27.
|
|
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
|
}
|