@discourse/lint-configs 2.13.0 → 2.13.2
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.
|
@@ -20,7 +20,7 @@ export default {
|
|
|
20
20
|
message:
|
|
21
21
|
"Import from 'i18n' is not allowed. Use 'discourse-i18n' instead.",
|
|
22
22
|
fix(fixer) {
|
|
23
|
-
return fixer.replaceText(node.source, "
|
|
23
|
+
return fixer.replaceText(node.source, `"discourse-i18n"`);
|
|
24
24
|
},
|
|
25
25
|
});
|
|
26
26
|
}
|
|
@@ -35,13 +35,22 @@ export default {
|
|
|
35
35
|
fix(fixer) {
|
|
36
36
|
const canSafelyReplace =
|
|
37
37
|
node.specifiers.length === 1 &&
|
|
38
|
-
node.specifiers[0].type === "ImportDefaultSpecifier"
|
|
39
|
-
node.specifiers[0].local.name === "i18n";
|
|
38
|
+
node.specifiers[0].type === "ImportDefaultSpecifier";
|
|
40
39
|
|
|
41
40
|
if (!canSafelyReplace) {
|
|
42
41
|
return;
|
|
43
42
|
}
|
|
44
43
|
|
|
44
|
+
const localName = node.specifiers[0].local.name;
|
|
45
|
+
let sourceName = node.source.value.match(/([^/]+)$/)[0];
|
|
46
|
+
let importString;
|
|
47
|
+
|
|
48
|
+
if (localName === sourceName) {
|
|
49
|
+
importString = `${localName}`;
|
|
50
|
+
} else {
|
|
51
|
+
importString = `${sourceName} as ${localName}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
45
54
|
const existingImport = context
|
|
46
55
|
.getSourceCode()
|
|
47
56
|
.ast.body.find(
|
|
@@ -54,13 +63,13 @@ export default {
|
|
|
54
63
|
return [
|
|
55
64
|
fixer.remove(node),
|
|
56
65
|
fixImport(fixer, existingImport, {
|
|
57
|
-
namedImportsToAdd: [
|
|
66
|
+
namedImportsToAdd: [importString],
|
|
58
67
|
}),
|
|
59
68
|
];
|
|
60
69
|
} else {
|
|
61
70
|
return fixer.replaceText(
|
|
62
71
|
node,
|
|
63
|
-
`import {
|
|
72
|
+
`import { ${importString} } from "discourse-i18n";`
|
|
64
73
|
);
|
|
65
74
|
}
|
|
66
75
|
},
|
|
@@ -18,10 +18,14 @@ export default {
|
|
|
18
18
|
fix(fixer) {
|
|
19
19
|
let code;
|
|
20
20
|
const localName = node.specifiers[0].local.name;
|
|
21
|
-
|
|
21
|
+
let sourceName = node.source.value.match(/([^/]+)$/)[0];
|
|
22
|
+
|
|
23
|
+
if (sourceName === "not-eq") {
|
|
24
|
+
sourceName = "notEq";
|
|
25
|
+
}
|
|
22
26
|
|
|
23
27
|
if (localName === sourceName) {
|
|
24
|
-
code = `import { ${
|
|
28
|
+
code = `import { ${localName} } from 'truth-helpers';`;
|
|
25
29
|
} else {
|
|
26
30
|
code = `import { ${sourceName} as ${localName} } from 'truth-helpers';`;
|
|
27
31
|
}
|