@croct/eslint-plugin 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Croct.com
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 all
13
+ 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 THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,114 @@
1
+ <p align="center">
2
+ <a href="https://croct.com">
3
+ <img src="https://cdn.croct.io/brand/logo/repo-icon-green.svg" alt="Croct" height="80"/>
4
+ </a>
5
+ <br />
6
+ <strong>JavaScript Coding Standard</strong>
7
+ <br />
8
+ A set of <a href="https://eslint.org/">ESLint</a> rules applied to all Croct JavaScript projects.
9
+ </p>
10
+ <p align="center">
11
+ <a href="https://www.npmjs.com/package/@croct/eslint-plugin"><img alt="Version" src="https://img.shields.io/npm/v/@croct/eslint-plugin"/></a>
12
+ <a href="https://github.com/croct-tech/coding-standard-js/actions/workflows/branch-validations.yaml">
13
+ <img alt="Build" src="https://github.com/croct-tech/coding-standard-js/actions/workflows/branch-validations.yaml/badge.svg" />
14
+ </a>
15
+ <a href="https://codeclimate.com/repos/620292a0376562495b002392/maintainability"><img alt="Maintainability" src="https://api.codeclimate.com/v1/badges/c1fe99959c642f53697b/maintainability" /></a>
16
+ <a href="https://codeclimate.com/repos/620292a0376562495b002392/test_coverage"><img alt="Coverage" src="https://api.codeclimate.com/v1/badges/c1fe99959c642f53697b/test_coverage" /></a>
17
+ <br />
18
+ <br />
19
+ <a href="https://github.com/croct-tech/coding-standard-js/releases">📦 Releases</a>
20
+ ·
21
+ <a href="https://github.com/croct-tech/coding-standard-js/issues">🐞 Report Bug</a>
22
+ ·
23
+ <a href="https://github.com/croct-tech/coding-standard-js/issues">✨ Request Feature</a>
24
+ </p>
25
+
26
+ ## Installation
27
+
28
+ The recommended way to install the SDK is via [NPM](https://npmjs.com). It pairs nicely with module bundlers such as
29
+ Webpack or Browserify:
30
+
31
+ ```sh
32
+ npm i -D @croct/eslint-plugin
33
+ ```
34
+
35
+ Then, add the following to your `.eslintrc.js` file:
36
+
37
+ ```js
38
+ // Workaround for https://github.com/eslint/eslint/issues/3458
39
+ require("@rushstack/eslint-patch/modern-module-resolution");
40
+
41
+ module.exports = {
42
+ "plugins": ["@croct"]
43
+ }
44
+ ```
45
+
46
+ Note the `require` call at the top of the file. This is a workaround to avoid adding the transitive dependencies of
47
+ the plugin to the project, which is [currently not supported by the ESLint plugin system](https://github.com/eslint/eslint/issues/3458).
48
+
49
+ ### TypeScript
50
+
51
+ For TypeScript projects, you need first to install the TypeScript parser:
52
+
53
+ ```sh
54
+ npm i -D @typescript-eslint/parser
55
+ ```
56
+
57
+ Then, add the following to your `.eslintrc.js` file:
58
+
59
+ ```js
60
+ // Workaround for https://github.com/eslint/eslint/issues/3458
61
+ require("@rushstack/eslint-patch/modern-module-resolution");
62
+
63
+ module.exports = {
64
+ "parser": "@typescript-eslint/parser",
65
+ "plugins": [
66
+ "@croct"
67
+ ],
68
+ "extends": [
69
+ "plugin:@croct/typescript"
70
+ ],
71
+ "parserOptions": {
72
+ "extends": "./tsconfig.json",
73
+ "project": ["./tsconfig.json"]
74
+ },
75
+ }
76
+ ```
77
+
78
+ For the list for available presets and rules, see the [reference documentation](docs/README.md).
79
+
80
+ ## Basic usage
81
+
82
+ Run the following command to check if the project adheres to the coding standard:
83
+
84
+ ```sh
85
+ eslint
86
+ ```
87
+
88
+ ## Contributing
89
+
90
+ Contributions to the package are always welcome!
91
+
92
+ - Report any bugs or issues on the [issue tracker](https://github.com/croct-tech/coding-standard-js/issues).
93
+ - For major changes, please [open an issue](https://github.com/croct-tech/coding-standard-js/issues) first to discuss what you would like to change.
94
+ - Please make sure to update tests as appropriate.
95
+
96
+ ## Testing
97
+
98
+ Before running the test suites, the development dependencies must be installed:
99
+
100
+ ```sh
101
+ npm i
102
+ ```
103
+
104
+ Then, to run all tests:
105
+
106
+ ```sh
107
+ npm run test
108
+ ```
109
+
110
+ ## Copyright Notice
111
+
112
+ Copyright © 2015-2021 Croct Limited, All Rights Reserved.
113
+
114
+ All information contained herein is, and remains the property of Croct Limited. The intellectual, design and technical concepts contained herein are proprietary to Croct Limited s and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from Croct Limited.
@@ -0,0 +1,13 @@
1
+ export declare const cypress: {
2
+ extends: string[];
3
+ plugins: string[];
4
+ rules: {
5
+ 'no-loop-func': number;
6
+ 'cypress/no-assigning-return-values': string;
7
+ 'cypress/no-unnecessary-waiting': string;
8
+ 'cypress/assertion-before-screenshot': string;
9
+ 'cypress/no-async-tests': string;
10
+ 'cypress/no-pause': string;
11
+ '@typescript-eslint/no-namespace': string;
12
+ };
13
+ };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cypress = void 0;
4
+ exports.cypress = {
5
+ extends: [
6
+ 'plugin:@croct/javascript',
7
+ ],
8
+ plugins: [
9
+ 'cypress',
10
+ '@croct',
11
+ ],
12
+ rules: {
13
+ 'no-loop-func': 0,
14
+ 'cypress/no-assigning-return-values': 'warn',
15
+ 'cypress/no-unnecessary-waiting': 'error',
16
+ 'cypress/assertion-before-screenshot': 'warn',
17
+ 'cypress/no-async-tests': 'error',
18
+ 'cypress/no-pause': 'error',
19
+ '@typescript-eslint/no-namespace': 'off',
20
+ },
21
+ };
@@ -0,0 +1,250 @@
1
+ export declare const configs: {
2
+ cypress: {
3
+ extends: string[];
4
+ plugins: string[];
5
+ rules: {
6
+ 'no-loop-func': number;
7
+ 'cypress/no-assigning-return-values': string;
8
+ 'cypress/no-unnecessary-waiting': string;
9
+ 'cypress/assertion-before-screenshot': string;
10
+ 'cypress/no-async-tests': string;
11
+ 'cypress/no-pause': string;
12
+ '@typescript-eslint/no-namespace': string;
13
+ };
14
+ };
15
+ react: {
16
+ extends: string[];
17
+ plugins: string[];
18
+ rules: {
19
+ '@croct/jsx-attribute-spacing': string;
20
+ 'react/jsx-wrap-multilines': string;
21
+ 'react/display-name': string;
22
+ 'react/jsx-newline': (string | {
23
+ prevent: boolean;
24
+ })[];
25
+ 'react/jsx-no-bind': (string | {
26
+ allowArrowFunctions: boolean;
27
+ allowBind: boolean;
28
+ allowFunctions: boolean;
29
+ })[];
30
+ 'react/no-unstable-nested-components': (string | {
31
+ allowAsProps: boolean;
32
+ })[];
33
+ 'react/jsx-no-useless-fragment': (string | {
34
+ allowExpressions: boolean;
35
+ })[];
36
+ 'react/function-component-definition': string;
37
+ 'testing-library/no-container': string;
38
+ 'testing-library/no-node-access': string;
39
+ 'testing-library/await-async-utils': string;
40
+ 'jsx-a11y/aria-role': (string | {
41
+ ignoreNonDOM: boolean;
42
+ })[];
43
+ 'react/jsx-uses-react': string;
44
+ 'react/react-in-jsx-scope': string;
45
+ 'react/jsx-one-expression-per-line': string;
46
+ 'react/prop-types': string;
47
+ 'react/require-default-props': string;
48
+ 'react/jsx-fragments': string[];
49
+ 'react-hooks/rules-of-hooks': string;
50
+ 'react-hooks/exhaustive-deps': string;
51
+ 'react/jsx-filename-extension': (number | {
52
+ extensions: string[];
53
+ })[];
54
+ 'react/jsx-indent': (string | number)[];
55
+ 'react/jsx-indent-props': string;
56
+ 'react/jsx-props-no-spreading': string;
57
+ 'no-restricted-imports': (string | {
58
+ name: string;
59
+ importNames: string[];
60
+ message: string;
61
+ })[];
62
+ 'import/order': (string | {
63
+ groups: string[];
64
+ pathGroups: {
65
+ pattern: string;
66
+ group: string;
67
+ position: string;
68
+ }[];
69
+ pathGroupsExcludedImportTypes: string[];
70
+ 'newlines-between': string;
71
+ alphabetize: {
72
+ order: string;
73
+ caseInsensitive: boolean;
74
+ };
75
+ })[];
76
+ };
77
+ };
78
+ typescript: {
79
+ extends: string[];
80
+ plugins: string[];
81
+ rules: {
82
+ '@typescript-eslint/array-type': (string | {
83
+ default: string;
84
+ })[];
85
+ '@typescript-eslint/prefer-as-const': string;
86
+ '@typescript-eslint/adjacent-overload-signatures': string;
87
+ '@typescript-eslint/type-annotation-spacing': string;
88
+ '@typescript-eslint/semi': string[];
89
+ '@typescript-eslint/strict-boolean-expressions': (string | {
90
+ allowString: boolean;
91
+ allowNumber: boolean;
92
+ allowNullableObject: boolean;
93
+ })[];
94
+ '@typescript-eslint/prefer-regexp-exec': string;
95
+ '@typescript-eslint/prefer-optional-chain': string;
96
+ 'no-shadow': string;
97
+ '@typescript-eslint/no-shadow': (string | {
98
+ ignoreTypeValueShadow: boolean;
99
+ ignoreFunctionTypeParameterNameValueShadow: boolean;
100
+ })[];
101
+ '@typescript-eslint/no-empty-interface': string;
102
+ '@typescript-eslint/explicit-member-accessibility': string[];
103
+ '@typescript-eslint/explicit-module-boundary-types': string;
104
+ '@typescript-eslint/explicit-function-return-type': string[];
105
+ '@typescript-eslint/no-explicit-any': string;
106
+ 'no-use-before-define': string;
107
+ '@typescript-eslint/no-use-before-define': string;
108
+ 'no-unused-expressions': string;
109
+ '@typescript-eslint/no-unused-expressions': string;
110
+ indent: (string | number | {
111
+ SwitchCase: number;
112
+ })[];
113
+ '@typescript-eslint/no-unused-vars': string;
114
+ 'no-unused-vars': string;
115
+ '@typescript-eslint/no-non-null-assertion': string;
116
+ 'object-curly-spacing': string;
117
+ '@typescript-eslint/object-curly-spacing': string;
118
+ '@typescript-eslint/member-delimiter-style': (string | {
119
+ multiline: {
120
+ delimiter: string;
121
+ requireLast: boolean;
122
+ };
123
+ singleline: {
124
+ delimiter: string;
125
+ requireLast: boolean;
126
+ };
127
+ overrides: {
128
+ interface: {
129
+ singleline: {
130
+ delimiter: string;
131
+ };
132
+ multiline: {
133
+ delimiter: string;
134
+ };
135
+ };
136
+ };
137
+ })[];
138
+ 'no-undef': string;
139
+ };
140
+ overrides: {
141
+ files: string[];
142
+ extends: string[];
143
+ plugins: string[];
144
+ rules: {
145
+ 'no-new-object': string;
146
+ };
147
+ env: {
148
+ jest: boolean;
149
+ };
150
+ }[];
151
+ };
152
+ javascript: {
153
+ extends: string[];
154
+ plugins: string[];
155
+ rules: {
156
+ '@croct/argument-spacing': string;
157
+ '@croct/complex-expression-spacing': string;
158
+ 'array-bracket-newline': string[];
159
+ 'multiline-ternary': string[];
160
+ 'no-undef-init': string;
161
+ 'jest/consistent-test-it': (string | {
162
+ fn: string;
163
+ })[];
164
+ 'jest/no-large-snapshots': string;
165
+ 'jest/prefer-expect-resolves': string;
166
+ 'jest/prefer-lowercase-title': (string | {
167
+ ignore: string[];
168
+ })[];
169
+ 'jest/prefer-spy-on': string;
170
+ 'jest/require-top-level-describe': string;
171
+ 'jest/prefer-to-contain': string;
172
+ 'jest/prefer-hooks-on-top': string;
173
+ 'jest/prefer-equality-matcher': string;
174
+ 'jest/no-test-return-statement': string;
175
+ 'function-call-argument-newline': string[];
176
+ 'no-underscore-dangle': string;
177
+ 'import/no-default-export': string;
178
+ 'array-element-newline': string[];
179
+ 'import-newlines/enforce': (string | {
180
+ items: number;
181
+ 'max-len': number;
182
+ })[];
183
+ 'no-smart-quotes/no-smart-quotes': string;
184
+ 'no-shadow': string;
185
+ 'import/prefer-default-export': string;
186
+ 'import/no-extraneous-dependencies': string;
187
+ 'no-use-before-define': string;
188
+ 'arrow-parens': string[];
189
+ 'class-methods-use-this': string;
190
+ 'consistent-return': string;
191
+ 'default-case': string;
192
+ 'import/extensions': string[];
193
+ 'import/no-unresolved': string;
194
+ indent: (string | number | {
195
+ SwitchCase: number;
196
+ })[];
197
+ 'linebreak-style': string[];
198
+ 'max-classes-per-file': string;
199
+ 'max-len': (string | {
200
+ code: number;
201
+ ignoreStrings: boolean;
202
+ })[];
203
+ 'no-await-in-loop': string;
204
+ 'no-bitwise': string;
205
+ 'no-continue': string;
206
+ 'no-multiple-empty-lines': (string | {
207
+ max: number;
208
+ maxEOF: number;
209
+ maxBOF: number;
210
+ })[];
211
+ 'no-plusplus': (string | {
212
+ allowForLoopAfterthoughts: boolean;
213
+ })[];
214
+ 'no-unused-expressions': string;
215
+ 'no-unused-vars': string;
216
+ 'no-restricted-syntax': string[];
217
+ 'object-curly-newline': (string | {
218
+ multiline: boolean;
219
+ consistent: boolean;
220
+ })[];
221
+ 'object-curly-spacing': string[];
222
+ 'require-await': string;
223
+ 'object-shorthand': string[];
224
+ 'padding-line-between-statements': (string | {
225
+ blankLine: string;
226
+ prev: string;
227
+ next: string[];
228
+ } | {
229
+ blankLine: string;
230
+ prev: string[];
231
+ next: string;
232
+ } | {
233
+ blankLine: string;
234
+ prev: string[];
235
+ next: string[];
236
+ })[];
237
+ };
238
+ overrides: {
239
+ files: string[];
240
+ extends: string[];
241
+ plugins: string[];
242
+ rules: {
243
+ 'no-new-object': string;
244
+ };
245
+ env: {
246
+ jest: boolean;
247
+ };
248
+ }[];
249
+ };
250
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configs = void 0;
4
+ const cypress_1 = require("./cypress");
5
+ const react_1 = require("./react");
6
+ const typescript_1 = require("./typescript");
7
+ const javascript_1 = require("./javascript");
8
+ exports.configs = {
9
+ cypress: cypress_1.cypress,
10
+ react: react_1.react,
11
+ typescript: typescript_1.typescript,
12
+ javascript: javascript_1.javascript,
13
+ };
@@ -0,0 +1,98 @@
1
+ export declare const javascript: {
2
+ extends: string[];
3
+ plugins: string[];
4
+ rules: {
5
+ '@croct/argument-spacing': string;
6
+ '@croct/complex-expression-spacing': string;
7
+ 'array-bracket-newline': string[];
8
+ 'multiline-ternary': string[];
9
+ 'no-undef-init': string;
10
+ 'jest/consistent-test-it': (string | {
11
+ fn: string;
12
+ })[];
13
+ 'jest/no-large-snapshots': string;
14
+ 'jest/prefer-expect-resolves': string;
15
+ 'jest/prefer-lowercase-title': (string | {
16
+ ignore: string[];
17
+ })[];
18
+ 'jest/prefer-spy-on': string;
19
+ 'jest/require-top-level-describe': string;
20
+ 'jest/prefer-to-contain': string;
21
+ 'jest/prefer-hooks-on-top': string;
22
+ 'jest/prefer-equality-matcher': string;
23
+ 'jest/no-test-return-statement': string;
24
+ 'function-call-argument-newline': string[];
25
+ 'no-underscore-dangle': string;
26
+ 'import/no-default-export': string;
27
+ 'array-element-newline': string[];
28
+ 'import-newlines/enforce': (string | {
29
+ items: number;
30
+ 'max-len': number;
31
+ })[];
32
+ 'no-smart-quotes/no-smart-quotes': string;
33
+ 'no-shadow': string;
34
+ 'import/prefer-default-export': string;
35
+ 'import/no-extraneous-dependencies': string;
36
+ 'no-use-before-define': string;
37
+ 'arrow-parens': string[];
38
+ 'class-methods-use-this': string;
39
+ 'consistent-return': string;
40
+ 'default-case': string;
41
+ 'import/extensions': string[];
42
+ 'import/no-unresolved': string;
43
+ indent: (string | number | {
44
+ SwitchCase: number;
45
+ })[];
46
+ 'linebreak-style': string[];
47
+ 'max-classes-per-file': string;
48
+ 'max-len': (string | {
49
+ code: number;
50
+ ignoreStrings: boolean;
51
+ })[];
52
+ 'no-await-in-loop': string;
53
+ 'no-bitwise': string;
54
+ 'no-continue': string;
55
+ 'no-multiple-empty-lines': (string | {
56
+ max: number;
57
+ maxEOF: number;
58
+ maxBOF: number;
59
+ })[];
60
+ 'no-plusplus': (string | {
61
+ allowForLoopAfterthoughts: boolean;
62
+ })[];
63
+ 'no-unused-expressions': string;
64
+ 'no-unused-vars': string;
65
+ 'no-restricted-syntax': string[];
66
+ 'object-curly-newline': (string | {
67
+ multiline: boolean;
68
+ consistent: boolean;
69
+ })[];
70
+ 'object-curly-spacing': string[];
71
+ 'require-await': string;
72
+ 'object-shorthand': string[];
73
+ 'padding-line-between-statements': (string | {
74
+ blankLine: string;
75
+ prev: string;
76
+ next: string[];
77
+ } | {
78
+ blankLine: string;
79
+ prev: string[];
80
+ next: string;
81
+ } | {
82
+ blankLine: string;
83
+ prev: string[];
84
+ next: string[];
85
+ })[];
86
+ };
87
+ overrides: {
88
+ files: string[];
89
+ extends: string[];
90
+ plugins: string[];
91
+ rules: {
92
+ 'no-new-object': string;
93
+ };
94
+ env: {
95
+ jest: boolean;
96
+ };
97
+ }[];
98
+ };