eslint-plugin-hyoban 0.2.8 → 0.4.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/README.md +1 -1
- package/dist/index.cjs +30 -4
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +30 -4
- package/package.json +22 -27
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2
2
|
|
|
3
3
|
var utils = require('@typescript-eslint/utils');
|
|
4
4
|
|
|
5
|
-
var version = "0.
|
|
5
|
+
var version = "0.4.0";
|
|
6
6
|
|
|
7
7
|
const createRule = utils.ESLintUtils.RuleCreator((name)=>`https://github.com/hyoban/eslint-plugin-hyoban/blob/main/src/${name}.ts`);
|
|
8
8
|
|
|
@@ -12,14 +12,15 @@ const expressionTypesNoCheck = new Set([
|
|
|
12
12
|
utils.AST_NODE_TYPES.TSAsExpression
|
|
13
13
|
]);
|
|
14
14
|
const rule$1 = createRule({
|
|
15
|
-
name: '
|
|
15
|
+
name: 'jsx-attribute-spacing',
|
|
16
16
|
meta: {
|
|
17
17
|
type: 'layout',
|
|
18
18
|
fixable: 'whitespace',
|
|
19
19
|
docs: {
|
|
20
|
-
description: '
|
|
20
|
+
description: 'Enforce consistent spacing around JSX attributes'
|
|
21
21
|
},
|
|
22
22
|
messages: {
|
|
23
|
+
jsxAttributeSpacing: 'Expected space before and after JSX attribute',
|
|
23
24
|
noExtraSpaceJsxExpression: 'No extra space in jsx expression'
|
|
24
25
|
},
|
|
25
26
|
schema: []
|
|
@@ -56,6 +57,31 @@ const rule$1 = createRule({
|
|
|
56
57
|
},
|
|
57
58
|
JSXExpressionContainer (node) {
|
|
58
59
|
check(node);
|
|
60
|
+
},
|
|
61
|
+
JSXOpeningElement (node) {
|
|
62
|
+
const { attributes } = node;
|
|
63
|
+
if (attributes.length <= 1) return;
|
|
64
|
+
for (const [index, attribute] of attributes.entries()){
|
|
65
|
+
const nextAttribute = attributes[index + 1];
|
|
66
|
+
if (!nextAttribute) break;
|
|
67
|
+
const isSameLine = attribute.loc.end.line === nextAttribute.loc.start.line;
|
|
68
|
+
if (!isSameLine) continue;
|
|
69
|
+
const { range } = attribute;
|
|
70
|
+
const nextRange = nextAttribute.range;
|
|
71
|
+
const spaceBetween = nextRange[0] - range[1];
|
|
72
|
+
if (spaceBetween !== 1) {
|
|
73
|
+
context.report({
|
|
74
|
+
node: nextAttribute,
|
|
75
|
+
fix (fixer) {
|
|
76
|
+
return fixer.replaceTextRange([
|
|
77
|
+
range[1],
|
|
78
|
+
nextRange[0]
|
|
79
|
+
], ' ');
|
|
80
|
+
},
|
|
81
|
+
messageId: 'jsxAttributeSpacing'
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
59
85
|
}
|
|
60
86
|
};
|
|
61
87
|
}
|
|
@@ -116,7 +142,7 @@ var index = {
|
|
|
116
142
|
},
|
|
117
143
|
rules: {
|
|
118
144
|
'prefer-early-return': rule,
|
|
119
|
-
'
|
|
145
|
+
'jsx-attribute-spacing': rule$1
|
|
120
146
|
}
|
|
121
147
|
};
|
|
122
148
|
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
|
|
3
|
+
type MessageIds = 'jsxAttributeSpacing' | 'noExtraSpaceJsxExpression';
|
|
4
|
+
|
|
3
5
|
declare const _default: {
|
|
4
6
|
meta: {
|
|
5
7
|
name: string;
|
|
@@ -7,7 +9,7 @@ declare const _default: {
|
|
|
7
9
|
};
|
|
8
10
|
rules: {
|
|
9
11
|
'prefer-early-return': _typescript_eslint_utils_ts_eslint.RuleModule<"preferEarlyReturn", [], _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
10
|
-
'
|
|
12
|
+
'jsx-attribute-spacing': _typescript_eslint_utils_ts_eslint.RuleModule<MessageIds, [], _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
11
13
|
};
|
|
12
14
|
};
|
|
13
15
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
|
|
3
|
+
type MessageIds = 'jsxAttributeSpacing' | 'noExtraSpaceJsxExpression';
|
|
4
|
+
|
|
3
5
|
declare const _default: {
|
|
4
6
|
meta: {
|
|
5
7
|
name: string;
|
|
@@ -7,7 +9,7 @@ declare const _default: {
|
|
|
7
9
|
};
|
|
8
10
|
rules: {
|
|
9
11
|
'prefer-early-return': _typescript_eslint_utils_ts_eslint.RuleModule<"preferEarlyReturn", [], _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
10
|
-
'
|
|
12
|
+
'jsx-attribute-spacing': _typescript_eslint_utils_ts_eslint.RuleModule<MessageIds, [], _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
11
13
|
};
|
|
12
14
|
};
|
|
13
15
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ESLintUtils, AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
2
|
|
|
3
|
-
var version = "0.
|
|
3
|
+
var version = "0.4.0";
|
|
4
4
|
|
|
5
5
|
const createRule = ESLintUtils.RuleCreator((name)=>`https://github.com/hyoban/eslint-plugin-hyoban/blob/main/src/${name}.ts`);
|
|
6
6
|
|
|
@@ -10,14 +10,15 @@ const expressionTypesNoCheck = new Set([
|
|
|
10
10
|
AST_NODE_TYPES.TSAsExpression
|
|
11
11
|
]);
|
|
12
12
|
const rule$1 = createRule({
|
|
13
|
-
name: '
|
|
13
|
+
name: 'jsx-attribute-spacing',
|
|
14
14
|
meta: {
|
|
15
15
|
type: 'layout',
|
|
16
16
|
fixable: 'whitespace',
|
|
17
17
|
docs: {
|
|
18
|
-
description: '
|
|
18
|
+
description: 'Enforce consistent spacing around JSX attributes'
|
|
19
19
|
},
|
|
20
20
|
messages: {
|
|
21
|
+
jsxAttributeSpacing: 'Expected space before and after JSX attribute',
|
|
21
22
|
noExtraSpaceJsxExpression: 'No extra space in jsx expression'
|
|
22
23
|
},
|
|
23
24
|
schema: []
|
|
@@ -54,6 +55,31 @@ const rule$1 = createRule({
|
|
|
54
55
|
},
|
|
55
56
|
JSXExpressionContainer (node) {
|
|
56
57
|
check(node);
|
|
58
|
+
},
|
|
59
|
+
JSXOpeningElement (node) {
|
|
60
|
+
const { attributes } = node;
|
|
61
|
+
if (attributes.length <= 1) return;
|
|
62
|
+
for (const [index, attribute] of attributes.entries()){
|
|
63
|
+
const nextAttribute = attributes[index + 1];
|
|
64
|
+
if (!nextAttribute) break;
|
|
65
|
+
const isSameLine = attribute.loc.end.line === nextAttribute.loc.start.line;
|
|
66
|
+
if (!isSameLine) continue;
|
|
67
|
+
const { range } = attribute;
|
|
68
|
+
const nextRange = nextAttribute.range;
|
|
69
|
+
const spaceBetween = nextRange[0] - range[1];
|
|
70
|
+
if (spaceBetween !== 1) {
|
|
71
|
+
context.report({
|
|
72
|
+
node: nextAttribute,
|
|
73
|
+
fix (fixer) {
|
|
74
|
+
return fixer.replaceTextRange([
|
|
75
|
+
range[1],
|
|
76
|
+
nextRange[0]
|
|
77
|
+
], ' ');
|
|
78
|
+
},
|
|
79
|
+
messageId: 'jsxAttributeSpacing'
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
57
83
|
}
|
|
58
84
|
};
|
|
59
85
|
}
|
|
@@ -114,7 +140,7 @@ var index = {
|
|
|
114
140
|
},
|
|
115
141
|
rules: {
|
|
116
142
|
'prefer-early-return': rule,
|
|
117
|
-
'
|
|
143
|
+
'jsx-attribute-spacing': rule$1
|
|
118
144
|
}
|
|
119
145
|
};
|
|
120
146
|
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-hyoban",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.4.0",
|
|
4
5
|
"description": "Hyoban extended ESLint rules.",
|
|
5
|
-
"
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "hyoban",
|
|
8
|
+
"url": "https://github.com/hyoban"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
6
11
|
"homepage": "https://github.com/hyoban/eslint-plugin-hyoban#readme",
|
|
7
|
-
"bugs": "https://github.com/hyoban/eslint-plugin-hyoban/issues",
|
|
8
12
|
"repository": {
|
|
9
13
|
"type": "git",
|
|
10
14
|
"url": "git+https://github.com/hyoban/eslint-plugin-hyoban.git"
|
|
11
15
|
},
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"name": "hyoban",
|
|
15
|
-
"url": "https://github.com/hyoban"
|
|
16
|
-
},
|
|
16
|
+
"bugs": "https://github.com/hyoban/eslint-plugin-hyoban/issues",
|
|
17
|
+
"keywords": [],
|
|
17
18
|
"sideEffects": false,
|
|
18
|
-
"type": "module",
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
21
|
"import": {
|
|
@@ -42,32 +42,27 @@
|
|
|
42
42
|
"files": [
|
|
43
43
|
"dist"
|
|
44
44
|
],
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"eslint": "*"
|
|
47
|
+
},
|
|
45
48
|
"dependencies": {
|
|
46
|
-
"@typescript-eslint/utils": "^7.
|
|
49
|
+
"@typescript-eslint/utils": "^7.8.0"
|
|
47
50
|
},
|
|
48
51
|
"devDependencies": {
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"eslint": "
|
|
55
|
-
"eslint-config-hyoban": "^0.7.1",
|
|
56
|
-
"prettier": "^3.2.5",
|
|
57
|
-
"prettier-plugin-curly": "^0.2.1",
|
|
58
|
-
"prettier-plugin-packagejson": "^2.4.14",
|
|
52
|
+
"@types/node": "^20.12.10",
|
|
53
|
+
"@typescript-eslint/parser": "^7.8.0",
|
|
54
|
+
"bunchee": "^5.1.5",
|
|
55
|
+
"eslint": "^9.2.0",
|
|
56
|
+
"eslint-config-hyoban": "^2.2.5",
|
|
57
|
+
"eslint-vitest-rule-tester": "^0.2.1",
|
|
59
58
|
"typescript": "^5.4.5",
|
|
60
|
-
"vitest": "^1.
|
|
61
|
-
},
|
|
62
|
-
"peerDependencies": {
|
|
63
|
-
"eslint": "*"
|
|
59
|
+
"vitest": "^1.6.0"
|
|
64
60
|
},
|
|
65
|
-
"packageManager": "pnpm@8.15.6",
|
|
66
61
|
"scripts": {
|
|
67
62
|
"build": "bunchee",
|
|
68
63
|
"dev": "bunchee -w",
|
|
69
|
-
"lint": "
|
|
70
|
-
"lint:fix": "
|
|
64
|
+
"lint": "eslint .",
|
|
65
|
+
"lint:fix": "eslint . --fix",
|
|
71
66
|
"test": "vitest",
|
|
72
67
|
"typecheck": "tsc"
|
|
73
68
|
}
|