eslint-plugin-crisp 1.0.68 → 1.0.70
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 +66 -65
- package/index.js +2 -0
- package/package.json +1 -1
- package/recommended-vue.js +1 -0
- package/rules/import-group-comment.js +108 -0
- package/rules/methods-naming.js +3 -3
package/README.md
CHANGED
|
@@ -32,100 +32,101 @@ Add the plugin in your ESLint config object, then extend the desired configurati
|
|
|
32
32
|
This is the list of plugins and rules used by ESLint Plugin Crisp, and what they do.
|
|
33
33
|
|
|
34
34
|
Each item has emojis denoting:
|
|
35
|
-
*
|
|
35
|
+
* 🟠: enabled in `plugin:crisp/recommended`
|
|
36
36
|
* 🟢: enabled in `plugin:crisp/recommended-vue`
|
|
37
37
|
|
|
38
38
|
### Configurations
|
|
39
39
|
- [eslint:recommended](https://github.com/eslint/eslint) (🟢): Core ESLint rules
|
|
40
|
-
- [plugin:jsdoc/recommended](https://github.com/gajus/eslint-plugin-jsdoc) (
|
|
40
|
+
- [plugin:jsdoc/recommended](https://github.com/gajus/eslint-plugin-jsdoc) (🟠🟢): JSDoc linting rules
|
|
41
41
|
- [plugin:vue/vue3-recommended](https://github.com/vuejs/eslint-plugin-vue) (🟢): Vue.js 3 linting rules
|
|
42
42
|
- [plugin:vue-pug/vue3-recommended](https://github.com/gajus/eslint-plugin-jsdoc) (🟢): Pug templates support for Vue.js linting rules
|
|
43
43
|
|
|
44
44
|
### Plugins
|
|
45
|
-
- [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) (
|
|
45
|
+
- [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) (🟠🟢): JSDoc linting rules for ESLint
|
|
46
46
|
|
|
47
47
|
### Rules
|
|
48
48
|
|
|
49
49
|
#### General JS rules
|
|
50
|
-
- [arrow-parens](https://eslint.org/docs/latest/rules/arrow-parens) (
|
|
51
|
-
- [brace-style](https://eslint.org/docs/latest/rules/brace-style) (
|
|
52
|
-
- [comma-dangle](https://eslint.org/docs/latest/rules/comma-dangle) (
|
|
53
|
-
- [comma-style](https://eslint.org/docs/latest/rules/comma-style) (
|
|
54
|
-
- [curly](https://eslint.org/docs/latest/rules/curly) (
|
|
50
|
+
- [arrow-parens](https://eslint.org/docs/latest/rules/arrow-parens) (🟠🟢): Requires parentheses around arrow function arguments
|
|
51
|
+
- [brace-style](https://eslint.org/docs/latest/rules/brace-style) (🟠🟢): Enforces one true brace style for blocks
|
|
52
|
+
- [comma-dangle](https://eslint.org/docs/latest/rules/comma-dangle) (🟠🟢): Disallows trailing commas
|
|
53
|
+
- [comma-style](https://eslint.org/docs/latest/rules/comma-style) (🟠🟢): Requires a comma after and on the same line
|
|
54
|
+
- [curly](https://eslint.org/docs/latest/rules/curly) (🟠🟢): Ensures block statements are always wrapped in curly braces
|
|
55
55
|
- [computed-property-spacing](https://eslint.org/docs/latest/rules/computed-property-spacing) (🟢): Disallows spaces inside computed property brackets
|
|
56
|
-
- [default-param-last](https://eslint.org/docs/latest/rules/default-param-last) (
|
|
57
|
-
- [default-case-last](https://eslint.org/docs/latest/rules/default-case-last) (
|
|
58
|
-
- [dot-notation](https://eslint.org/docs/latest/rules/dot-notation) (
|
|
59
|
-
- [eqeqeq](https://eslint.org/docs/latest/rules/eqeqeq) (
|
|
60
|
-
- [eol-last](https://eslint.org/docs/latest/rules/eol-last) (
|
|
61
|
-
- [indent](https://eslint.org/docs/latest/rules/indent) (
|
|
62
|
-
- [for-direction](https://eslint.org/docs/latest/rules/for-direction) (
|
|
56
|
+
- [default-param-last](https://eslint.org/docs/latest/rules/default-param-last) (🟠🟢): Enforces default parameters to be last
|
|
57
|
+
- [default-case-last](https://eslint.org/docs/latest/rules/default-case-last) (🟠🟢): Enforces default clauses in switch statements to be last
|
|
58
|
+
- [dot-notation](https://eslint.org/docs/latest/rules/dot-notation) (🟠🟢): Enforces dot notation instead of square-bracket notation
|
|
59
|
+
- [eqeqeq](https://eslint.org/docs/latest/rules/eqeqeq) (🟠🟢): Requires the use of `===` and `!==`
|
|
60
|
+
- [eol-last](https://eslint.org/docs/latest/rules/eol-last) (🟠🟢): Requires newline at the end of files
|
|
61
|
+
- [indent](https://eslint.org/docs/latest/rules/indent) (🟠🟢): Enforces 2-space indentation, and specific indentation levels for some nodes
|
|
62
|
+
- [for-direction](https://eslint.org/docs/latest/rules/for-direction) (🟠🟢): Prevents for-loops to have stop condition that can never be reached
|
|
63
63
|
- [key-spacing](https://eslint.org/docs/latest/rules/key-spacing) (🟢): Enforces consistent spacing in object literal properties (no space between the key and the colon, one space between the colon and the value)
|
|
64
|
-
- [linebreak-style](https://eslint.org/docs/latest/rules/linebreak-style) (
|
|
65
|
-
- [max-len](https://eslint.org/docs/latest/rules/max-len) (
|
|
64
|
+
- [linebreak-style](https://eslint.org/docs/latest/rules/linebreak-style) (🟠🟢): Enforces Unix-style line endings
|
|
65
|
+
- [max-len](https://eslint.org/docs/latest/rules/max-len) (🟠): Enforces a maximum line length of 80 characters
|
|
66
66
|
- [newline-per-chained-call](https://eslint.org/docs/latest/rules/newline-per-chained-call) (🟢): Requires a newline after each call in a method chain
|
|
67
|
-
- [no-console](https://eslint.org/docs/latest/rules/no-console) (
|
|
68
|
-
- [no-debugger](https://eslint.org/docs/latest/rules/no-debugger) (
|
|
69
|
-
- [no-eval](https://eslint.org/docs/latest/rules/no-eval) (
|
|
70
|
-
- [no-magic-numbers](https://eslint.org/docs/latest/rules/no-magic-numbers) (
|
|
71
|
-
- [no-multi-str](https://eslint.org/docs/latest/rules/no-multi-str) (
|
|
67
|
+
- [no-console](https://eslint.org/docs/latest/rules/no-console) (🟠🟢): Disallows the use of `console`
|
|
68
|
+
- [no-debugger](https://eslint.org/docs/latest/rules/no-debugger) (🟠🟢): Disallows the use of `debugger`
|
|
69
|
+
- [no-eval](https://eslint.org/docs/latest/rules/no-eval) (🟠🟢): Disallows the use of `eval`
|
|
70
|
+
- [no-magic-numbers](https://eslint.org/docs/latest/rules/no-magic-numbers) (🟠): Disallows magic numbers (except the ones in the context of array indexes and in default value assignments)
|
|
71
|
+
- [no-multi-str](https://eslint.org/docs/latest/rules/no-multi-str) (🟠🟢): Disallows multiline strings
|
|
72
72
|
- [no-multiple-empty-lines](https://eslint.org/docs/latest/rules/no-multiple-empty-lines) (🟢): Allows a maximum of 1 consecutive empty lines
|
|
73
|
-
- [no-mixed-spaces-and-tabs](https://eslint.org/docs/latest/rules/no-mixed-spaces-and-tabs) (
|
|
73
|
+
- [no-mixed-spaces-and-tabs](https://eslint.org/docs/latest/rules/no-mixed-spaces-and-tabs) (🟠🟢): Disallows mixed spaces and tabs for indentation
|
|
74
74
|
- [no-restricted-syntax](https://eslint.org/docs/latest/rules/no-restricted-syntax) (🟢): Enforces `switch` `case`'s content to be enclosed in braces
|
|
75
|
-
- [no-tabs](https://eslint.org/docs/latest/rules/no-tabs) (
|
|
76
|
-
- [no-trailing-spaces](https://eslint.org/docs/latest/rules/no-trailing-spaces) (
|
|
77
|
-
- [no-unused-vars](https://eslint.org/docs/latest/rules/no-unused-vars) (
|
|
78
|
-
- [no-unsafe-optional-chaining](https://eslint.org/docs/latest/rules/no-unsafe-optional-chaining) (
|
|
79
|
-
- [object-curly-newline](https://eslint.org/docs/latest/rules/object-curly-newline) (
|
|
80
|
-
- [object-curly-spacing](https://eslint.org/docs/latest/rules/object-curly-spacing) (
|
|
81
|
-
- [padded-blocks](https://eslint.org/docs/latest/rules/padded-blocks) (
|
|
82
|
-
- [padding-line-between-statements](https://eslint.org/docs/latest/rules/padding-line-between-statements) (
|
|
75
|
+
- [no-tabs](https://eslint.org/docs/latest/rules/no-tabs) (🟠🟢): Disallows tabs
|
|
76
|
+
- [no-trailing-spaces](https://eslint.org/docs/latest/rules/no-trailing-spaces) (🟠🟢): Disallows trailing whitespace at the end of lines
|
|
77
|
+
- [no-unused-vars](https://eslint.org/docs/latest/rules/no-unused-vars) (🟠🟢): Disallows unused variables
|
|
78
|
+
- [no-unsafe-optional-chaining](https://eslint.org/docs/latest/rules/no-unsafe-optional-chaining) (🟠🟢): Disallows use of optional chaining in contexts where the `undefined` value is not allowed
|
|
79
|
+
- [object-curly-newline](https://eslint.org/docs/latest/rules/object-curly-newline) (🟠🟢): Requires line breaks after opening and before closing braces
|
|
80
|
+
- [object-curly-spacing](https://eslint.org/docs/latest/rules/object-curly-spacing) (🟠🟢): Requires spacing inside of braces
|
|
81
|
+
- [padded-blocks](https://eslint.org/docs/latest/rules/padded-blocks) (🟠🟢): Disallows empty lines at the beginning and ending of blocks
|
|
82
|
+
- [padding-line-between-statements](https://eslint.org/docs/latest/rules/padding-line-between-statements) (🟠🟢): Requires padding lines between various statements
|
|
83
83
|
- [prefer-arrow-callback](https://eslint.org/docs/latest/rules/prefer-arrow-callback) (🟢): Requires using arrow functions for callbacks
|
|
84
|
-
- [quotes](https://eslint.org/docs/latest/rules/quotes) (
|
|
85
|
-
- [quote-props](https://eslint.org/docs/latest/rules/quote-props) (
|
|
86
|
-
- [semi](https://eslint.org/docs/latest/rules/semi) (
|
|
87
|
-
- [semi-style](https://eslint.org/docs/latest/rules/semi-style) (
|
|
84
|
+
- [quotes](https://eslint.org/docs/latest/rules/quotes) (🟠🟢): Enforces the consistent use of double quotes (while allowing single quotes in order to avoid escape, and backticks for template literals)
|
|
85
|
+
- [quote-props](https://eslint.org/docs/latest/rules/quote-props) (🟠🟢): Disallows quotes around object literal property names that are not strictly required
|
|
86
|
+
- [semi](https://eslint.org/docs/latest/rules/semi) (🟠🟢): Requires semicolons at the end of statements
|
|
87
|
+
- [semi-style](https://eslint.org/docs/latest/rules/semi-style) (🟠🟢): Enforces that semicolons are at the end of statements
|
|
88
88
|
- [semi-spacing](https://eslint.org/docs/latest/rules/semi-spacing) (🟢): Disallows space before semicolons, enforces spaces after
|
|
89
|
-
- [space-before-blocks](https://eslint.org/docs/latest/rules/space-before-blocks) (
|
|
90
|
-
- [space-in-parens](https://eslint.org/docs/latest/rules/space-in-parens) (
|
|
89
|
+
- [space-before-blocks](https://eslint.org/docs/latest/rules/space-before-blocks) (🟠🟢): Enforces consistent spacing before blocks
|
|
90
|
+
- [space-in-parens](https://eslint.org/docs/latest/rules/space-in-parens) (🟠🟢): Enforces zero spaces inside of parentheses
|
|
91
91
|
|
|
92
92
|
#### Crisp JS rules
|
|
93
|
-
- [crisp/align-consecutive-class-assignements](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/align-consecutive-class-assignements.js) (
|
|
94
|
-
- [crisp/align-one-var](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/align-one-var.js) (
|
|
95
|
-
- [crisp/align-requires](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/align-requires.js) (
|
|
96
|
-
- [crisp/const](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/const.js) (
|
|
97
|
-
- [crisp/constructor-variables](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/constructor-variables.js) (
|
|
98
|
-
- [crisp/enforce-optional](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/enforce-optional.js) (
|
|
99
|
-
- [crisp/header-check](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/header-check.js) (
|
|
100
|
-
- [crisp/header-comments-check](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/header-comments-check.js) (
|
|
101
|
-
- [crisp/
|
|
102
|
-
- [crisp/methods-
|
|
103
|
-
- [crisp/
|
|
104
|
-
- [crisp/
|
|
105
|
-
- [crisp/
|
|
106
|
-
- [crisp/no-
|
|
107
|
-
- [crisp/no-
|
|
93
|
+
- [crisp/align-consecutive-class-assignements](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/align-consecutive-class-assignements.js) (🟠): Enforces alignment of consecutive assignment statements in a class constructor
|
|
94
|
+
- [crisp/align-one-var](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/align-one-var.js) (🟠): Enforces alignment of variables in 'one-var' statements
|
|
95
|
+
- [crisp/align-requires](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/align-requires.js) (🟠): Enforces alignment of require statements
|
|
96
|
+
- [crisp/const](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/const.js) (🟠): Enforces that `const` variables start with `__` or are all uppercase
|
|
97
|
+
- [crisp/constructor-variables](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/constructor-variables.js) (🟠): Ensures all class properties in the constructor start with `_`
|
|
98
|
+
- [crisp/enforce-optional](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/enforce-optional.js) (🟠🟢): Enforces use of optional chaining
|
|
99
|
+
- [crisp/header-check](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/header-check.js) (🟠🟢): Enforces files to start with Crisp header
|
|
100
|
+
- [crisp/header-comments-check](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/header-comments-check.js) (🟠🟢): Enforces different comment blocks before different groups (imports, constants, instances and exports)
|
|
101
|
+
- [crisp/import-group-comment](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/import-group-comment.js) (🟢): Ensures `import` statements are preceded by a comment stating their type
|
|
102
|
+
- [crisp/methods-naming](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/methods-naming.js) (🟠🟢): Ensures methods are named according to their access (`public`, `private`, `protected`)
|
|
103
|
+
- [crisp/methods-ordering](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/methods-ordering.js) (🟠🟢): Ensures methods order according to their access: `public` then `protected` then `private`
|
|
104
|
+
- [crisp/multiline-comment-end-backslash](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/multiline-comment-end-backslash.js) (🟠🟢): Enforces multiline comments to end with a backslash
|
|
105
|
+
- [crisp/newline-after-switch-case](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/newline-after-switch-case.js) (🟠🟢): Requires newline between switch cases
|
|
106
|
+
- [crisp/no-async](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/no-async.js) (🟠🟢): Disallows the use of `async/syntax`, in favor of `Promise`
|
|
107
|
+
- [crisp/no-short-parameters](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/no-short-parameters.js) (🟠🟢): Disallow parameter names shorter than 3 characters
|
|
108
|
+
- [crisp/no-space-in-optional-arguments](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/no-space-in-optional-arguments.js) (🟠): Disallows space before or after `=` in optional parameters
|
|
108
109
|
- [crisp/no-useless-template-literals](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/no-useless-template-literals.js) (🟢): Disallows unnecessary use of template literals
|
|
109
|
-
- [crisp/no-var-in-blocks](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/no-var-in-blocks.js) (
|
|
110
|
-
- [crisp/one-space-after-operator](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/one-space-after-operator.js) (
|
|
111
|
-
- [crisp/regex-in-constructor](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/regex-in-constructor.js) (
|
|
112
|
-
- [crisp/ternary-parenthesis](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/ternary-parenthesis.js) (
|
|
113
|
-
- [crisp/two-lines-between-class-members](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/two-lines-between-class-members.js) (
|
|
114
|
-
- [crisp/variable-names](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/variable-names.js) (
|
|
110
|
+
- [crisp/no-var-in-blocks](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/no-var-in-blocks.js) (🟠🟢): Disallows `var` declarations inside function, method, or class block
|
|
111
|
+
- [crisp/one-space-after-operator](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/one-space-after-operator.js) (🟠🟢): Enforces at least one space before and one space after `=` and `:` operators
|
|
112
|
+
- [crisp/regex-in-constructor](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/regex-in-constructor.js) (🟠🟢): Ensures regular expressions are defined in the class constructor
|
|
113
|
+
- [crisp/ternary-parenthesis](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/ternary-parenthesis.js) (🟠🟢): Enforces parentheses around conditions with operators in ternary expressions
|
|
114
|
+
- [crisp/two-lines-between-class-members](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/two-lines-between-class-members.js) (🟠): Requires exactly two line breaks between class methods
|
|
115
|
+
- [crisp/variable-names](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/variable-names.js) (🟠🟢): Requires variables defined within a method to start with `_`
|
|
115
116
|
|
|
116
117
|
#### General JSDoc rules
|
|
117
|
-
- [jsdoc/no-undefined-types](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-undefined-types.md) (
|
|
118
|
+
- [jsdoc/no-undefined-types](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-undefined-types.md) (🟠): Rule is **disabled** to allow some undefined types
|
|
118
119
|
- [jsdoc/require-description](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-description.md) (🟢): Requires all functions to have a description in their JSDoc
|
|
119
|
-
- [jsdoc/require-param-description](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-description.md) (
|
|
120
|
-
- [jsdoc/require-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md) (
|
|
121
|
-
- [jsdoc/sort-tags](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/sort-tags.md) (
|
|
120
|
+
- [jsdoc/require-param-description](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-description.md) (🟠🟢): Rule is **disabled** as we don't write any description for `@param` tags
|
|
121
|
+
- [jsdoc/require-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md) (🟠🟢): Enforces JSDoc comments on functions and classes
|
|
122
|
+
- [jsdoc/sort-tags](https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/sort-tags.md) (🟠🟢): Enforces specific order for tags
|
|
122
123
|
|
|
123
124
|
#### Crisp JSDoc rules
|
|
124
|
-
- [crisp/jsdoc-align-params](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/jsdoc-align-params.js) (
|
|
125
|
-
- [crisp/jsdoc-check-indentation](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/jsdoc-check-indentation.js) (
|
|
125
|
+
- [crisp/jsdoc-align-params](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/jsdoc-align-params.js) (🟠🟢): Enforces various alignments
|
|
126
|
+
- [crisp/jsdoc-check-indentation](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/jsdoc-check-indentation.js) (🟠🟢): Enforces consistent indentation
|
|
126
127
|
- [crisp/jsdoc-check-optional-params](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/jsdoc-check-optional-params.js) (🟢): Requires optional parameters to be surrounded by brackets
|
|
127
128
|
- [crisp/jsdoc-enforce-access](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/jsdoc-enforce-access.js) (🟢): Requires one of `@public`, `@private`, or `@protected` for functions
|
|
128
|
-
- [crisp/jsdoc-enforce-classdesc](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/jsdoc-enforce-classdesc.js) (
|
|
129
|
+
- [crisp/jsdoc-enforce-classdesc](https://github.com/crisp-oss/eslint-plugin-crisp/blob/master/rules/jsdoc-enforce-classdesc.js) (🟠🟢): Ensures JSDoc for class headers to include a non-empty `@classdesc`
|
|
129
130
|
|
|
130
131
|
#### General Vue rules
|
|
131
132
|
- [vue/attributes-order](https://eslint.vuejs.org/rules/attributes-order) (🟢): Enforces order of attributes
|
package/index.js
CHANGED
|
@@ -11,6 +11,7 @@ module.exports = {
|
|
|
11
11
|
"enforce-optional": require("./rules/enforce-optional"),
|
|
12
12
|
"header-check": require("./rules/header-check"),
|
|
13
13
|
"header-comments-check": require("./rules/header-comments-check"),
|
|
14
|
+
"import-group-comment": require("./rules/import-group-comment"),
|
|
14
15
|
"jsdoc-align-params": require("./rules/jsdoc-align-params"),
|
|
15
16
|
"jsdoc-check-indentation": require("./rules/jsdoc-check-indentation"),
|
|
16
17
|
"jsdoc-check-optional-params": require("./rules/jsdoc-check-optional-params"),
|
|
@@ -19,6 +20,7 @@ module.exports = {
|
|
|
19
20
|
"methods-naming": require("./rules/methods-naming"),
|
|
20
21
|
"methods-ordering": require("./rules/methods-ordering"),
|
|
21
22
|
"multiline-comment-end-backslash": require("./rules/multiline-comment-end-backslash"),
|
|
23
|
+
"newline-after-switch-case": require("./rules/newline-after-switch-case"),
|
|
22
24
|
"no-async": require("./rules/no-async"),
|
|
23
25
|
"no-var-in-blocks": require("./rules/no-var-in-blocks"),
|
|
24
26
|
"no-space-in-optional-arguments": require("./rules/no-space-in-optional-arguments"),
|
package/package.json
CHANGED
package/recommended-vue.js
CHANGED
|
@@ -140,6 +140,7 @@ module.exports = {
|
|
|
140
140
|
"crisp/enforce-optional": "error",
|
|
141
141
|
"crisp/header-check": "error",
|
|
142
142
|
"crisp/header-comments-check": "error",
|
|
143
|
+
"crisp/import-group-comment": "error",
|
|
143
144
|
"crisp/methods-naming": "error",
|
|
144
145
|
"crisp/methods-ordering": "error",
|
|
145
146
|
"crisp/multiline-comment-end-backslash": "error",
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
meta: {
|
|
3
|
+
type: "suggestion",
|
|
4
|
+
docs: {
|
|
5
|
+
description: "Enforce import statements to be grouped and preceded by a comment",
|
|
6
|
+
category: "Best Practices",
|
|
7
|
+
recommended: false,
|
|
8
|
+
},
|
|
9
|
+
fixable: null, // This rule is not auto-fixable
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
create(context) {
|
|
13
|
+
let currentGroupComment = null;
|
|
14
|
+
|
|
15
|
+
// Extract the directory name from the file path
|
|
16
|
+
function getDirectoryName(filePath) {
|
|
17
|
+
const pathParts = filePath.split('/');
|
|
18
|
+
return pathParts[pathParts.length - 2].toUpperCase(); // Directory name
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function extractGroupFromPath(path, filePath) {
|
|
22
|
+
// Relative path import?
|
|
23
|
+
if (path.startsWith("./")) {
|
|
24
|
+
return getDirectoryName(filePath);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Alias path import?
|
|
28
|
+
if (path.startsWith("@/")) {
|
|
29
|
+
const parts = path.split("/");
|
|
30
|
+
|
|
31
|
+
if (parts.length === 2) {
|
|
32
|
+
return "MAIN";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return parts[1].toUpperCase();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return "NPM";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function generateExpectedComment(group) {
|
|
42
|
+
if (group === "NPM") {
|
|
43
|
+
return group;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return `PROJECT: ${group}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function isGroupComment(comment) {
|
|
50
|
+
return (
|
|
51
|
+
comment.type === "Line" &&
|
|
52
|
+
(
|
|
53
|
+
comment.value.trim().startsWith("PROJECT:") ||
|
|
54
|
+
comment.value.trim().startsWith("NPM")
|
|
55
|
+
)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function isIgnoreComment(comment) {
|
|
60
|
+
// Skip some comments
|
|
61
|
+
return (
|
|
62
|
+
comment.type === "Line" &&
|
|
63
|
+
comment.value.trim().startsWith("@ts-ignore")
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function updateCurrentGroupComment(node) {
|
|
68
|
+
const comments = context.getSourceCode().getCommentsBefore(node);
|
|
69
|
+
|
|
70
|
+
if (comments.length > 0) {
|
|
71
|
+
for (let i = comments.length - 1; i >= 0; i--) {
|
|
72
|
+
if (isIgnoreComment(comments[i])) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (isGroupComment(comments[i])) {
|
|
77
|
+
currentGroupComment = comments[i];
|
|
78
|
+
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function checkImportGroup(node) {
|
|
86
|
+
const importPath = node.source.value;
|
|
87
|
+
const filePath = context.getFilename();
|
|
88
|
+
|
|
89
|
+
// Get group from import path
|
|
90
|
+
const expectedGroup = extractGroupFromPath(importPath, filePath);
|
|
91
|
+
const expectedComment = generateExpectedComment(expectedGroup);
|
|
92
|
+
|
|
93
|
+
// Get comment for current group
|
|
94
|
+
updateCurrentGroupComment(node);
|
|
95
|
+
|
|
96
|
+
if (!currentGroupComment || !currentGroupComment.value.toUpperCase().includes(expectedComment.toUpperCase())) {
|
|
97
|
+
context.report({
|
|
98
|
+
node,
|
|
99
|
+
message: `Import "${importPath}" should be in the "${expectedComment}" group.`,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
ImportDeclaration: checkImportGroup,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
};
|
package/rules/methods-naming.js
CHANGED
|
@@ -21,16 +21,16 @@ module.exports = {
|
|
|
21
21
|
if (jsDocComment) {
|
|
22
22
|
const isPrivate = node.key.name.startsWith("__");
|
|
23
23
|
const isProtected = node.key.name.startsWith("_") && !node.key.name.startsWith("__");
|
|
24
|
-
const
|
|
24
|
+
const isPublicJsDoc = jsDocComment.value.includes("@public");
|
|
25
25
|
const isProtectedJsDoc = jsDocComment.value.includes("@protected");
|
|
26
26
|
const isPrivateJsDoc = jsDocComment.value.includes("@private");
|
|
27
27
|
|
|
28
|
-
if (isPrivate &&
|
|
28
|
+
if (isPrivate && isPublicJsDoc) {
|
|
29
29
|
context.report({
|
|
30
30
|
node: node,
|
|
31
31
|
message: "Methods starting with '__' should not be marked with '@public'."
|
|
32
32
|
});
|
|
33
|
-
} else if (isProtected &&
|
|
33
|
+
} else if (isProtected && isPublicJsDoc) {
|
|
34
34
|
context.report({
|
|
35
35
|
node: node,
|
|
36
36
|
message: "Methods starting with '_' should not be marked with '@public'."
|