@backstage/eslint-plugin 0.1.9 → 0.1.10-next.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @backstage/eslint-plugin
2
2
 
3
+ ## 0.1.10-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 63963f6: Internal refactor to deal with `estree` upgrade
8
+
3
9
  ## 0.1.9
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/eslint-plugin",
3
- "version": "0.1.9",
3
+ "version": "0.1.10-next.0",
4
4
  "description": "Backstage ESLint plugin",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -22,7 +22,7 @@
22
22
  "minimatch": "^9.0.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@backstage/cli": "^0.27.1",
25
+ "@backstage/cli": "0.28.0-next.1",
26
26
  "@types/estree": "^1.0.5",
27
27
  "eslint": "^8.33.0"
28
28
  }
@@ -80,11 +80,14 @@ const KNOWN_STYLES = [
80
80
 
81
81
  /**
82
82
  * filter function to keep only ImportSpecifier nodes
83
- * @param {import('estree').ImportSpecifier | import('estree').ImportDefaultSpecifier| import('estree').ImportNamespaceSpecifier} specifier
83
+ * @param {import('estree').ImportSpecifier | import('estree').ImportDefaultSpecifier | import('estree').ImportNamespaceSpecifier} specifier
84
84
  * @returns {specifier is import('estree').ImportSpecifier}
85
85
  */
86
86
  function importSpecifiersFilter(specifier) {
87
- return specifier.type === 'ImportSpecifier';
87
+ return (
88
+ specifier.type === 'ImportSpecifier' &&
89
+ specifier.imported.type !== 'Literal'
90
+ );
88
91
  }
89
92
 
90
93
  /**
@@ -146,12 +149,16 @@ module.exports = {
146
149
 
147
150
  const specifiers = node.specifiers.filter(importSpecifiersFilter);
148
151
 
149
- const specifiersMap = specifiers.map(
152
+ const specifiersMap = specifiers.flatMap(
150
153
  /**
151
154
  * transform ImportSpecifier to FixerValues to have a simpler object to work with
152
- * @returns {FixerValues}
155
+ * @returns {FixerValues[]}
153
156
  */
154
157
  s => {
158
+ if (s.imported.type === 'Literal') {
159
+ return [];
160
+ }
161
+
155
162
  const value = s.imported.name;
156
163
  const alias = s.local.name === value ? undefined : s.local.name;
157
164
 
@@ -165,19 +172,24 @@ module.exports = {
165
172
  const emitComponent = !emitProp;
166
173
  const emitComponentAndProp =
167
174
  emitProp &&
168
- specifiers.find(s => s.imported.name === propsMatch[1])?.local
169
- .name;
170
-
171
- return {
172
- emitComponent: emitComponent || Boolean(emitComponentAndProp),
173
- emitProp,
174
- value,
175
- componentValue: propsMatch ? propsMatch[1] : undefined,
176
- componentAlias: emitComponentAndProp
177
- ? emitComponentAndProp
178
- : undefined,
179
- alias,
180
- };
175
+ specifiers.find(
176
+ s =>
177
+ s.imported.type !== 'Literal' &&
178
+ s.imported.name === propsMatch[1],
179
+ )?.local.name;
180
+
181
+ return [
182
+ {
183
+ emitComponent: emitComponent || Boolean(emitComponentAndProp),
184
+ emitProp,
185
+ value,
186
+ componentValue: propsMatch ? propsMatch[1] : undefined,
187
+ componentAlias: emitComponentAndProp
188
+ ? emitComponentAndProp
189
+ : undefined,
190
+ alias,
191
+ },
192
+ ];
181
193
  },
182
194
  );
183
195