@tai-kun/vp-lint-plugins 0.0.0 → 0.0.2

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.
Files changed (107) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -43
  3. package/dist/src/index.d.ts +22 -0
  4. package/dist/src/index.d.ts.map +1 -0
  5. package/dist/src/index.js +21 -0
  6. package/dist/src/plugin.d.ts +3 -0
  7. package/dist/src/plugin.d.ts.map +1 -0
  8. package/dist/src/plugin.js +46 -0
  9. package/dist/src/rules/blank-line-after-control-block.d.ts +7 -0
  10. package/dist/src/rules/blank-line-after-control-block.d.ts.map +1 -0
  11. package/dist/src/rules/blank-line-after-control-block.js +54 -0
  12. package/dist/src/rules/blank-line-after-declaration.d.ts +7 -0
  13. package/dist/src/rules/blank-line-after-declaration.d.ts.map +1 -0
  14. package/dist/src/rules/blank-line-after-declaration.js +79 -0
  15. package/dist/src/rules/blank-line-after-variable-declaration.d.ts +9 -0
  16. package/dist/src/rules/blank-line-after-variable-declaration.d.ts.map +1 -0
  17. package/dist/src/rules/blank-line-after-variable-declaration.js +118 -0
  18. package/dist/src/rules/blank-line-before-return.d.ts +7 -0
  19. package/dist/src/rules/blank-line-before-return.d.ts.map +1 -0
  20. package/dist/src/rules/blank-line-before-return.js +81 -0
  21. package/dist/src/rules/blank-line-between-class-members.d.ts +8 -0
  22. package/dist/src/rules/blank-line-between-class-members.d.ts.map +1 -0
  23. package/dist/src/rules/blank-line-between-class-members.js +85 -0
  24. package/dist/src/rules/blank-line-between-switch-cases.d.ts +8 -0
  25. package/dist/src/rules/blank-line-between-switch-cases.d.ts.map +1 -0
  26. package/dist/src/rules/blank-line-between-switch-cases.js +45 -0
  27. package/dist/src/rules/blank-line.d.ts +18 -0
  28. package/dist/src/rules/blank-line.d.ts.map +1 -0
  29. package/dist/src/rules/blank-line.js +86 -0
  30. package/dist/src/rules/comment-japanese-spacing.d.ts +8 -0
  31. package/dist/src/rules/comment-japanese-spacing.d.ts.map +1 -0
  32. package/dist/src/rules/comment-japanese-spacing.js +195 -0
  33. package/dist/src/rules/comment-one-sentence-per-line.d.ts +9 -0
  34. package/dist/src/rules/comment-one-sentence-per-line.d.ts.map +1 -0
  35. package/dist/src/rules/comment-one-sentence-per-line.js +190 -0
  36. package/dist/src/rules/comment-utils.d.ts +30 -0
  37. package/dist/src/rules/comment-utils.d.ts.map +1 -0
  38. package/dist/src/rules/comment-utils.js +153 -0
  39. package/dist/src/rules/jsdoc-param-order.d.ts +6 -0
  40. package/dist/src/rules/jsdoc-param-order.d.ts.map +1 -0
  41. package/dist/src/rules/jsdoc-param-order.js +101 -0
  42. package/dist/src/rules/jsdoc-tag-lines.d.ts +6 -0
  43. package/dist/src/rules/jsdoc-tag-lines.d.ts.map +1 -0
  44. package/dist/src/rules/jsdoc-tag-lines.js +128 -0
  45. package/dist/src/rules/jsdoc-tag-order.d.ts +6 -0
  46. package/dist/src/rules/jsdoc-tag-order.d.ts.map +1 -0
  47. package/dist/src/rules/jsdoc-tag-order.js +62 -0
  48. package/dist/src/rules/jsdoc-utils.d.ts +26 -0
  49. package/dist/src/rules/jsdoc-utils.d.ts.map +1 -0
  50. package/dist/src/rules/jsdoc-utils.js +132 -0
  51. package/dist/src/rules/member-ordering.d.ts +6 -0
  52. package/dist/src/rules/member-ordering.d.ts.map +1 -0
  53. package/dist/src/rules/member-ordering.js +66 -0
  54. package/dist/src/rules/object-properties-newline.d.ts +9 -0
  55. package/dist/src/rules/object-properties-newline.d.ts.map +1 -0
  56. package/dist/src/rules/object-properties-newline.js +47 -0
  57. package/dist/src/rules/object-sort-utils.d.ts +32 -0
  58. package/dist/src/rules/object-sort-utils.d.ts.map +1 -0
  59. package/dist/src/rules/object-sort-utils.js +221 -0
  60. package/dist/src/rules/overload-signatures-adjacent.d.ts +6 -0
  61. package/dist/src/rules/overload-signatures-adjacent.d.ts.map +1 -0
  62. package/dist/src/rules/overload-signatures-adjacent.js +128 -0
  63. package/dist/src/rules/sort-import-export-specifiers.d.ts +8 -0
  64. package/dist/src/rules/sort-import-export-specifiers.d.ts.map +1 -0
  65. package/dist/src/rules/sort-import-export-specifiers.js +130 -0
  66. package/dist/src/rules/sort-jsx-props.d.ts +7 -0
  67. package/dist/src/rules/sort-jsx-props.d.ts.map +1 -0
  68. package/dist/src/rules/sort-jsx-props.js +102 -0
  69. package/dist/src/rules/sort-object-properties.d.ts +9 -0
  70. package/dist/src/rules/sort-object-properties.d.ts.map +1 -0
  71. package/dist/src/rules/sort-object-properties.js +54 -0
  72. package/dist/src/rules/sort-type-members.d.ts +8 -0
  73. package/dist/src/rules/sort-type-members.d.ts.map +1 -0
  74. package/dist/src/rules/sort-type-members.js +213 -0
  75. package/dist/src/rules/spaced-comment.d.ts +6 -0
  76. package/dist/src/rules/spaced-comment.d.ts.map +1 -0
  77. package/dist/src/rules/spaced-comment.js +105 -0
  78. package/dist/src/rules/type-literal-properties-newline.d.ts +8 -0
  79. package/dist/src/rules/type-literal-properties-newline.d.ts.map +1 -0
  80. package/dist/src/rules/type-literal-properties-newline.js +39 -0
  81. package/package.json +40 -8
  82. package/src/index.ts +22 -0
  83. package/src/plugin.ts +48 -0
  84. package/src/rules/blank-line-after-control-block.ts +82 -0
  85. package/src/rules/blank-line-after-declaration.ts +106 -0
  86. package/src/rules/blank-line-after-variable-declaration.ts +165 -0
  87. package/src/rules/blank-line-before-return.ts +101 -0
  88. package/src/rules/blank-line-between-class-members.ts +112 -0
  89. package/src/rules/blank-line-between-switch-cases.ts +53 -0
  90. package/src/rules/blank-line.ts +143 -0
  91. package/src/rules/comment-japanese-spacing.ts +271 -0
  92. package/src/rules/comment-one-sentence-per-line.ts +263 -0
  93. package/src/rules/comment-utils.ts +218 -0
  94. package/src/rules/jsdoc-param-order.ts +137 -0
  95. package/src/rules/jsdoc-tag-lines.ts +165 -0
  96. package/src/rules/jsdoc-tag-order.ts +75 -0
  97. package/src/rules/jsdoc-utils.ts +178 -0
  98. package/src/rules/member-ordering.ts +93 -0
  99. package/src/rules/object-properties-newline.ts +54 -0
  100. package/src/rules/object-sort-utils.ts +338 -0
  101. package/src/rules/overload-signatures-adjacent.ts +178 -0
  102. package/src/rules/sort-import-export-specifiers.ts +194 -0
  103. package/src/rules/sort-jsx-props.ts +148 -0
  104. package/src/rules/sort-object-properties.ts +62 -0
  105. package/src/rules/sort-type-members.ts +299 -0
  106. package/src/rules/spaced-comment.ts +127 -0
  107. package/src/rules/type-literal-properties-newline.ts +44 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026-present, tai-kun
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,3 @@
1
1
  # @tai-kun/vp-lint-plugins
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
4
-
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@tai-kun/vp-lint-plugins`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**
3
+ [Document](https://tai-kun.github.io/vp-lint-plugins/)
@@ -0,0 +1,22 @@
1
+ export { default as blankLineAfterControlBlock } from "./rules/blank-line-after-control-block.js";
2
+ export { default as blankLineAfterDeclaration } from "./rules/blank-line-after-declaration.js";
3
+ export { default as blankLineAfterVariableDeclaration } from "./rules/blank-line-after-variable-declaration.js";
4
+ export { default as blankLineBeforeReturn } from "./rules/blank-line-before-return.js";
5
+ export { default as blankLineBetweenClassMembers } from "./rules/blank-line-between-class-members.js";
6
+ export { default as blankLineBetweenSwitchCases } from "./rules/blank-line-between-switch-cases.js";
7
+ export { default as commentJapaneseSpacing } from "./rules/comment-japanese-spacing.js";
8
+ export { default as commentOneSentencePerLine } from "./rules/comment-one-sentence-per-line.js";
9
+ export { default as jsdocParamOrder } from "./rules/jsdoc-param-order.js";
10
+ export { default as jsdocTagLines } from "./rules/jsdoc-tag-lines.js";
11
+ export { default as jsdocTagOrder } from "./rules/jsdoc-tag-order.js";
12
+ export { default as memberOrdering } from "./rules/member-ordering.js";
13
+ export { default as objectPropertiesNewline } from "./rules/object-properties-newline.js";
14
+ export { default as overloadSignaturesAdjacent } from "./rules/overload-signatures-adjacent.js";
15
+ export { default as sortImportExportSpecifiers } from "./rules/sort-import-export-specifiers.js";
16
+ export { default as sortJsxProps } from "./rules/sort-jsx-props.js";
17
+ export { default as sortObjectProperties } from "./rules/sort-object-properties.js";
18
+ export { default as sortTypeMembers } from "./rules/sort-type-members.js";
19
+ export { default as spacedComment } from "./rules/spaced-comment.js";
20
+ export { default as typeLiteralPropertiesNewline } from "./rules/type-literal-properties-newline.js";
21
+ export { default } from "./plugin.js";
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AAClG,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAC/F,OAAO,EAAE,OAAO,IAAI,iCAAiC,EAAE,MAAM,kDAAkD,CAAC;AAChH,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AACvF,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AACtG,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACpG,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AAChG,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC1F,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAChG,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACjG,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAErG,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,21 @@
1
+ export { default as blankLineAfterControlBlock } from "./rules/blank-line-after-control-block.js";
2
+ export { default as blankLineAfterDeclaration } from "./rules/blank-line-after-declaration.js";
3
+ export { default as blankLineAfterVariableDeclaration } from "./rules/blank-line-after-variable-declaration.js";
4
+ export { default as blankLineBeforeReturn } from "./rules/blank-line-before-return.js";
5
+ export { default as blankLineBetweenClassMembers } from "./rules/blank-line-between-class-members.js";
6
+ export { default as blankLineBetweenSwitchCases } from "./rules/blank-line-between-switch-cases.js";
7
+ export { default as commentJapaneseSpacing } from "./rules/comment-japanese-spacing.js";
8
+ export { default as commentOneSentencePerLine } from "./rules/comment-one-sentence-per-line.js";
9
+ export { default as jsdocParamOrder } from "./rules/jsdoc-param-order.js";
10
+ export { default as jsdocTagLines } from "./rules/jsdoc-tag-lines.js";
11
+ export { default as jsdocTagOrder } from "./rules/jsdoc-tag-order.js";
12
+ export { default as memberOrdering } from "./rules/member-ordering.js";
13
+ export { default as objectPropertiesNewline } from "./rules/object-properties-newline.js";
14
+ export { default as overloadSignaturesAdjacent } from "./rules/overload-signatures-adjacent.js";
15
+ export { default as sortImportExportSpecifiers } from "./rules/sort-import-export-specifiers.js";
16
+ export { default as sortJsxProps } from "./rules/sort-jsx-props.js";
17
+ export { default as sortObjectProperties } from "./rules/sort-object-properties.js";
18
+ export { default as sortTypeMembers } from "./rules/sort-type-members.js";
19
+ export { default as spacedComment } from "./rules/spaced-comment.js";
20
+ export { default as typeLiteralPropertiesNewline } from "./rules/type-literal-properties-newline.js";
21
+ export { default } from "./plugin.js";
@@ -0,0 +1,3 @@
1
+ declare const _default: import("vite-plus/lint/plugins").Plugin;
2
+ export default _default;
3
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":""}
@@ -0,0 +1,46 @@
1
+ import { definePlugin } from "vite-plus/lint/plugins";
2
+ import blankLineAfterControlBlock from "./rules/blank-line-after-control-block.js";
3
+ import blankLineAfterDeclaration from "./rules/blank-line-after-declaration.js";
4
+ import blankLineAfterVariableDeclaration from "./rules/blank-line-after-variable-declaration.js";
5
+ import blankLineBeforeReturn from "./rules/blank-line-before-return.js";
6
+ import blankLineBetweenClassMembers from "./rules/blank-line-between-class-members.js";
7
+ import blankLineBetweenSwitchCases from "./rules/blank-line-between-switch-cases.js";
8
+ import commentJapaneseSpacing from "./rules/comment-japanese-spacing.js";
9
+ import commentOneSentencePerLine from "./rules/comment-one-sentence-per-line.js";
10
+ import jsdocParamOrder from "./rules/jsdoc-param-order.js";
11
+ import jsdocTagLines from "./rules/jsdoc-tag-lines.js";
12
+ import jsdocTagOrder from "./rules/jsdoc-tag-order.js";
13
+ import memberOrdering from "./rules/member-ordering.js";
14
+ import objectPropertiesNewline from "./rules/object-properties-newline.js";
15
+ import overloadSignaturesAdjacent from "./rules/overload-signatures-adjacent.js";
16
+ import sortImportExportSpecifiers from "./rules/sort-import-export-specifiers.js";
17
+ import sortJsxProps from "./rules/sort-jsx-props.js";
18
+ import sortObjectProperties from "./rules/sort-object-properties.js";
19
+ import sortTypeMembers from "./rules/sort-type-members.js";
20
+ import spacedComment from "./rules/spaced-comment.js";
21
+ import typeLiteralPropertiesNewline from "./rules/type-literal-properties-newline.js";
22
+ export default definePlugin({
23
+ meta: { name: "tai-kun" },
24
+ rules: {
25
+ "sort-jsx-props": sortJsxProps,
26
+ "spaced-comment": spacedComment,
27
+ "jsdoc-tag-lines": jsdocTagLines,
28
+ "jsdoc-tag-order": jsdocTagOrder,
29
+ "member-ordering": memberOrdering,
30
+ "jsdoc-param-order": jsdocParamOrder,
31
+ "sort-type-members": sortTypeMembers,
32
+ "sort-object-properties": sortObjectProperties,
33
+ "blank-line-before-return": blankLineBeforeReturn,
34
+ "comment-japanese-spacing": commentJapaneseSpacing,
35
+ "object-properties-newline": objectPropertiesNewline,
36
+ "blank-line-after-declaration": blankLineAfterDeclaration,
37
+ "overload-signatures-adjacent": overloadSignaturesAdjacent,
38
+ "comment-one-sentence-per-line": commentOneSentencePerLine,
39
+ "sort-import-export-specifiers": sortImportExportSpecifiers,
40
+ "blank-line-after-control-block": blankLineAfterControlBlock,
41
+ "blank-line-between-switch-cases": blankLineBetweenSwitchCases,
42
+ "type-literal-properties-newline": typeLiteralPropertiesNewline,
43
+ "blank-line-between-class-members": blankLineBetweenClassMembers,
44
+ "blank-line-after-variable-declaration": blankLineAfterVariableDeclaration,
45
+ },
46
+ });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 制御ブロックの直後に次の処理がある場合、空行を 1 行以上確保します。
3
+ * 余分な空行は Oxfmt が 1 行に畳みます。
4
+ */
5
+ declare const blankLineAfterControlBlock: import("vite-plus/lint/plugins").Rule;
6
+ export default blankLineAfterControlBlock;
7
+ //# sourceMappingURL=blank-line-after-control-block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blank-line-after-control-block.d.ts","sourceRoot":"","sources":["../../../src/rules/blank-line-after-control-block.ts"],"names":[],"mappings":"AA+BA;;;GAGG;AACH,QAAA,MAAM,0BAA0B,uCA4C9B,CAAC;eAEY,0BAA0B"}
@@ -0,0 +1,54 @@
1
+ import { defineRule } from "vite-plus/lint/plugins";
2
+ import { hasBlankLine, getBlankLineFix, getNextStatement, getInsertionTarget, } from "./blank-line.js";
3
+ const CONTROL_STATEMENT_TYPES = new Set([
4
+ "DoWhileStatement",
5
+ "ForInStatement",
6
+ "ForOfStatement",
7
+ "ForStatement",
8
+ "IfStatement",
9
+ "SwitchStatement",
10
+ "TryStatement",
11
+ "WhileStatement",
12
+ ]);
13
+ /**
14
+ * 制御ブロックの直後に次の処理がある場合、空行を 1 行以上確保します。
15
+ * 余分な空行は Oxfmt が 1 行に畳みます。
16
+ */
17
+ const blankLineAfterControlBlock = defineRule({
18
+ meta: {
19
+ docs: {
20
+ description: "Require a blank line after a control block when another statement follows.",
21
+ },
22
+ type: "layout",
23
+ fixable: "whitespace",
24
+ messages: {
25
+ blankLine: "Expected a blank line after a control block when another statement follows.",
26
+ },
27
+ },
28
+ create(context) {
29
+ const sourceCode = context.sourceCode;
30
+ function checkNode(node) {
31
+ const nextStatement = getNextStatement(node);
32
+ if (nextStatement === null || nextStatement.type === "EmptyStatement") {
33
+ return;
34
+ }
35
+ const target = getInsertionTarget(node, nextStatement, sourceCode);
36
+ if (hasBlankLine(node, target)) {
37
+ return;
38
+ }
39
+ context.report({
40
+ fix(fixer) {
41
+ return getBlankLineFix(fixer, sourceCode, node, target);
42
+ },
43
+ node,
44
+ messageId: "blankLine",
45
+ });
46
+ }
47
+ const visitors = {};
48
+ for (const type of CONTROL_STATEMENT_TYPES) {
49
+ visitors[type] = checkNode;
50
+ }
51
+ return visitors;
52
+ },
53
+ });
54
+ export default blankLineAfterControlBlock;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 関数・クラス・型などの宣言の後に次の文がある場合、空行を 1 行以上確保します。
3
+ * 余分な空行は Oxfmt が 1 行に畳みます。
4
+ */
5
+ declare const blankLineAfterDeclaration: import("vite-plus/lint/plugins").Rule;
6
+ export default blankLineAfterDeclaration;
7
+ //# sourceMappingURL=blank-line-after-declaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blank-line-after-declaration.d.ts","sourceRoot":"","sources":["../../../src/rules/blank-line-after-declaration.ts"],"names":[],"mappings":"AA2CA;;;GAGG;AACH,QAAA,MAAM,yBAAyB,uCAwD7B,CAAC;eAEY,yBAAyB"}
@@ -0,0 +1,79 @@
1
+ import { defineRule } from "vite-plus/lint/plugins";
2
+ import { hasBlankLine, getBlankLineFix, getNextStatement, getInsertionTarget, } from "./blank-line.js";
3
+ const DECLARATION_TYPES = new Set([
4
+ "ClassDeclaration",
5
+ "FunctionDeclaration",
6
+ "TSDeclareFunction",
7
+ "TSEnumDeclaration",
8
+ "TSInterfaceDeclaration",
9
+ "TSModuleDeclaration",
10
+ "TSTypeAliasDeclaration",
11
+ ]);
12
+ function getDeclaration(node) {
13
+ if (DECLARATION_TYPES.has(node.type)) {
14
+ return node;
15
+ }
16
+ if ((node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration") &&
17
+ node.declaration !== null &&
18
+ DECLARATION_TYPES.has(node.declaration.type)) {
19
+ return node.declaration;
20
+ }
21
+ return null;
22
+ }
23
+ function isOverload(declaration) {
24
+ return ((declaration.type === "FunctionDeclaration" || declaration.type === "TSDeclareFunction") &&
25
+ declaration.body === null);
26
+ }
27
+ /**
28
+ * 関数・クラス・型などの宣言の後に次の文がある場合、空行を 1 行以上確保します。
29
+ * 余分な空行は Oxfmt が 1 行に畳みます。
30
+ */
31
+ const blankLineAfterDeclaration = defineRule({
32
+ meta: {
33
+ docs: {
34
+ description: "Require a blank line after a declaration when another statement follows.",
35
+ },
36
+ type: "layout",
37
+ fixable: "whitespace",
38
+ messages: {
39
+ blankLine: "Expected a blank line after a declaration when another statement follows.",
40
+ },
41
+ },
42
+ create(context) {
43
+ const sourceCode = context.sourceCode;
44
+ function checkNode(node) {
45
+ const declaration = getDeclaration(node);
46
+ if (declaration === null || isOverload(declaration)) {
47
+ return;
48
+ }
49
+ const nextStatement = getNextStatement(node);
50
+ if (nextStatement === null || nextStatement.type === "EmptyStatement") {
51
+ return;
52
+ }
53
+ const target = getInsertionTarget(node, nextStatement, sourceCode);
54
+ if (hasBlankLine(node, target)) {
55
+ return;
56
+ }
57
+ context.report({
58
+ fix(fixer) {
59
+ return getBlankLineFix(fixer, sourceCode, node, target);
60
+ },
61
+ node,
62
+ messageId: "blankLine",
63
+ });
64
+ }
65
+ const visitors = {
66
+ ClassDeclaration: checkNode,
67
+ TSDeclareFunction: checkNode,
68
+ TSEnumDeclaration: checkNode,
69
+ FunctionDeclaration: checkNode,
70
+ TSModuleDeclaration: checkNode,
71
+ ExportNamedDeclaration: checkNode,
72
+ TSInterfaceDeclaration: checkNode,
73
+ TSTypeAliasDeclaration: checkNode,
74
+ ExportDefaultDeclaration: checkNode,
75
+ };
76
+ return visitors;
77
+ },
78
+ });
79
+ export default blankLineAfterDeclaration;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 連続する変数宣言の後に別の種類の文が続く場合、空行を 1 行以上確保します。
3
+ *
4
+ * 宣言した変数を使う式文は同じ宣言グループとして扱い、グループ内の空行は削除します。
5
+ * return の直前は blank-line-before-return が担当するため対象外にします。
6
+ */
7
+ declare const blankLineAfterVariableDeclaration: import("vite-plus/lint/plugins").Rule;
8
+ export default blankLineAfterVariableDeclaration;
9
+ //# sourceMappingURL=blank-line-after-variable-declaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blank-line-after-variable-declaration.d.ts","sourceRoot":"","sources":["../../../src/rules/blank-line-after-variable-declaration.ts"],"names":[],"mappings":"AA8CA;;;;;GAKG;AACH,QAAA,MAAM,iCAAiC,uCA8GrC,CAAC;eAEY,iCAAiC"}
@@ -0,0 +1,118 @@
1
+ import { defineRule } from "vite-plus/lint/plugins";
2
+ import { hasBlankLine, getBlankLineFix, getNextStatement, getInsertionTarget, getPreviousStatement, getRemoveBlankLineFix, } from "./blank-line.js";
3
+ function getVariableDeclaration(node) {
4
+ if (node.type === "VariableDeclaration") {
5
+ return node;
6
+ }
7
+ if (node.type === "ExportNamedDeclaration" && node.declaration?.type === "VariableDeclaration") {
8
+ return node.declaration;
9
+ }
10
+ return null;
11
+ }
12
+ function isRelatedExpression(statement, variables) {
13
+ if (statement.type !== "ExpressionStatement") {
14
+ return false;
15
+ }
16
+ for (const variable of variables) {
17
+ for (const reference of variable.references) {
18
+ if (reference.identifier.range[0] >= statement.range[0] &&
19
+ reference.identifier.range[1] <= statement.range[1]) {
20
+ return true;
21
+ }
22
+ }
23
+ }
24
+ return false;
25
+ }
26
+ /**
27
+ * 連続する変数宣言の後に別の種類の文が続く場合、空行を 1 行以上確保します。
28
+ *
29
+ * 宣言した変数を使う式文は同じ宣言グループとして扱い、グループ内の空行は削除します。
30
+ * return の直前は blank-line-before-return が担当するため対象外にします。
31
+ */
32
+ const blankLineAfterVariableDeclaration = defineRule({
33
+ meta: {
34
+ docs: {
35
+ description: "Require a blank line after a variable declaration group and remove blank lines before related statements.",
36
+ },
37
+ type: "layout",
38
+ fixable: "whitespace",
39
+ messages: {
40
+ blankLine: "Expected a blank line after a variable declaration group when another statement follows.",
41
+ unexpectedBlankLine: "Expected no blank line between a variable declaration and its related statement.",
42
+ },
43
+ },
44
+ create(context) {
45
+ const sourceCode = context.sourceCode;
46
+ function checkStatement(node) {
47
+ const variableDeclaration = getVariableDeclaration(node);
48
+ if (variableDeclaration === null) {
49
+ return;
50
+ }
51
+ if (node.type === "VariableDeclaration" && node.parent.type === "ExportNamedDeclaration") {
52
+ return;
53
+ }
54
+ const previousStatement = getPreviousStatement(node);
55
+ if (previousStatement !== null && getVariableDeclaration(previousStatement) !== null) {
56
+ return;
57
+ }
58
+ const variables = new Set(sourceCode.getDeclaredVariables(variableDeclaration));
59
+ let last = node;
60
+ let nextStatement = getNextStatement(last);
61
+ while (nextStatement !== null) {
62
+ const nextVariableDeclaration = getVariableDeclaration(nextStatement);
63
+ if (nextVariableDeclaration !== null && getVariableDeclaration(last) !== null) {
64
+ for (const variable of sourceCode.getDeclaredVariables(nextVariableDeclaration)) {
65
+ variables.add(variable);
66
+ }
67
+ last = nextStatement;
68
+ nextStatement = getNextStatement(last);
69
+ continue;
70
+ }
71
+ if (nextStatement.type === "ExpressionStatement" &&
72
+ isRelatedExpression(nextStatement, variables)) {
73
+ const target = getInsertionTarget(last, nextStatement, sourceCode);
74
+ if (hasBlankLine(last, target)) {
75
+ context.report({
76
+ fix(fixer) {
77
+ return getRemoveBlankLineFix(fixer, sourceCode, last, target);
78
+ },
79
+ node: nextStatement,
80
+ messageId: "unexpectedBlankLine",
81
+ });
82
+ }
83
+ last = nextStatement;
84
+ nextStatement = getNextStatement(last);
85
+ continue;
86
+ }
87
+ break;
88
+ }
89
+ if (nextStatement === null ||
90
+ nextStatement.type === "EmptyStatement" ||
91
+ nextStatement.type === "ReturnStatement") {
92
+ return;
93
+ }
94
+ const target = getInsertionTarget(last, nextStatement, sourceCode);
95
+ if (hasBlankLine(last, target)) {
96
+ return;
97
+ }
98
+ context.report({
99
+ fix(fixer) {
100
+ return getBlankLineFix(fixer, sourceCode, last, target);
101
+ },
102
+ node: nextStatement,
103
+ messageId: "blankLine",
104
+ });
105
+ }
106
+ return {
107
+ VariableDeclaration(node) {
108
+ checkStatement(node);
109
+ },
110
+ ExportNamedDeclaration(node) {
111
+ if (node.declaration?.type === "VariableDeclaration") {
112
+ checkStatement(node);
113
+ }
114
+ },
115
+ };
116
+ },
117
+ });
118
+ export default blankLineAfterVariableDeclaration;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * return の直前に処理がある場合、空行を 1 行以上確保します。
3
+ * 余分な空行は Oxfmt が 1 行に畳みます。
4
+ */
5
+ declare const blankLineBeforeReturn: import("vite-plus/lint/plugins").Rule;
6
+ export default blankLineBeforeReturn;
7
+ //# sourceMappingURL=blank-line-before-return.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blank-line-before-return.d.ts","sourceRoot":"","sources":["../../../src/rules/blank-line-before-return.ts"],"names":[],"mappings":"AA2CA;;;GAGG;AACH,QAAA,MAAM,qBAAqB,uCAmDzB,CAAC;eAEY,qBAAqB"}
@@ -0,0 +1,81 @@
1
+ import { defineRule } from "vite-plus/lint/plugins";
2
+ import { hasBlankLine, getBlankLineFix, getInsertionTarget, getPreviousStatement, } from "./blank-line.js";
3
+ const SKIP_PREVIOUS_TYPES = new Set([
4
+ // 制御ブロックは blank-line-after-control-block が担当します。
5
+ "DoWhileStatement",
6
+ "ForInStatement",
7
+ "ForOfStatement",
8
+ "ForStatement",
9
+ "IfStatement",
10
+ "SwitchStatement",
11
+ "TryStatement",
12
+ "WhileStatement",
13
+ // 宣言は blank-line-after-declaration が担当します。
14
+ "ClassDeclaration",
15
+ "ExportAllDeclaration",
16
+ "ExportDefaultDeclaration",
17
+ "ExportNamedDeclaration",
18
+ "FunctionDeclaration",
19
+ "ImportDeclaration",
20
+ "TSDeclareFunction",
21
+ "TSEnumDeclaration",
22
+ "TSInterfaceDeclaration",
23
+ "TSModuleDeclaration",
24
+ "TSTypeAliasDeclaration",
25
+ // 途中で終わる文や空文の後は対象外にします。
26
+ "BlockStatement",
27
+ "BreakStatement",
28
+ "ContinueStatement",
29
+ "DebuggerStatement",
30
+ "EmptyStatement",
31
+ "LabeledStatement",
32
+ "ReturnStatement",
33
+ "ThrowStatement",
34
+ "WithStatement",
35
+ ]);
36
+ /**
37
+ * return の直前に処理がある場合、空行を 1 行以上確保します。
38
+ * 余分な空行は Oxfmt が 1 行に畳みます。
39
+ */
40
+ const blankLineBeforeReturn = defineRule({
41
+ meta: {
42
+ docs: {
43
+ description: "Require a blank line before a return statement when another statement precedes it.",
44
+ },
45
+ type: "layout",
46
+ fixable: "whitespace",
47
+ messages: {
48
+ blankLine: "Expected a blank line before a return statement when another statement precedes it.",
49
+ },
50
+ },
51
+ create(context) {
52
+ const sourceCode = context.sourceCode;
53
+ return {
54
+ ReturnStatement(node) {
55
+ const previousStatement = getPreviousStatement(node);
56
+ if (previousStatement === null) {
57
+ return;
58
+ }
59
+ if (SKIP_PREVIOUS_TYPES.has(previousStatement.type)) {
60
+ return;
61
+ }
62
+ if (previousStatement.type === "ExpressionStatement" &&
63
+ typeof previousStatement.directive === "string") {
64
+ return;
65
+ }
66
+ const target = getInsertionTarget(previousStatement, node, sourceCode);
67
+ if (hasBlankLine(previousStatement, target)) {
68
+ return;
69
+ }
70
+ context.report({
71
+ fix(fixer) {
72
+ return getBlankLineFix(fixer, sourceCode, previousStatement, target);
73
+ },
74
+ node,
75
+ messageId: "blankLine",
76
+ });
77
+ },
78
+ };
79
+ },
80
+ });
81
+ export default blankLineBeforeReturn;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * クラスメンバーの間に空行を 1 行以上確保します。
3
+ *
4
+ * オーバーロード署名と getter/setter のペアは連続させます。
5
+ */
6
+ declare const blankLineBetweenClassMembers: import("vite-plus/lint/plugins").Rule;
7
+ export default blankLineBetweenClassMembers;
8
+ //# sourceMappingURL=blank-line-between-class-members.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blank-line-between-class-members.d.ts","sourceRoot":"","sources":["../../../src/rules/blank-line-between-class-members.ts"],"names":[],"mappings":"AA2DA;;;;GAIG;AACH,QAAA,MAAM,4BAA4B,uCA6ChC,CAAC;eAEY,4BAA4B"}