eslint-plugin-turmag-special-rules 1.0.28 → 1.0.30

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/index.ts ADDED
@@ -0,0 +1,17 @@
1
+ import addVueExtension from 'lib/rules/add-vue-extension.js';
2
+ import importEntitesByColumnOrLine from 'lib/rules/import-entities-by-column-or-line';
3
+ import importRightOrder from 'lib/rules/import-right-order.js';
4
+ import preferTrueAttributeShorthand from 'lib/rules/prefer-true-attribute-shorthand';
5
+ import useShortestAlias from 'lib/rules/use-shortest-alias.js';
6
+ import variableEntitiesByColumnOrLine from 'lib/rules/variable-entities-by-column-or-line.js';
7
+
8
+ export const rules = {
9
+ 'add-vue-extension': addVueExtension,
10
+ 'import-entities-by-column-or-line': importEntitesByColumnOrLine,
11
+ 'import-right-order': importRightOrder,
12
+ 'prefer-true-attribute-shorthand': preferTrueAttributeShorthand,
13
+ 'use-shortest-alias': useShortestAlias,
14
+ 'variable-entities-by-column-or-line': variableEntitiesByColumnOrLine,
15
+ };
16
+
17
+ export default { rules };
@@ -1,4 +1,8 @@
1
- module.exports = {
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
- module.exports = {
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
- module.exports = {
1
+ export default {
2
2
  meta: {
3
3
  fixable: 'code',
4
4
  type: 'suggestion',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eslint-plugin-turmag-special-rules",
3
- "version": "1.0.28",
4
- "type": "commonjs",
3
+ "version": "1.0.30",
4
+ "type": "module",
5
5
  "description": "Special eslint rules for your awesome projects",
6
6
  "keywords": [
7
7
  "eslint",
@@ -9,8 +9,8 @@
9
9
  "eslint-plugin"
10
10
  ],
11
11
  "author": "Pavel",
12
- "main": "./lib/index.js",
13
- "exports": "./lib/index.js",
12
+ "main": "./lib/index.ts",
13
+ "exports": "./lib/index.ts",
14
14
  "files": [
15
15
  "lib"
16
16
  ],
@@ -18,21 +18,28 @@
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": "mocha tests --recursive",
21
+ "test": "jest",
22
22
  "update:eslint-docs": "eslint-doc-generator"
23
23
  },
24
- "dependencies": {
25
- "requireindex": "^1.2.0"
26
- },
24
+ "dependencies": {},
27
25
  "devDependencies": {
28
26
  "@eslint/js": "^9.0.0",
27
+ "@types/jest": "^30.0.0",
28
+ "@vue/compiler-sfc": "^3.5.27",
29
+ "@vue/test-utils": "^2.4.6",
30
+ "@vue/vue3-jest": "^29.2.6",
29
31
  "eslint": "^9.0.0",
30
32
  "eslint-doc-generator": "^1.0.0",
31
33
  "eslint-plugin-eslint-plugin": "^6.0.0",
32
34
  "eslint-plugin-n": "^17.0.0",
35
+ "jest": "^30.2.0",
33
36
  "mocha": "^10.0.0",
34
37
  "npm-run-all2": "^6.1.2",
35
- "vue-eslint-parser": "^9.4.3"
38
+ "ts-jest": "^29.4.6",
39
+ "ts-node": "^10.9.2",
40
+ "typescript": "^5.9.3",
41
+ "typescript-eslint": "^8.54.0",
42
+ "vue-eslint-parser": "^10.2.0"
36
43
  },
37
44
  "engines": {
38
45
  "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
package/lib/index.js DELETED
@@ -1,19 +0,0 @@
1
- /**
2
- * @fileoverview Special eslint rules for your awesome projects
3
- * @author Pavel
4
- */
5
- "use strict";
6
-
7
- //------------------------------------------------------------------------------
8
- // Requirements
9
- //------------------------------------------------------------------------------
10
-
11
- const requireIndex = require("requireindex");
12
-
13
- //------------------------------------------------------------------------------
14
- // Plugin Definition
15
- //------------------------------------------------------------------------------
16
-
17
-
18
- // import all rules in lib/rules
19
- module.exports.rules = requireIndex(`${__dirname}/rules`);