eslint-plugin-hyoban 0.3.0 → 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/dist/index.cjs CHANGED
@@ -2,69 +2,25 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  var utils = require('@typescript-eslint/utils');
4
4
 
5
- var version = "0.3.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
 
9
- const rule$2 = createRule({
10
- name: 'jsx-attribute-spacing',
11
- meta: {
12
- type: 'layout',
13
- fixable: 'whitespace',
14
- docs: {
15
- description: 'Enforce consistent spacing around JSX attributes'
16
- },
17
- messages: {
18
- jsxAttributeSpacing: 'Expected space before and after JSX attribute'
19
- },
20
- schema: []
21
- },
22
- defaultOptions: [],
23
- create (context) {
24
- return {
25
- JSXOpeningElement (node) {
26
- const { attributes } = node;
27
- if (attributes.length <= 1) return;
28
- for (const [index, attribute] of attributes.entries()){
29
- const nextAttribute = attributes[index + 1];
30
- if (!nextAttribute) break;
31
- const isSameLine = attribute.loc.end.line === nextAttribute.loc.start.line;
32
- if (!isSameLine) continue;
33
- const { range } = attribute;
34
- const nextRange = nextAttribute.range;
35
- const spaceBetween = nextRange[0] - range[1];
36
- if (spaceBetween !== 1) {
37
- context.report({
38
- node: nextAttribute,
39
- fix (fixer) {
40
- return fixer.replaceTextRange([
41
- range[1],
42
- nextRange[0]
43
- ], ' ');
44
- },
45
- messageId: 'jsxAttributeSpacing'
46
- });
47
- }
48
- }
49
- }
50
- };
51
- }
52
- });
53
-
54
9
  const expressionTypesNoCheck = new Set([
55
10
  utils.AST_NODE_TYPES.ConditionalExpression,
56
11
  utils.AST_NODE_TYPES.JSXElement,
57
12
  utils.AST_NODE_TYPES.TSAsExpression
58
13
  ]);
59
14
  const rule$1 = createRule({
60
- name: 'no-extra-space-jsx-expression',
15
+ name: 'jsx-attribute-spacing',
61
16
  meta: {
62
17
  type: 'layout',
63
18
  fixable: 'whitespace',
64
19
  docs: {
65
- description: 'No extra space in jsx expression'
20
+ description: 'Enforce consistent spacing around JSX attributes'
66
21
  },
67
22
  messages: {
23
+ jsxAttributeSpacing: 'Expected space before and after JSX attribute',
68
24
  noExtraSpaceJsxExpression: 'No extra space in jsx expression'
69
25
  },
70
26
  schema: []
@@ -101,6 +57,31 @@ const rule$1 = createRule({
101
57
  },
102
58
  JSXExpressionContainer (node) {
103
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
+ }
104
85
  }
105
86
  };
106
87
  }
@@ -161,8 +142,7 @@ var index = {
161
142
  },
162
143
  rules: {
163
144
  'prefer-early-return': rule,
164
- 'no-extra-space-jsx-expression': rule$1,
165
- 'jsx-attribute-spacing': rule$2
145
+ 'jsx-attribute-spacing': rule$1
166
146
  }
167
147
  };
168
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,8 +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
- 'no-extra-space-jsx-expression': _typescript_eslint_utils_ts_eslint.RuleModule<"noExtraSpaceJsxExpression", [], _typescript_eslint_utils_ts_eslint.RuleListener>;
11
- 'jsx-attribute-spacing': _typescript_eslint_utils_ts_eslint.RuleModule<"jsxAttributeSpacing", [], _typescript_eslint_utils_ts_eslint.RuleListener>;
12
+ 'jsx-attribute-spacing': _typescript_eslint_utils_ts_eslint.RuleModule<MessageIds, [], _typescript_eslint_utils_ts_eslint.RuleListener>;
12
13
  };
13
14
  };
