@discourse/lint-configs 2.44.1 → 2.45.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.
@@ -1,4 +1,4 @@
1
- import { fixImport } from "./utils/fix-import.mjs";
1
+ import { buildImportStatement, fixImport } from "./utils/fix-import.mjs";
2
2
 
3
3
  export default {
4
4
  meta: {
@@ -43,13 +43,11 @@ export default {
43
43
 
44
44
  const localName = node.specifiers[0].local.name;
45
45
  let sourceName = node.source.value.match(/([^/]+)$/)[0];
46
- let importString;
47
46
 
48
- if (localName === sourceName) {
49
- importString = `${localName}`;
50
- } else {
51
- importString = `${sourceName} as ${localName}`;
52
- }
47
+ const namedImport =
48
+ localName === sourceName
49
+ ? localName
50
+ : `${sourceName} as ${localName}`;
53
51
 
54
52
  const existingImport = context
55
53
  .getSourceCode()
@@ -63,13 +61,15 @@ export default {
63
61
  return [
64
62
  fixer.remove(node),
65
63
  fixImport(fixer, existingImport, {
66
- namedImportsToAdd: [importString],
64
+ namedImportsToAdd: [namedImport],
67
65
  }),
68
66
  ];
69
67
  } else {
70
68
  return fixer.replaceText(
71
69
  node,
72
- `import { ${importString} } from "discourse-i18n";`
70
+ buildImportStatement("discourse-i18n", {
71
+ namedImports: [namedImport],
72
+ })
73
73
  );
74
74
  }
75
75
  },