tsl-dx 0.10.1 → 0.10.3

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
@@ -1,4 +1,4 @@
1
- import * as tsl from "tsl";
1
+ import * as _$tsl from "tsl";
2
2
 
3
3
  //#region src/rules/no-duplicate-exports.d.ts
4
4
  /**
@@ -17,7 +17,7 @@ import * as tsl from "tsl";
17
17
  * export { A, B } from 'module';
18
18
  * ```
19
19
  */
20
- declare const noDuplicateExports: (options?: "off" | undefined) => tsl.Rule<unknown>;
20
+ declare const noDuplicateExports: (options?: "off" | undefined) => _$tsl.Rule<unknown>;
21
21
  //#endregion
22
22
  //#region src/rules/no-duplicate-imports.d.ts
23
23
  /**
@@ -36,7 +36,7 @@ declare const noDuplicateExports: (options?: "off" | undefined) => tsl.Rule<unkn
36
36
  * import { A, B } from 'module';
37
37
  * ```
38
38
  */
39
- declare const noDuplicateImports: (options?: "off" | undefined) => tsl.Rule<unknown>;
39
+ declare const noDuplicateImports: (options?: "off" | undefined) => _$tsl.Rule<unknown>;
40
40
  //#endregion
41
41
  //#region src/rules/no-multiline-template-expression-without-auto-dedent.d.ts
42
42
  type noMultilineTemplateExpressionWithoutAutoDedentOptions = {
@@ -65,7 +65,7 @@ type noMultilineTemplateExpressionWithoutAutoDedentOptions = {
65
65
  * `;
66
66
  * ```
67
67
  */
68
- declare const noMultilineTemplateExpressionWithoutAutoDedent: (options?: "off" | noMultilineTemplateExpressionWithoutAutoDedentOptions | undefined) => tsl.Rule<unknown>;
68
+ declare const noMultilineTemplateExpressionWithoutAutoDedent: (options?: "off" | noMultilineTemplateExpressionWithoutAutoDedentOptions | undefined) => _$tsl.Rule<unknown>;
69
69
  //#endregion
70
70
  //#region src/rules/nullish.d.ts
71
71
  type nullishOptions = {
@@ -88,6 +88,6 @@ type nullishOptions = {
88
88
  * if (x == null) { }
89
89
  * ```
90
90
  */
91
- declare const nullish: (options?: nullishOptions | "off" | 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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsl-dx",
3
- "version": "0.10.1",
3
+ "version": "0.10.3",
4
4
  "description": "A tsl plugin for better JavaScript/TypeScript DX.",
5
5
  "keywords": [
6
6
  "tsl",
@@ -26,9 +26,9 @@
26
26
  "devDependencies": {
27
27
  "@liautaud/typezod": "^2.0.0",
28
28
  "dedent": "^1.7.2",
29
- "tsdown": "^0.21.2",
30
- "tsl": "^1.0.29",
31
- "vitest": "^4.1.0",
29
+ "tsdown": "^0.21.7",
30
+ "tsl": "^1.0.30",
31
+ "vitest": "^4.1.2",
32
32
  "@local/configs": "0.0.0",
33
33
  "@local/eff": "0.2.9"
34
34
  },