eslint-plugin-hyoban 0.2.5 → 0.2.7
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.cjs +6 -5
- package/dist/index.js +6 -5
- package/package.json +6 -21
package/dist/index.cjs
CHANGED
|
@@ -2,15 +2,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2
2
|
|
|
3
3
|
var utils = require('@typescript-eslint/utils');
|
|
4
4
|
|
|
5
|
-
var version = "0.2.
|
|
5
|
+
var version = "0.2.7";
|
|
6
6
|
|
|
7
7
|
const createRule = utils.ESLintUtils.RuleCreator((name)=>`https://github.com/hyoban/eslint-plugin-hyoban/blob/main/src/rules/${name}.`);
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line unused-imports/no-unused-imports
|
|
10
10
|
const expressionTypesNoCheck = new Set([
|
|
11
|
-
utils.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
12
11
|
utils.AST_NODE_TYPES.ConditionalExpression,
|
|
13
|
-
utils.AST_NODE_TYPES.JSXElement
|
|
12
|
+
utils.AST_NODE_TYPES.JSXElement,
|
|
13
|
+
utils.AST_NODE_TYPES.TSAsExpression
|
|
14
14
|
]);
|
|
15
15
|
const rule$1 = createRule({
|
|
16
16
|
name: 'no-extra-space-jsx-expression',
|
|
@@ -29,10 +29,11 @@ const rule$1 = createRule({
|
|
|
29
29
|
create (context) {
|
|
30
30
|
function check(node, isExit) {
|
|
31
31
|
const { expression } = node;
|
|
32
|
-
if (expressionTypesNoCheck.has(expression.type)) return;
|
|
32
|
+
if (expressionTypesNoCheck.has(expression.type) || expression.type === utils.AST_NODE_TYPES.ArrowFunctionExpression && expression.body.type !== utils.AST_NODE_TYPES.BlockStatement) return;
|
|
33
33
|
const containerRange = node.range;
|
|
34
34
|
const expressionRange = expression.range;
|
|
35
|
-
|
|
35
|
+
const noSpace = isExit ? containerRange[1] - expressionRange[1] === 1 : expressionRange[0] - containerRange[0] === 1;
|
|
36
|
+
if (noSpace) return;
|
|
36
37
|
const rangeToRemove = isExit ? [
|
|
37
38
|
expressionRange[1],
|
|
38
39
|
containerRange[1] - 1
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ESLintUtils, AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
2
|
|
|
3
|
-
var version = "0.2.
|
|
3
|
+
var version = "0.2.7";
|
|
4
4
|
|
|
5
5
|
const createRule = ESLintUtils.RuleCreator((name)=>`https://github.com/hyoban/eslint-plugin-hyoban/blob/main/src/rules/${name}.`);
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line unused-imports/no-unused-imports
|
|
8
8
|
const expressionTypesNoCheck = new Set([
|
|
9
|
-
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
10
9
|
AST_NODE_TYPES.ConditionalExpression,
|
|
11
|
-
AST_NODE_TYPES.JSXElement
|
|
10
|
+
AST_NODE_TYPES.JSXElement,
|
|
11
|
+
AST_NODE_TYPES.TSAsExpression
|
|
12
12
|
]);
|
|
13
13
|
const rule$1 = createRule({
|
|
14
14
|
name: 'no-extra-space-jsx-expression',
|
|
@@ -27,10 +27,11 @@ const rule$1 = createRule({
|
|
|
27
27
|
create (context) {
|
|
28
28
|
function check(node, isExit) {
|
|
29
29
|
const { expression } = node;
|
|
30
|
-
if (expressionTypesNoCheck.has(expression.type)) return;
|
|
30
|
+
if (expressionTypesNoCheck.has(expression.type) || expression.type === AST_NODE_TYPES.ArrowFunctionExpression && expression.body.type !== AST_NODE_TYPES.BlockStatement) return;
|
|
31
31
|
const containerRange = node.range;
|
|
32
32
|
const expressionRange = expression.range;
|
|
33
|
-
|
|
33
|
+
const noSpace = isExit ? containerRange[1] - expressionRange[1] === 1 : expressionRange[0] - containerRange[0] === 1;
|
|
34
|
+
if (noSpace) return;
|
|
34
35
|
const rangeToRemove = isExit ? [
|
|
35
36
|
expressionRange[1],
|
|
36
37
|
containerRange[1] - 1
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-hyoban",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.7",
|
|
5
5
|
"packageManager": "pnpm@8.15.4",
|
|
6
6
|
"description": "Prefer early return pattern to clean if else statement",
|
|
7
7
|
"author": {
|
|
@@ -40,34 +40,19 @@
|
|
|
40
40
|
"files": [
|
|
41
41
|
"dist"
|
|
42
42
|
],
|
|
43
|
-
"release-it": {
|
|
44
|
-
"plugins": {
|
|
45
|
-
"release-it-pnpm": {}
|
|
46
|
-
},
|
|
47
|
-
"git": {
|
|
48
|
-
"commitMessage": "chore: release v${version}"
|
|
49
|
-
},
|
|
50
|
-
"hooks": {
|
|
51
|
-
"before:init": [
|
|
52
|
-
"pnpm run lint",
|
|
53
|
-
"pnpm run typecheck",
|
|
54
|
-
"pnpm run test --run"
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
43
|
"dependencies": {
|
|
59
|
-
"@typescript-eslint/utils": "^7.
|
|
44
|
+
"@typescript-eslint/utils": "^7.2.0"
|
|
60
45
|
},
|
|
61
46
|
"devDependencies": {
|
|
62
|
-
"@types/node": "^20.11.
|
|
63
|
-
"@typescript-eslint/rule-tester": "^7.
|
|
47
|
+
"@types/node": "^20.11.27",
|
|
48
|
+
"@typescript-eslint/rule-tester": "^7.2.0",
|
|
64
49
|
"bunchee": "^4.4.8",
|
|
65
50
|
"dedent": "^1.5.1",
|
|
66
51
|
"eslint": "^8.57.0",
|
|
67
|
-
"eslint-config-hyoban": "^0.1
|
|
52
|
+
"eslint-config-hyoban": "^0.2.1",
|
|
68
53
|
"lint-staged": "^15.2.2",
|
|
69
54
|
"release-it": "^17.1.1",
|
|
70
|
-
"release-it-pnpm": "4.0.
|
|
55
|
+
"release-it-pnpm": "4.0.2",
|
|
71
56
|
"simple-git-hooks": "^2.10.0",
|
|
72
57
|
"typescript": "^5.4.2",
|
|
73
58
|
"vitest": "^1.3.1"
|