@so1ve/eslint-plugin 4.2.2 → 4.6.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/dist/index.mjs +27 -29
- package/dist/rules/function-style.mjs +2 -7
- package/dist/rules/html-spaced-comment.mjs +2 -7
- package/dist/rules/import-dedupe.mjs +2 -7
- package/dist/rules/import-export-newline.mjs +1 -4
- package/dist/rules/no-import-promises-as.mjs +1 -4
- package/dist/rules/no-inline-type-modifier.mjs +1 -4
- package/dist/rules/no-negated-comparison.mjs +1 -4
- package/dist/rules/no-useless-template-string.mjs +2 -7
- package/dist/rules/prefer-ts-expect-error.mjs +1 -4
- package/dist/rules/require-async-with-await.mjs +2 -7
- package/dist/rules/sort-exports.mjs +1 -4
- package/dist/rules/sort-imports.mjs +1 -4
- package/dist/rules/vue-root-element-sort-attributes.mjs +1 -4
- package/dist/utils/index.mjs +1 -3
- package/dist/utils/sort-imports.mjs +7 -13
- package/package.json +5 -7
package/dist/index.mjs
CHANGED
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
1
|
+
import rule from "./rules/function-style.mjs";
|
|
2
|
+
import rule$1 from "./rules/html-spaced-comment.mjs";
|
|
3
|
+
import rule$2 from "./rules/import-dedupe.mjs";
|
|
4
|
+
import rule$3 from "./rules/import-export-newline.mjs";
|
|
5
|
+
import rule$4 from "./rules/no-import-promises-as.mjs";
|
|
6
|
+
import rule$5 from "./rules/no-inline-type-modifier.mjs";
|
|
7
|
+
import rule$6 from "./rules/no-negated-comparison.mjs";
|
|
8
|
+
import rule$7 from "./rules/no-useless-template-string.mjs";
|
|
9
|
+
import rule$8 from "./rules/prefer-ts-expect-error.mjs";
|
|
10
|
+
import rule$9 from "./rules/require-async-with-await.mjs";
|
|
11
|
+
import rule$10 from "./rules/sort-exports.mjs";
|
|
12
|
+
import rule$11 from "./rules/sort-imports.mjs";
|
|
13
|
+
import rule$12 from "./rules/vue-root-element-sort-attributes.mjs";
|
|
15
14
|
//#region src/index.ts
|
|
16
15
|
var src_default = { rules: {
|
|
17
|
-
"function-style":
|
|
18
|
-
"html-spaced-comment":
|
|
19
|
-
"import-dedupe":
|
|
20
|
-
"import-export-newline":
|
|
21
|
-
"no-import-promises-as":
|
|
22
|
-
"no-inline-type-modifier":
|
|
23
|
-
"no-negated-comparison":
|
|
24
|
-
"no-useless-template-string":
|
|
25
|
-
"prefer-ts-expect-error":
|
|
26
|
-
"require-async-with-await":
|
|
27
|
-
"sort-exports":
|
|
28
|
-
"sort-imports":
|
|
29
|
-
"vue-root-element-sort-attributes":
|
|
16
|
+
"function-style": rule,
|
|
17
|
+
"html-spaced-comment": rule$1,
|
|
18
|
+
"import-dedupe": rule$2,
|
|
19
|
+
"import-export-newline": rule$3,
|
|
20
|
+
"no-import-promises-as": rule$4,
|
|
21
|
+
"no-inline-type-modifier": rule$5,
|
|
22
|
+
"no-negated-comparison": rule$6,
|
|
23
|
+
"no-useless-template-string": rule$7,
|
|
24
|
+
"prefer-ts-expect-error": rule$8,
|
|
25
|
+
"require-async-with-await": rule$9,
|
|
26
|
+
"sort-exports": rule$10,
|
|
27
|
+
"sort-imports": rule$11,
|
|
28
|
+
"vue-root-element-sort-attributes": rule$12
|
|
30
29
|
} };
|
|
31
|
-
|
|
32
30
|
//#endregion
|
|
33
|
-
export { src_default as default };
|
|
31
|
+
export { src_default as default };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { createEslintRule, getPreviousNode } from "../utils/index.mjs";
|
|
2
2
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
3
|
-
|
|
4
|
-
//#region src/rules/function-style.ts
|
|
5
|
-
const RULE_NAME = "function-style";
|
|
6
3
|
const rule = createEslintRule({
|
|
7
|
-
name:
|
|
4
|
+
name: "function-style",
|
|
8
5
|
meta: {
|
|
9
6
|
type: "problem",
|
|
10
7
|
docs: { description: "Enforce function style." },
|
|
@@ -139,7 +136,5 @@ const rule = createEslintRule({
|
|
|
139
136
|
};
|
|
140
137
|
}
|
|
141
138
|
});
|
|
142
|
-
var function_style_default = rule;
|
|
143
|
-
|
|
144
139
|
//#endregion
|
|
145
|
-
export {
|
|
140
|
+
export { rule as default };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { createEslintRule } from "../utils/index.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/rules/html-spaced-comment.ts
|
|
4
|
-
const RULE_NAME = "html-spaced-comment";
|
|
5
2
|
const rule = createEslintRule({
|
|
6
|
-
name:
|
|
3
|
+
name: "html-spaced-comment",
|
|
7
4
|
meta: {
|
|
8
5
|
type: "layout",
|
|
9
6
|
docs: { description: "Enforce consistent spacing in HTML comments" },
|
|
@@ -35,7 +32,5 @@ const rule = createEslintRule({
|
|
|
35
32
|
});
|
|
36
33
|
} })
|
|
37
34
|
});
|
|
38
|
-
var html_spaced_comment_default = rule;
|
|
39
|
-
|
|
40
35
|
//#endregion
|
|
41
|
-
export {
|
|
36
|
+
export { rule as default };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { createEslintRule } from "../utils/index.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/rules/import-dedupe.ts
|
|
4
|
-
const RULE_NAME = "import-dedupe";
|
|
5
2
|
const rule = createEslintRule({
|
|
6
|
-
name:
|
|
3
|
+
name: "import-dedupe",
|
|
7
4
|
meta: {
|
|
8
5
|
type: "problem",
|
|
9
6
|
docs: { description: "Fix duplication in imports." },
|
|
@@ -36,7 +33,5 @@ const rule = createEslintRule({
|
|
|
36
33
|
}
|
|
37
34
|
} })
|
|
38
35
|
});
|
|
39
|
-
var import_dedupe_default = rule;
|
|
40
|
-
|
|
41
36
|
//#endregion
|
|
42
|
-
export {
|
|
37
|
+
export { rule as default };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createEslintRule, getNextNode, getPreviousNode } from "../utils/index.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/rules/import-export-newline.ts
|
|
4
3
|
const RULE_NAME = "import-export-newline";
|
|
5
4
|
const isExportDeclaration = (node) => node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportAllDeclaration";
|
|
@@ -96,7 +95,5 @@ const rule = createEslintRule({
|
|
|
96
95
|
};
|
|
97
96
|
}
|
|
98
97
|
});
|
|
99
|
-
var import_export_newline_default = rule;
|
|
100
|
-
|
|
101
98
|
//#endregion
|
|
102
|
-
export {
|
|
99
|
+
export { rule as default };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createEslintRule } from "../utils/index.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/rules/no-import-promises-as.ts
|
|
4
3
|
const RULE_NAME = "no-import-promises-as";
|
|
5
4
|
const POSSIBLE_IMPORT_SOURCES = [
|
|
@@ -39,7 +38,5 @@ const rule = createEslintRule({
|
|
|
39
38
|
} };
|
|
40
39
|
}
|
|
41
40
|
});
|
|
42
|
-
var no_import_promises_as_default = rule;
|
|
43
|
-
|
|
44
41
|
//#endregion
|
|
45
|
-
export {
|
|
42
|
+
export { rule as default };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createEslintRule } from "../utils/index.mjs";
|
|
2
2
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
3
|
-
|
|
4
3
|
//#region src/rules/no-inline-type-modifier.ts
|
|
5
4
|
const RULE_NAME = "no-inline-type-modifier";
|
|
6
5
|
const getName = (node) => node.type === AST_NODE_TYPES.Identifier ? node.name : node.raw;
|
|
@@ -80,7 +79,5 @@ const rule = createEslintRule({
|
|
|
80
79
|
}
|
|
81
80
|
})
|
|
82
81
|
});
|
|
83
|
-
var no_inline_type_modifier_default = rule;
|
|
84
|
-
|
|
85
82
|
//#endregion
|
|
86
|
-
export {
|
|
83
|
+
export { rule as default };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createEslintRule } from "../utils/index.mjs";
|
|
2
2
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
3
|
-
|
|
4
3
|
//#region src/rules/no-negated-comparison.ts
|
|
5
4
|
const RULE_NAME = "no-negated-comparison";
|
|
6
5
|
const negatedToPositive = {
|
|
@@ -39,7 +38,5 @@ const rule = createEslintRule({
|
|
|
39
38
|
});
|
|
40
39
|
} })
|
|
41
40
|
});
|
|
42
|
-
var no_negated_comparison_default = rule;
|
|
43
|
-
|
|
44
41
|
//#endregion
|
|
45
|
-
export {
|
|
42
|
+
export { rule as default };
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { createEslintRule } from "../utils/index.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/rules/no-useless-template-string.ts
|
|
4
|
-
const RULE_NAME = "no-useless-template-string";
|
|
5
2
|
const rule = createEslintRule({
|
|
6
|
-
name:
|
|
3
|
+
name: "no-useless-template-string",
|
|
7
4
|
meta: {
|
|
8
5
|
type: "problem",
|
|
9
6
|
docs: { description: "No useless template string." },
|
|
@@ -24,7 +21,5 @@ const rule = createEslintRule({
|
|
|
24
21
|
});
|
|
25
22
|
} })
|
|
26
23
|
});
|
|
27
|
-
var no_useless_template_string_default = rule;
|
|
28
|
-
|
|
29
24
|
//#endregion
|
|
30
|
-
export {
|
|
25
|
+
export { rule as default };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createEslintRule } from "../utils/index.mjs";
|
|
2
2
|
import { AST_TOKEN_TYPES } from "@typescript-eslint/utils";
|
|
3
|
-
|
|
4
3
|
//#region src/rules/prefer-ts-expect-error.ts
|
|
5
4
|
const rule = createEslintRule({
|
|
6
5
|
name: "prefer-ts-expect-error",
|
|
@@ -40,7 +39,5 @@ const rule = createEslintRule({
|
|
|
40
39
|
} };
|
|
41
40
|
}
|
|
42
41
|
});
|
|
43
|
-
var prefer_ts_expect_error_default = rule;
|
|
44
|
-
|
|
45
42
|
//#endregion
|
|
46
|
-
export {
|
|
43
|
+
export { rule as default };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { createEslintRule } from "../utils/index.mjs";
|
|
2
2
|
import { TSESTree } from "@typescript-eslint/types";
|
|
3
|
-
|
|
4
|
-
//#region src/rules/require-async-with-await.ts
|
|
5
|
-
const RULE_NAME = "require-async-with-await";
|
|
6
3
|
const rule = createEslintRule({
|
|
7
|
-
name:
|
|
4
|
+
name: "require-async-with-await",
|
|
8
5
|
meta: {
|
|
9
6
|
type: "problem",
|
|
10
7
|
docs: { description: "Require using async keyword with await." },
|
|
@@ -45,7 +42,5 @@ const rule = createEslintRule({
|
|
|
45
42
|
};
|
|
46
43
|
}
|
|
47
44
|
});
|
|
48
|
-
var require_async_with_await_default = rule;
|
|
49
|
-
|
|
50
45
|
//#endregion
|
|
51
|
-
export {
|
|
46
|
+
export { rule as default };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createEslintRule } from "../utils/index.mjs";
|
|
2
2
|
import { extractChunks, getImportExportItems, maybeReportSorting, printSortedItems, printWithSortedSpecifiers, sortImportExportItems } from "../utils/sort-imports.mjs";
|
|
3
|
-
|
|
4
3
|
//#region src/rules/sort-exports.ts
|
|
5
4
|
const RULE_NAME = "sort-exports";
|
|
6
5
|
function isParentWithBody(node) {
|
|
@@ -62,7 +61,5 @@ const rule = createEslintRule({
|
|
|
62
61
|
};
|
|
63
62
|
}
|
|
64
63
|
});
|
|
65
|
-
var sort_exports_default = rule;
|
|
66
|
-
|
|
67
64
|
//#endregion
|
|
68
|
-
export {
|
|
65
|
+
export { rule as default };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createEslintRule } from "../utils/index.mjs";
|
|
2
2
|
import { extractChunks, getImportExportItems, isPunctuator, maybeReportSorting, printSortedItems, sortImportExportItems } from "../utils/sort-imports.mjs";
|
|
3
|
-
|
|
4
3
|
//#region src/rules/sort-imports.ts
|
|
5
4
|
const RULE_NAME = "sort-imports";
|
|
6
5
|
function isParentWithBody(node) {
|
|
@@ -65,7 +64,6 @@ const rule = createEslintRule({
|
|
|
65
64
|
};
|
|
66
65
|
}
|
|
67
66
|
});
|
|
68
|
-
var sort_imports_default = rule;
|
|
69
67
|
function maybeReportChunkSorting(chunk, context, outerGroups, sourceCode) {
|
|
70
68
|
const items = getImportExportItems(chunk.filter(isImport), sourceCode, isSideEffectImport, getSpecifiers);
|
|
71
69
|
const sorted = printSortedItems(makeSortedItems(items, outerGroups), items, sourceCode);
|
|
@@ -99,6 +97,5 @@ function makeSortedItems(items, outerGroups) {
|
|
|
99
97
|
items: rest
|
|
100
98
|
}]].map((groups) => groups.filter((group) => group.items.length > 0)).filter((groups) => groups.length > 0).map((groups) => groups.map((group) => sortImportExportItems(group.items)));
|
|
101
99
|
}
|
|
102
|
-
|
|
103
100
|
//#endregion
|
|
104
|
-
export {
|
|
101
|
+
export { rule as default };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createEslintRule } from "../utils/index.mjs";
|
|
2
|
-
|
|
3
2
|
//#region src/rules/vue-root-element-sort-attributes.ts
|
|
4
3
|
const RULE_NAME = "vue-root-element-sort-attributes";
|
|
5
4
|
const defaultOptions = { script: ["setup", "lang"] };
|
|
@@ -60,7 +59,5 @@ const rule = createEslintRule({
|
|
|
60
59
|
} };
|
|
61
60
|
}
|
|
62
61
|
});
|
|
63
|
-
var vue_root_element_sort_attributes_default = rule;
|
|
64
|
-
|
|
65
62
|
//#endregion
|
|
66
|
-
export {
|
|
63
|
+
export { rule as default };
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/index.ts
|
|
4
3
|
const createEslintRule = ESLintUtils.RuleCreator((ruleName) => ruleName);
|
|
5
4
|
function getSiblingNode(node, offset) {
|
|
@@ -14,6 +13,5 @@ function getSiblingNode(node, offset) {
|
|
|
14
13
|
}
|
|
15
14
|
const getPreviousNode = (node) => getSiblingNode(node, -1);
|
|
16
15
|
const getNextNode = (node) => getSiblingNode(node, 1);
|
|
17
|
-
|
|
18
16
|
//#endregion
|
|
19
|
-
export { createEslintRule, getNextNode, getPreviousNode };
|
|
17
|
+
export { createEslintRule, getNextNode, getPreviousNode };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import natsort from "natsort";
|
|
2
|
-
|
|
3
2
|
//#region src/utils/sort-imports.ts
|
|
4
3
|
const NEWLINE = /(\r?\n)/;
|
|
5
4
|
const hasNewline = (text) => NEWLINE.test(text);
|
|
@@ -139,10 +138,7 @@ function extractChunks(parentNode, isPartOfChunk) {
|
|
|
139
138
|
chunk = [];
|
|
140
139
|
}
|
|
141
140
|
break;
|
|
142
|
-
default: {
|
|
143
|
-
const _never = result;
|
|
144
|
-
throw new Error(`Unknown chunk result: ${String(_never)}`);
|
|
145
|
-
}
|
|
141
|
+
default: throw new Error(`Unknown chunk result: ${String(result)}`);
|
|
146
142
|
}
|
|
147
143
|
lastNode = node;
|
|
148
144
|
}
|
|
@@ -166,11 +162,10 @@ function printSortedItems(sortedItems, originalItems, sourceCode) {
|
|
|
166
162
|
const flattened = flatMap(sortedItems, (groups) => flatMap(groups, (g) => g));
|
|
167
163
|
const lastSortedItem = flattened[flattened.length - 1];
|
|
168
164
|
const lastOriginalItem = originalItems[originalItems.length - 1];
|
|
169
|
-
|
|
165
|
+
return sorted + ((lastSortedItem.needsNewline ? sourceCode.getTokenAfter(lastOriginalItem.node, {
|
|
170
166
|
includeComments: true,
|
|
171
167
|
filter: (token) => token.type !== "Line" && (token.type !== "Block" || token.loc.end.line !== lastOriginalItem.node.loc.end.line)
|
|
172
|
-
}) : void 0;
|
|
173
|
-
return sorted + (nextToken != null && nextToken.loc.start.line === lastOriginalItem.node.loc.end.line ? newline : "");
|
|
168
|
+
}) : void 0)?.loc.start.line === lastOriginalItem.node.loc.end.line ? newline : "");
|
|
174
169
|
}
|
|
175
170
|
const makeEmptyItem = () => ({
|
|
176
171
|
state: "before",
|
|
@@ -326,12 +321,12 @@ function printWithSortedSpecifiers(node, sourceCode, getSpecifiers) {
|
|
|
326
321
|
const lastIndex = sortedItems.length - 1;
|
|
327
322
|
const sorted = flatMap(sortedItems, (item, index) => {
|
|
328
323
|
const previous = index === 0 ? void 0 : sortedItems[index - 1];
|
|
329
|
-
const maybeNewline
|
|
324
|
+
const maybeNewline = previous != null && needsStartingNewline(item.before) && (previous.after.length <= 0 || !isNewline(previous.after[previous.after.length - 1])) ? [{
|
|
330
325
|
type: "Newline",
|
|
331
326
|
code: newline
|
|
332
327
|
}] : [];
|
|
333
328
|
if (index < lastIndex || hasTrailingComma) return [
|
|
334
|
-
...maybeNewline
|
|
329
|
+
...maybeNewline,
|
|
335
330
|
...item.before,
|
|
336
331
|
...item.specifier,
|
|
337
332
|
{
|
|
@@ -343,7 +338,7 @@ function printWithSortedSpecifiers(node, sourceCode, getSpecifiers) {
|
|
|
343
338
|
const nonBlankIndex = item.after.findIndex((token) => !isNewline(token) && !isSpaces(token));
|
|
344
339
|
const after = item.hadComma ? nonBlankIndex === -1 ? [] : item.after.slice(nonBlankIndex) : item.after;
|
|
345
340
|
return [
|
|
346
|
-
...maybeNewline
|
|
341
|
+
...maybeNewline,
|
|
347
342
|
...item.before,
|
|
348
343
|
...item.specifier,
|
|
349
344
|
...after
|
|
@@ -412,6 +407,5 @@ function getImportExportItems(passedChunk, sourceCode, isSideEffectImport, getSp
|
|
|
412
407
|
};
|
|
413
408
|
});
|
|
414
409
|
}
|
|
415
|
-
|
|
416
410
|
//#endregion
|
|
417
|
-
export { extractChunks, getImportExportItems, isPunctuator, maybeReportSorting, printSortedItems, printWithSortedSpecifiers, sortImportExportItems };
|
|
411
|
+
export { extractChunks, getImportExportItems, isPunctuator, maybeReportSorting, printSortedItems, printWithSortedSpecifiers, sortImportExportItems };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@so1ve/eslint-plugin",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"author": "Ray <i@mk1.io> (https://github.com/so1ve/)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -21,8 +21,6 @@
|
|
|
21
21
|
".": "./dist/index.mjs",
|
|
22
22
|
"./package.json": "./package.json"
|
|
23
23
|
},
|
|
24
|
-
"main": "./dist/index.mjs",
|
|
25
|
-
"module": "./dist/index.mjs",
|
|
26
24
|
"types": "./dist/index.d.mts",
|
|
27
25
|
"files": [
|
|
28
26
|
"dist"
|
|
@@ -31,12 +29,12 @@
|
|
|
31
29
|
"access": "public"
|
|
32
30
|
},
|
|
33
31
|
"dependencies": {
|
|
34
|
-
"@typescript-eslint/types": "^8.
|
|
35
|
-
"@typescript-eslint/utils": "^8.
|
|
32
|
+
"@typescript-eslint/types": "^8.61.0",
|
|
33
|
+
"@typescript-eslint/utils": "^8.61.0",
|
|
36
34
|
"natsort": "^2.0.3"
|
|
37
35
|
},
|
|
38
36
|
"devDependencies": {
|
|
39
|
-
"@html-eslint/parser": "^0.
|
|
40
|
-
"vue-eslint-parser": "^10.
|
|
37
|
+
"@html-eslint/parser": "^0.61.0",
|
|
38
|
+
"vue-eslint-parser": "^10.4.1"
|
|
41
39
|
}
|
|
42
40
|
}
|