tsl-dx 0.9.0 → 0.10.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.
package/dist/index.d.ts CHANGED
@@ -88,6 +88,6 @@ type nullishOptions = {
88
88
  * if (x == null) { }
89
89
  * ```
90
90
  */
91
- declare const nullish: (options?: "off" | nullishOptions | undefined) => tsl.Rule<unknown>;
91
+ declare const nullish: (options?: nullishOptions | "off" | undefined) => tsl.Rule<unknown>;
92
92
  //#endregion
93
93
  export { noDuplicateExports, noDuplicateImports, noMultilineTemplateExpressionWithoutAutoDedent, nullish };
package/dist/index.js CHANGED
@@ -45,20 +45,21 @@ const noDuplicateExports = defineRule(() => {
45
45
  } }
46
46
  };
47
47
  });
48
- function buildSuggestions$1(a, b) {
48
+ function buildSuggestions$1(existing, incoming) {
49
49
  switch (true) {
50
- case ts.isNamedExports(a.exportClause) && ts.isNamedExports(b.exportClause): {
51
- const aElements = a.exportClause.elements.map((el) => el.getText());
52
- const bElements = b.exportClause.elements.map((el) => el.getText());
53
- const parts = Array.from(new Set([...aElements, ...bElements]));
50
+ case ts.isNamedExports(existing.exportClause) && ts.isNamedExports(incoming.exportClause): {
51
+ const existingElements = existing.exportClause.elements.map((el) => el.getText());
52
+ const incomingElements = incoming.exportClause.elements.map((el) => el.getText());
53
+ const parts = Array.from(new Set([...existingElements, ...incomingElements]));
54
54
  return [{
55
55
  message: "Merge duplicate exports",
56
56
  changes: [{
57
- node: a,
57
+ start: incoming.getFullStart(),
58
+ end: incoming.getEnd(),
58
59
  newText: ""
59
60
  }, {
60
- node: b,
61
- newText: `export ${a.isTypeOnly ? "type " : ""}{ ${parts.join(", ")} } from ${a.moduleSpecifier.getText()};`
61
+ node: existing,
62
+ newText: `export ${existing.isTypeOnly ? "type " : ""}{ ${parts.join(", ")} } from ${existing.moduleSpecifier.getText()};`
62
63
  }]
63
64
  }];
64
65
  }
@@ -129,7 +130,11 @@ const noDuplicateImports = defineRule(() => {
129
130
  };
130
131
  });
131
132
  function buildSuggestions(existing, incoming) {
132
- if (incoming.kind === "defer" || incoming.bindings.kind === "namespace" || existing.bindings.kind === "namespace") return [];
133
+ switch (true) {
134
+ case incoming.kind === "defer" || incoming.bindings.kind === "namespace" || existing.bindings.kind === "namespace": return [];
135
+ case existing.defaultImport != null && incoming.defaultImport != null && existing.defaultImport !== incoming.defaultImport: return [];
136
+ default: break;
137
+ }
133
138
  const parts = [];
134
139
  const defaultImport = existing.defaultImport ?? incoming.defaultImport;
135
140
  if (defaultImport != null) parts.push(defaultImport);
@@ -139,7 +144,8 @@ function buildSuggestions(existing, incoming) {
139
144
  return [{
140
145
  message: "Merge duplicate imports",
141
146
  changes: [{
142
- node: incoming.node,
147
+ start: incoming.node.getFullStart(),
148
+ end: incoming.node.getEnd(),
143
149
  newText: ""
144
150
  }, {
145
151
  node: existing.node,
@@ -148,13 +154,6 @@ function buildSuggestions(existing, incoming) {
148
154
  }];
149
155
  }
150
156
 
151
- //#endregion
152
- //#region src/utils/source-file.ts
153
- function getLine(node) {
154
- const sourceFile = node.getSourceFile();
155
- return [sourceFile.getLineAndCharacterOfPosition(node.getStart()).line, sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line];
156
- }
157
-
158
157
  //#endregion
159
158
  //#region src/rules/no-multiline-template-expression-without-auto-dedent.ts
160
159
  const messages$1 = {
@@ -186,6 +185,10 @@ const messages$1 = {
186
185
  const noMultilineTemplateExpressionWithoutAutoDedent = defineRule((options) => {
187
186
  const dedentTagNames = options?.dedentTagNames ?? ["dedent"];
188
187
  const dedentTagImportCallback = options?.dedentTagImportCallback ?? ((name) => `import ${name} from "dedent";\n`);
188
+ function getLine(node) {
189
+ const sourceFile = node.getSourceFile();
190
+ return [sourceFile.getLineAndCharacterOfPosition(node.getStart()).line, sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line];
191
+ }
189
192
  return {
190
193
  name: "dx/no-multiline-template-expression-without-auto-dedent",
191
194
  visitor: { NoSubstitutionTemplateLiteral(ctx, node) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsl-dx",
3
- "version": "0.9.0",
3
+ "version": "0.10.2",
4
4
  "description": "A tsl plugin for better JavaScript/TypeScript DX.",
5
5
  "keywords": [
6
6
  "tsl",
@@ -25,15 +25,15 @@
25
25
  },
26
26
  "devDependencies": {
27
27
  "@liautaud/typezod": "^2.0.0",
28
- "dedent": "^1.7.1",
29
- "tsdown": "^0.21.0-beta.2",
28
+ "dedent": "^1.7.2",
29
+ "tsdown": "^0.21.4",
30
30
  "tsl": "^1.0.29",
31
- "vitest": "^4.0.18",
31
+ "vitest": "^4.1.0",
32
32
  "@local/configs": "0.0.0",
33
33
  "@local/eff": "0.2.9"
34
34
  },
35
35
  "peerDependencies": {
36
- "tsl": "^1.0.28",
36
+ "tsl": "^1.0.29",
37
37
  "typescript": "*"
38
38
  },
39
39
  "publishConfig": {