@discourse/lint-configs 2.25.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.
@@ -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
- if (expression?.type === "GlimmerMustacheStatement") {
36
- fixes.push(
37
- fixer.replaceText(expression, `{{settings.${param.value}}}`)
38
- );
39
- } else if (expression?.type === "GlimmerSubExpression") {
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.replaceText(expression, `settings.${param.value}`)
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@discourse/lint-configs",
3
- "version": "2.25.0",
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",
@@ -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.8.1",
37
- "eslint": "^9.28.0",
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.5",
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.0",
50
+ "stylelint-scss": "^6.12.1",
51
51
  "typescript": "^5.8.3"
52
52
  },
53
53
  "peerDependencies": {
54
- "ember-template-lint": "7.8.1",
55
- "eslint": "9.28.0",
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
  }