eslint-plugin-turmag-special-rules 1.0.27 → 1.0.29
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/lib/rules/{import-entities-by-column-or-line.js → import-entities-by-column-or-line.ts}
RENAMED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import { Rule } from 'eslint';
|
|
3
|
+
import { TSESTree } from '@typescript-eslint/utils';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
2
6
|
meta: {
|
|
3
7
|
fixable: 'code',
|
|
4
8
|
type: 'suggestion',
|
|
@@ -14,9 +18,10 @@ module.exports = {
|
|
|
14
18
|
properties: { minProperties: { type: 'number' } },
|
|
15
19
|
}],
|
|
16
20
|
},
|
|
21
|
+
// @ts-expect-error create type
|
|
17
22
|
create(context) {
|
|
18
23
|
return {
|
|
19
|
-
ImportDeclaration(node) {
|
|
24
|
+
ImportDeclaration(node: TSESTree.ImportDeclaration) {
|
|
20
25
|
if (!node.specifiers[0]) return;
|
|
21
26
|
if (node.specifiers[0].type === 'ImportDefaultSpecifier') return;
|
|
22
27
|
const minProperties = context.options[0].minProperties;
|
|
@@ -34,12 +39,17 @@ module.exports = {
|
|
|
34
39
|
});
|
|
35
40
|
}
|
|
36
41
|
|
|
37
|
-
const getSpecifiersArr = specifiers => {
|
|
38
|
-
const specifiersArr = [];
|
|
42
|
+
const getSpecifiersArr = (specifiers: TSESTree.ImportSpecifier[]) => {
|
|
43
|
+
const specifiersArr: string[] = [];
|
|
39
44
|
specifiers.forEach(specifier => {
|
|
40
45
|
const localName = specifier.local.name;
|
|
46
|
+
let resultName = localName;
|
|
47
|
+
if ((specifier.imported as TSESTree.Identifier).name !== localName) {
|
|
48
|
+
resultName = `${(specifier.imported as TSESTree.Identifier).name} as ${localName}`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const name = specifier.importKind === 'type' ? `type ${resultName}` : resultName;
|
|
41
52
|
|
|
42
|
-
const name = specifier.importKind === 'type' ? `type ${localName}` : localName;
|
|
43
53
|
specifiersArr.push(name);
|
|
44
54
|
});
|
|
45
55
|
|
|
@@ -50,8 +60,8 @@ module.exports = {
|
|
|
50
60
|
context.report({
|
|
51
61
|
node,
|
|
52
62
|
messageId: 'column',
|
|
53
|
-
fix: fixer => {
|
|
54
|
-
const specifiersArr = getSpecifiersArr(node.specifiers);
|
|
63
|
+
fix: (fixer: Rule.RuleFixer) => {
|
|
64
|
+
const specifiersArr = getSpecifiersArr(node.specifiers as TSESTree.ImportSpecifier[]);
|
|
55
65
|
|
|
56
66
|
const replaceShiftSign = '\n ';
|
|
57
67
|
return fixer.replaceText(node, `import ${isTypedNode ? 'type ' : ''}{${replaceShiftSign}${specifiersArr.join(`,${replaceShiftSign}`)},\n} from '${node.source.value}';`);
|
|
@@ -62,8 +72,8 @@ module.exports = {
|
|
|
62
72
|
context.report({
|
|
63
73
|
node,
|
|
64
74
|
messageId: 'line',
|
|
65
|
-
fix: fixer => {
|
|
66
|
-
const specifiersArr = getSpecifiersArr(node.specifiers);
|
|
75
|
+
fix: (fixer: Rule.RuleFixer) => {
|
|
76
|
+
const specifiersArr = getSpecifiersArr(node.specifiers as TSESTree.ImportSpecifier[]);
|
|
67
77
|
|
|
68
78
|
const replaceShiftSign = ' ';
|
|
69
79
|
return fixer.replaceText(node, `import ${isTypedNode ? 'type ' : ''}{${replaceShiftSign}${specifiersArr.join(`,${replaceShiftSign}`)} } from '${node.source.value}';`);
|
|
@@ -73,4 +83,4 @@ module.exports = {
|
|
|
73
83
|
},
|
|
74
84
|
};
|
|
75
85
|
},
|
|
76
|
-
}
|
|
86
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export default {
|
|
2
2
|
meta: {
|
|
3
3
|
fixable: 'code',
|
|
4
4
|
type: 'suggestion',
|
|
@@ -12,18 +12,19 @@ module.exports = {
|
|
|
12
12
|
},
|
|
13
13
|
schema: [{ enum: ['always', 'never'] }],
|
|
14
14
|
},
|
|
15
|
+
// @ts-expect-error create type
|
|
15
16
|
create(context) {
|
|
16
17
|
const sourceCode = context.getSourceCode();
|
|
17
18
|
return sourceCode.parserServices?.defineTemplateBodyVisitor
|
|
18
19
|
? sourceCode.parserServices.defineTemplateBodyVisitor({
|
|
19
|
-
VAttribute(node) {
|
|
20
|
+
VAttribute(node: { directive: unknown; value: { expression: { value: boolean; }; }; key: { rawName?: unknown; name?: unknown; argument?: unknown; }; }) {
|
|
20
21
|
const option = context.options[0] || 'always';
|
|
21
22
|
|
|
22
23
|
if (option === 'never' && !node.directive && !node.value) {
|
|
23
24
|
context.report({
|
|
24
25
|
node,
|
|
25
26
|
messageId: 'longHand',
|
|
26
|
-
fix: fixer => fixer.replaceText(node, `:${node.key.rawName}="true"`),
|
|
27
|
+
fix: (fixer: { replaceText: (arg0: unknown, arg1: string) => unknown; }) => fixer.replaceText(node, `:${node.key.rawName}="true"`),
|
|
27
28
|
});
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -36,7 +37,7 @@ module.exports = {
|
|
|
36
37
|
context.report({
|
|
37
38
|
node,
|
|
38
39
|
messageId: 'shortHand',
|
|
39
|
-
fix: fixer => {
|
|
40
|
+
fix: (fixer: { replaceText: (arg0: unknown, arg1: unknown) => unknown; }) => {
|
|
40
41
|
const sourceCode = context.getSourceCode();
|
|
41
42
|
return fixer.replaceText(node, sourceCode.getText(argument));
|
|
42
43
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export default {
|
|
2
2
|
meta: {
|
|
3
3
|
fixable: 'code',
|
|
4
4
|
type: 'suggestion',
|
|
@@ -29,7 +29,7 @@ module.exports = {
|
|
|
29
29
|
|
|
30
30
|
let isObjectDestructured = false;
|
|
31
31
|
properties.forEach(property => {
|
|
32
|
-
if (property.value
|
|
32
|
+
if (property.value?.type === 'ObjectPattern') isObjectDestructured = true;
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
if (isObjectDestructured) return;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-turmag-special-rules",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"type": "
|
|
3
|
+
"version": "1.0.29",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"description": "Special eslint rules for your awesome projects",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"eslint",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"lint": "npm-run-all \"lint:*\"",
|
|
19
19
|
"lint:eslint-docs": "npm-run-all \"update:eslint-docs -- --check\"",
|
|
20
20
|
"lint:js": "eslint .",
|
|
21
|
-
"test": "
|
|
21
|
+
"test": "jest",
|
|
22
22
|
"update:eslint-docs": "eslint-doc-generator"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
@@ -26,13 +26,22 @@
|
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@eslint/js": "^9.0.0",
|
|
29
|
+
"@types/jest": "^30.0.0",
|
|
30
|
+
"@vue/compiler-sfc": "^3.5.27",
|
|
31
|
+
"@vue/test-utils": "^2.4.6",
|
|
32
|
+
"@vue/vue3-jest": "^29.2.6",
|
|
29
33
|
"eslint": "^9.0.0",
|
|
30
34
|
"eslint-doc-generator": "^1.0.0",
|
|
31
35
|
"eslint-plugin-eslint-plugin": "^6.0.0",
|
|
32
36
|
"eslint-plugin-n": "^17.0.0",
|
|
37
|
+
"jest": "^30.2.0",
|
|
33
38
|
"mocha": "^10.0.0",
|
|
34
39
|
"npm-run-all2": "^6.1.2",
|
|
35
|
-
"
|
|
40
|
+
"ts-jest": "^29.4.6",
|
|
41
|
+
"ts-node": "^10.9.2",
|
|
42
|
+
"typescript": "^5.9.3",
|
|
43
|
+
"typescript-eslint": "^8.54.0",
|
|
44
|
+
"vue-eslint-parser": "^10.2.0"
|
|
36
45
|
},
|
|
37
46
|
"engines": {
|
|
38
47
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|