@cargosense/eslint-config 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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +46 -0
  3. package/index.js +224 -0
  4. package/package.json +54 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 CargoSense, Inc.
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,46 @@
1
+ # eslint-config
2
+
3
+ **Shareable [ESLint](https://eslint.org) configuration.**
4
+
5
+ [![npm](https://img.shields.io/npm/v/@cargosense/eslint-config.svg?logo=npm&style=for-the-badge)](https://www.npmjs.com/package/@cargosense/eslint-config)
6
+ [![Downloads](https://img.shields.io/npm/dt/@cargosense/eslint-config.svg?logo=npm&style=for-the-badge)](https://www.npmjs.com/package/@cargosense/eslint-config)
7
+ [![Build](https://img.shields.io/github/actions/workflow/status/CargoSense/eslint-config/ci.yml?branch=main&logo=github&style=for-the-badge)](https://github.com/CargoSense/eslint-config/actions/workflows/ci.yml)
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ npm install --save-dev @cargosense/eslint-config
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ Using [ECMAScript module (ESM)](https://nodejs.org/api/esm.html) syntax:
18
+
19
+ ```js
20
+ // eslint.config.js
21
+ export { default } from "@cargosense/eslint-config";
22
+ ```
23
+
24
+ You may also apply this shared configuration to your project's customized configuration:
25
+
26
+ ```js
27
+ // eslint.config.js
28
+ import config from "@cargosense/eslint-config";
29
+
30
+ export default [
31
+ ...config,
32
+
33
+ {
34
+ "rules": {
35
+ // …
36
+ },
37
+ },
38
+ ];
39
+ ```
40
+
41
+ > [!TIP]
42
+ > ESLint is _extremely_ customizable. Refer to [the documentation](https://eslint.org/docs/latest/use/configure/configuration-files) for details.
43
+
44
+ ## License
45
+
46
+ eslint-config is freely available under the [MIT License](https://opensource.org/licenses/MIT).
package/index.js ADDED
@@ -0,0 +1,224 @@
1
+ import js from "@eslint/js";
2
+ import stylistic from "@stylistic/eslint-plugin";
3
+
4
+ import arrayFunc from "eslint-plugin-array-func";
5
+ import jsdoc from "eslint-plugin-jsdoc";
6
+ import n from "eslint-plugin-n";
7
+ import regexp from "eslint-plugin-regexp";
8
+ import sortClassMembers from "eslint-plugin-sort-class-members";
9
+
10
+ export default [
11
+ /**
12
+ * @see {@link https://www.npmjs.com/package/@eslint/js}
13
+ * @see {@link https://eslint.org/docs/latest/rules/}
14
+ */
15
+ js.configs.recommended,
16
+
17
+ /**
18
+ * @see {@link https://eslint.style/guide/config-presets}
19
+ * @see {@link https://eslint.style/packages/default}
20
+ */
21
+ stylistic.configs["recommended-flat"],
22
+
23
+ /**
24
+ * @see {@link https://www.npmjs.com/package/eslint-plugin-array-func}
25
+ */
26
+ arrayFunc.configs.all,
27
+
28
+ /**
29
+ * @see {@link https://www.npmjs.com/package/eslint-plugin-jsdoc}
30
+ */
31
+ jsdoc.configs["flat/recommended"],
32
+
33
+ /**
34
+ * @see {@link https://www.npmjs.com/package/eslint-plugin-n}
35
+ */
36
+ n.configs["flat/recommended"],
37
+
38
+ /**
39
+ * @see {@link https://www.npmjs.com/package/eslint-plugin-regexp}
40
+ */
41
+ regexp.configs["flat/recommended"],
42
+
43
+ /**
44
+ * @see {@link https://www.npmjs.com/package/eslint-plugin-sort-class-members}
45
+ */
46
+ sortClassMembers.configs["flat/recommended"],
47
+
48
+ /**
49
+ * @see {@link https://www.npmjs.com/package/@cargosense/eslint-config}
50
+ */
51
+ {
52
+ rules: {
53
+ /**
54
+ * Enforce consistent line breaks between array elements.
55
+ *
56
+ * @see {@link https://eslint.style/rules/default/array-element-newline}
57
+ */
58
+ "@stylistic/array-element-newline": ["error", "consistent"],
59
+
60
+ /**
61
+ * Enforce consistent usage of line breaks between arguments of a function
62
+ * call.
63
+ *
64
+ * @see {@link https://eslint.style/rules/js/function-call-argument-newline}
65
+ */
66
+ "@stylistic/function-call-argument-newline": ["error", "consistent"],
67
+
68
+ /**
69
+ * Disallow spaces between the function name and the opening parenthesis
70
+ * that calls it.
71
+ *
72
+ * @see {@link https://eslint.style/rules/default/function-call-spacing}
73
+ */
74
+ "@stylistic/function-call-spacing": ["error"],
75
+
76
+ /**
77
+ * Enforce a consistent location for an arrow function containing an
78
+ * implicit return.
79
+ *
80
+ * @see {@link https://eslint.style/rules/default/implicit-arrow-linebreak}
81
+ */
82
+ "@stylistic/implicit-arrow-linebreak": "error",
83
+
84
+ /**
85
+ * Enforce consistent line endings independent of operating system, VCS,
86
+ * or editor.
87
+ *
88
+ * @see {@link https://eslint.style/rules/default/linebreak-style}
89
+ */
90
+ "@stylistic/linebreak-style": "warn",
91
+
92
+ /**
93
+ * Enforce a maximum line length to increase code readability and
94
+ * maintainability.
95
+ *
96
+ * @see {@link https://eslint.style/rules/default/max-len}
97
+ */
98
+ "@stylistic/max-len": ["warn", {
99
+ code: 120,
100
+ comments: 80,
101
+ ignoreUrls: true,
102
+ tabWidth: 2,
103
+ }],
104
+
105
+ /**
106
+ * Disallow unnecessary semicolons.
107
+ *
108
+ * @see {@link https://eslint.style/rules/default/no-extra-semi}
109
+ */
110
+ "@stylistic/no-extra-semi": "error",
111
+
112
+ /**
113
+ * Warns against using the arrow function syntax in places where it could
114
+ * be confused with a comparison operator.
115
+ *
116
+ * @see {@link https://eslint.style/rules/default/no-confusing-arrow}
117
+ */
118
+ "@stylistic/no-confusing-arrow": "warn",
119
+
120
+ /**
121
+ * Enforce a consistent linebreak style for operators.
122
+ *
123
+ * @see {@link https://eslint.style/rules/default/operator-linebreak}
124
+ */
125
+ "@stylistic/operator-linebreak": ["error", "after"],
126
+
127
+ /**
128
+ * Disallow quotes around object literal property names that are not
129
+ * strictly required.
130
+ *
131
+ * @see {@link https://eslint.style/rules/default/quote-props}
132
+ */
133
+ "@stylistic/quote-props": ["error", "as-needed"],
134
+
135
+ /**
136
+ * Enforce the consistent use of either double quotes.
137
+ *
138
+ * @see {@link https://eslint.style/rules/default/quotes}
139
+ */
140
+ "@stylistic/quotes": ["error", "double", {
141
+ allowTemplateLiterals: true,
142
+ avoidEscape: false,
143
+ }],
144
+
145
+ /**
146
+ * Enforce consistent use of semicolons.
147
+ *
148
+ * @see {@link https://eslint.style/rules/default/semi}
149
+ */
150
+ "@stylistic/semi": ["error", "always"],
151
+
152
+ /**
153
+ * Enforce consistent spacing before function parentheses.
154
+ *
155
+ * @see {@link https://eslint.style/rules/js/space-before-function-paren}
156
+ */
157
+ "@stylistic/space-before-function-paren": ["error", {
158
+ anonymous: "never",
159
+ asyncArrow: "always",
160
+ named: "never",
161
+ }],
162
+
163
+ /**
164
+ * Control spacing around colons of `case` and `default` clauses in switch
165
+ * statements.
166
+ *
167
+ * @see {@link https://eslint.style/rules/default/switch-colon-spacing}
168
+ */
169
+ "@stylistic/switch-colon-spacing": "error",
170
+
171
+ /**
172
+ * Sorts tags by a specified sequence according to tag name, optionally
173
+ * adding line breaks between tag groups.
174
+ *
175
+ * @see {@link https://github.com/gajus/eslint-plugin-jsdoc/blob/HEAD/docs/rules/sort-tags.md}
176
+ */
177
+ "jsdoc/sort-tags": ["warn", { alphabetizeExtras: true }],
178
+
179
+ /**
180
+ * Enforce lines (or no lines) between tags.
181
+ *
182
+ * @see {@link https://github.com/gajus/eslint-plugin-jsdoc/blob/HEAD/docs/rules/tag-lines.md}
183
+ */
184
+ "jsdoc/tag-lines": ["warn", "any", { startLines: 1 }],
185
+
186
+ /**
187
+ * Report unsupported Node.js built-in APIs on the configured Node.js
188
+ * version.
189
+ *
190
+ * @see {@link https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-unsupported-features/node-builtins.md}
191
+ */
192
+ "n/no-unsupported-features/node-builtins": ["error", { allowExperimental: true }],
193
+
194
+ /**
195
+ * Disallow unused variables (excluding variables whose name begins with
196
+ * an underscore).
197
+ *
198
+ * @see {@link https://eslint.org/docs/latest/rules/no-unused-vars}
199
+ */
200
+ "no-unused-vars": ["error", {
201
+ argsIgnorePattern: "^_",
202
+ destructuredArrayIgnorePattern: "^_",
203
+ }],
204
+
205
+ /**
206
+ * Enforce sorted import declarations within modules.
207
+ *
208
+ * @see {@link https://eslint.org/docs/latest/rules/sort-imports}
209
+ */
210
+ "sort-imports": ["error", { allowSeparatedGroups: true }],
211
+
212
+ /**
213
+ * Require object keys to be sorted.
214
+ *
215
+ * @see {@link https://eslint.org/docs/latest/rules/sort-keys}
216
+ */
217
+ "sort-keys": ["error", "asc", {
218
+ allowLineSeparatedGroups: true,
219
+ caseSensitive: false,
220
+ natural: true,
221
+ }],
222
+ },
223
+ },
224
+ ];
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name" :"@cargosense/eslint-config",
3
+ "version": "0.1.0",
4
+ "description": "Shareable ESLint configuration.",
5
+ "keywords": [
6
+ "eslint-config",
7
+ "eslint",
8
+ "eslintconfig",
9
+ "javascript"
10
+ ],
11
+ "homepage": "https://github.com/CargoSense/eslint-config",
12
+ "bugs": "https://github.com/CargoSense/eslint-config/issues",
13
+ "license": "MIT",
14
+ "author": "CargoSense <npm@cargosense.com> (https://www.cargosense.com)",
15
+ "files": [
16
+ "index.js"
17
+ ],
18
+ "type": "module",
19
+ "exports": {
20
+ "./package.json": "./package.json",
21
+ ".": "./index.js"
22
+ },
23
+ "repository": "github:CargoSense/eslint-config",
24
+ "scripts": {
25
+ "lint": "npx eslint",
26
+ "test": "NODE_V8_COVERAGE=coverage node --experimental-test-coverage --test"
27
+ },
28
+ "dependencies": {
29
+ "@eslint/js": "^9.3.0",
30
+ "@stylistic/eslint-plugin": "^2.1.0",
31
+ "eslint-plugin-array-func": "^5.0.1",
32
+ "eslint-plugin-jsdoc": "^48.2.6",
33
+ "eslint-plugin-n": "^17.7.0",
34
+ "eslint-plugin-regexp": "^2.6.0",
35
+ "eslint-plugin-sort-class-members": "^1.20.0"
36
+ },
37
+ "devDependencies": {
38
+ "eslint": "^9.3.0"
39
+ },
40
+ "peerDependencies": {
41
+ "eslint": ">=9"
42
+ },
43
+ "overrides": {
44
+ "@typescript-eslint/utils": {
45
+ "eslint": ">=9"
46
+ }
47
+ },
48
+ "engines": {
49
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ }
54
+ }