14
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,8 +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
- 'no-extra-space-jsx-expression': _typescript_eslint_utils_ts_eslint.RuleModule<"noExtraSpaceJsxExpression", [], _typescript_eslint_utils_ts_eslint.RuleListener>;
11
- 'jsx-attribute-spacing': _typescript_eslint_utils_ts_eslint.RuleModule<"jsxAttributeSpacing", [], _typescript_eslint_utils_ts_eslint.RuleListener>;
12
+ 'jsx-attribute-spacing': _typescript_eslint_utils_ts_eslint.RuleModule<MessageIds, [], _typescript_eslint_utils_ts_eslint.RuleListener>;
12
13
  };
13
14
  };
14
15
 
package/dist/index.js CHANGED
@@ -1,68 +1,24 @@
1
1
  import { ESLintUtils, AST_NODE_TYPES } from '@typescript-eslint/utils';
2
2
 
3
- var version = "0.3.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
 
7
- const rule$2 = createRule({
8
- name: 'jsx-attribute-spacing',
9
- meta: {
10
- type: 'layout',
11
- fixable: 'whitespace',
12
- docs: {
13
- description: 'Enforce consistent spacing around JSX attributes'
14
- },
15
- messages: {
16
- jsxAttributeSpacing: 'Expected space before and after JSX attribute'
17
- },
18
- schema: []
19
- },
20
- defaultOptions: [],
21
- create (context) {
22
- return {
23
- JSXOpeningElement (node) {
24
- const { attributes } = node;
25
- if (attributes.length <= 1) return;
26
- for (const [index, attribute] of attributes.entries()){
27
- const nextAttribute = attributes[index + 1];
28
- if (!nextAttribute) break;
29
- const isSameLine = attribute.loc.end.line === nextAttribute.loc.start.line;
30
- if (!isSameLine) continue;
31
- const { range } = attribute;
32
- const nextRange = nextAttribute.range;
33
- const spaceBetween = nextRange[0] - range[1];
34
- if (spaceBetween !== 1) {
35
- context.report({
36
- node: nextAttribute,
37
- fix (fixer) {
38
- return fixer.replaceTextRange([
39
- range[1],
40
- nextRange[0]
41
- ], ' ');
42
- },
43
- messageId: 'jsxAttributeSpacing'
44
- });
45
- }
46
- }
47
- }
48
- };
49
- }
50
- });
51
-
52
7
  const expressionTypesNoCheck = new Set([
53
8
  AST_NODE_TYPES.ConditionalExpression,
54
9
  AST_NODE_TYPES.JSXElement,
55
10
  AST_NODE_TYPES.TSAsExpression
56
11
  ]);
57
12
  const rule$1 = createRule({
58
- name: 'no-extra-space-jsx-expression',
13
+ name: 'jsx-attribute-spacing',
59
14
  meta: {
60
15
  type: 'layout',
61
16
  fixable: 'whitespace',
62
17
  docs: {
63
- description: 'No extra space in jsx expression'
18
+ description: 'Enforce consistent spacing around JSX attributes'
64
19
  },
65
20
  messages: {
21
+ jsxAttributeSpacing: 'Expected space before and after JSX attribute',
66
22
  noExtraSpaceJsxExpression: 'No extra space in jsx expression'
67
23
  },
68
24
  schema: []
@@ -99,6 +55,31 @@ const rule$1 = createRule({
99
55
  },
100
56
  JSXExpressionContainer (node) {
101
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
+ }
102
83
  }
103
84
  };
104
85
  }
@@ -159,8 +140,7 @@ var index = {
159
140
  },
160
141
  rules: {
161
142
  'prefer-early-return': rule,
162
- 'no-extra-space-jsx-expression': rule$1,
163
- 'jsx-attribute-spacing': rule$2
143
+ 'jsx-attribute-spacing': rule$1
164
144
  }
165
145
  };
166
146
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eslint-plugin-hyoban",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.4.0",
5
5
  "description": "Hyoban extended ESLint rules.",
6
6
  "author": {
7
7
  "name": "hyoban",