@adobe/eslint-config-helix 2.0.9 → 3.0.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/rules/es6.js ADDED
@@ -0,0 +1,199 @@
1
+ /*
2
+ * Copyright 2024 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import globals from 'globals';
13
+
14
+ export default {
15
+ languageOptions: {
16
+ ecmaVersion: 6,
17
+ sourceType: 'module',
18
+ parserOptions: {
19
+ ecmaFeatures: {
20
+ generators: false,
21
+ objectLiteralDuplicateProperties: false,
22
+ },
23
+ },
24
+ globals: {
25
+ ...globals.es6,
26
+ },
27
+ },
28
+ rules: {
29
+ // enforces no braces where they can be omitted
30
+ // https://eslint.org/docs/rules/arrow-body-style
31
+ // TODO: enable requireReturnForObjectLiteral?
32
+ 'arrow-body-style': ['error', 'as-needed', {
33
+ requireReturnForObjectLiteral: false,
34
+ }],
35
+
36
+ // require parens in arrow function arguments
37
+ // https://eslint.org/docs/rules/arrow-parens
38
+ 'arrow-parens': ['error', 'always'],
39
+
40
+ // require space before/after arrow function's arrow
41
+ // https://eslint.org/docs/rules/arrow-spacing
42
+ 'arrow-spacing': ['error', { before: true, after: true }],
43
+
44
+ // verify super() callings in constructors
45
+ 'constructor-super': 'error',
46
+
47
+ // enforce the spacing around the * in generator functions
48
+ // https://eslint.org/docs/rules/generator-star-spacing
49
+ 'generator-star-spacing': ['error', { before: false, after: true }],
50
+
51
+ // disallow modifying variables of class declarations
52
+ // https://eslint.org/docs/rules/no-class-assign
53
+ 'no-class-assign': 'error',
54
+
55
+ // disallow arrow functions where they could be confused with comparisons
56
+ // https://eslint.org/docs/rules/no-confusing-arrow
57
+ 'no-confusing-arrow': ['error', {
58
+ allowParens: true,
59
+ }],
60
+
61
+ // disallow modifying variables that are declared using const
62
+ 'no-const-assign': 'error',
63
+
64
+ // disallow duplicate class members
65
+ // https://eslint.org/docs/rules/no-dupe-class-members
66
+ 'no-dupe-class-members': 'error',
67
+
68
+ // disallow importing from the same path more than once
69
+ // https://eslint.org/docs/rules/no-duplicate-imports
70
+ // replaced by https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
71
+ 'no-duplicate-imports': 'off',
72
+
73
+ // disallow symbol constructor
74
+ // https://eslint.org/docs/rules/no-new-symbol
75
+ 'no-new-symbol': 'error',
76
+
77
+ // Disallow specified names in exports
78
+ // https://eslint.org/docs/rules/no-restricted-exports
79
+ 'no-restricted-exports': ['error', {
80
+ restrictedNamedExports: [
81
+ 'default', // use `export default` to provide a default export
82
+ 'then', // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
83
+ ],
84
+ }],
85
+
86
+ // disallow specific imports
87
+ // https://eslint.org/docs/rules/no-restricted-imports
88
+ 'no-restricted-imports': ['off', {
89
+ paths: [],
90
+ patterns: [],
91
+ }],
92
+
93
+ // disallow to use this/super before super() calling in constructors.
94
+ // https://eslint.org/docs/rules/no-this-before-super
95
+ 'no-this-before-super': 'error',
96
+
97
+ // disallow useless computed property keys
98
+ // https://eslint.org/docs/rules/no-useless-computed-key
99
+ 'no-useless-computed-key': 'error',
100
+
101
+ // disallow unnecessary constructor
102
+ // https://eslint.org/docs/rules/no-useless-constructor
103
+ 'no-useless-constructor': 'error',
104
+
105
+ // disallow renaming import, export, and destructured assignments to the same name
106
+ // https://eslint.org/docs/rules/no-useless-rename
107
+ 'no-useless-rename': ['error', {
108
+ ignoreDestructuring: false,
109
+ ignoreImport: false,
110
+ ignoreExport: false,
111
+ }],
112
+
113
+ // require let or const instead of var
114
+ 'no-var': 'error',
115
+
116
+ // require method and property shorthand syntax for object literals
117
+ // https://eslint.org/docs/rules/object-shorthand
118
+ 'object-shorthand': ['error', 'always', {
119
+ ignoreConstructors: false,
120
+ avoidQuotes: true,
121
+ }],
122
+
123
+ // suggest using arrow functions as callbacks
124
+ 'prefer-arrow-callback': ['error', {
125
+ allowNamedFunctions: false,
126
+ allowUnboundThis: true,
127
+ }],
128
+
129
+ // suggest using of const declaration for variables that are never modified after declared
130
+ 'prefer-const': ['error', {
131
+ destructuring: 'any',
132
+ ignoreReadBeforeAssign: true,
133
+ }],
134
+
135
+ // Prefer destructuring from arrays and objects
136
+ // https://eslint.org/docs/rules/prefer-destructuring
137
+ 'prefer-destructuring': ['error', {
138
+ VariableDeclarator: {
139
+ array: false,
140
+ object: true,
141
+ },
142
+ AssignmentExpression: {
143
+ array: true,
144
+ object: false,
145
+ },
146
+ }, {
147
+ enforceForRenamedProperties: false,
148
+ }],
149
+
150
+ // disallow parseInt() in favor of binary, octal, and hexadecimal literals
151
+ // https://eslint.org/docs/rules/prefer-numeric-literals
152
+ 'prefer-numeric-literals': 'error',
153
+
154
+ // suggest using Reflect methods where applicable
155
+ // https://eslint.org/docs/rules/prefer-reflect
156
+ 'prefer-reflect': 'off',
157
+
158
+ // use rest parameters instead of arguments
159
+ // https://eslint.org/docs/rules/prefer-rest-params
160
+ 'prefer-rest-params': 'error',
161
+
162
+ // suggest using the spread syntax instead of .apply()
163
+ // https://eslint.org/docs/rules/prefer-spread
164
+ 'prefer-spread': 'error',
165
+
166
+ // suggest using template literals instead of string concatenation
167
+ // https://eslint.org/docs/rules/prefer-template
168
+ 'prefer-template': 'error',
169
+
170
+ // disallow generator functions that do not have yield
171
+ // https://eslint.org/docs/rules/require-yield
172
+ 'require-yield': 'error',
173
+
174
+ // enforce spacing between object rest-spread
175
+ // https://eslint.org/docs/rules/rest-spread-spacing
176
+ 'rest-spread-spacing': ['error', 'never'],
177
+
178
+ // import sorting
179
+ // https://eslint.org/docs/rules/sort-imports
180
+ 'sort-imports': ['off', {
181
+ ignoreCase: false,
182
+ ignoreDeclarationSort: false,
183
+ ignoreMemberSort: false,
184
+ memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
185
+ }],
186
+
187
+ // require a Symbol description
188
+ // https://eslint.org/docs/rules/symbol-description
189
+ 'symbol-description': 'error',
190
+
191
+ // enforce usage of spacing in template strings
192
+ // https://eslint.org/docs/rules/template-curly-spacing
193
+ 'template-curly-spacing': 'error',
194
+
195
+ // enforce spacing around the * in yield* expressions
196
+ // https://eslint.org/docs/rules/yield-star-spacing
197
+ 'yield-star-spacing': ['error', 'after'],
198
+ },
199
+ };
@@ -0,0 +1,102 @@
1
+ /*
2
+ * Copyright 2024 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+
13
+ function headerLineMatches(expected, actual) {
14
+ if (expected.pattern) {
15
+ return new RegExp(expected.pattern).test(actual);
16
+ }
17
+ return expected === actual;
18
+ }
19
+
20
+ function headerMatches(expected, actual) {
21
+ if (expected.length !== actual.length) {
22
+ return false;
23
+ }
24
+ for (let i = 0; i < expected.length; i += 1) {
25
+ if (!headerLineMatches(expected[i], actual[i])) {
26
+ return false;
27
+ }
28
+ }
29
+ return true;
30
+ }
31
+
32
+ /**
33
+ * Returns the header comment.
34
+ *
35
+ * @param {Program} program program node
36
+ * @param {import('eslint').Rule.RuleContext} context rule context
37
+ * @returns header comment or null
38
+ */
39
+ function getHeaderComment(program, context) {
40
+ const comments = context.sourceCode.getCommentsBefore(program);
41
+ if (!comments.length) {
42
+ return null;
43
+ }
44
+ const startingIndex = comments[0].type === 'Shebang' ? 1 : 0;
45
+ if (comments.length <= startingIndex) {
46
+ return null;
47
+ }
48
+ if (comments[startingIndex].type === 'Block') {
49
+ return comments[startingIndex].value.split('\n');
50
+ }
51
+ return null;
52
+ }
53
+
54
+ export default {
55
+ rules: {
56
+ /** @type {import('eslint').Rule.RuleModule} */
57
+ header: {
58
+ meta: {
59
+ type: 'layout',
60
+ docs: {
61
+ description:
62
+ 'Verifies the content and format of a file\'s leading comment block.',
63
+ recommended: false,
64
+ },
65
+ messages: {
66
+ missingHeader: 'No header found.',
67
+ headerContentMismatch: 'Header does not include expected content.',
68
+ },
69
+ fixable: 'code',
70
+ schema: [
71
+ {
72
+ type: 'object',
73
+ properties: {
74
+ block: {
75
+ type: 'array',
76
+ },
77
+ },
78
+ required: ['block'],
79
+ },
80
+ ],
81
+ },
82
+ create: (context) => ({
83
+ Program: (node) => {
84
+ const headerComment = getHeaderComment(node, context);
85
+ if (!headerComment) {
86
+ context.report({
87
+ node,
88
+ messageId: 'missingHeader',
89
+ });
90
+ }
91
+ const { options: [{ block }] } = context;
92
+ if (!headerMatches(block, headerComment)) {
93
+ context.report({
94
+ node,
95
+ messageId: 'headerContentMismatch',
96
+ });
97
+ }
98
+ },
99
+ }),
100
+ },
101
+ },
102
+ };
@@ -0,0 +1,290 @@
1
+ /*
2
+ * Copyright 2024 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import importPlugin from 'eslint-plugin-import';
13
+
14
+ export default {
15
+ plugins: {
16
+ import: importPlugin,
17
+ },
18
+
19
+ settings: {
20
+ 'import/resolver': {
21
+ node: {
22
+ extensions: ['.mjs', '.js', '.json'],
23
+ },
24
+ },
25
+ 'import/extensions': [
26
+ '.js',
27
+ '.mjs',
28
+ '.jsx',
29
+ ],
30
+ 'import/core-modules': [
31
+ ],
32
+ 'import/ignore': [
33
+ 'node_modules',
34
+ '\\.(coffee|scss|css|less|hbs|svg|json)$',
35
+ ],
36
+ },
37
+
38
+ rules: {
39
+ // Static analysis:
40
+
41
+ // ensure imports point to files/modules that can be resolved
42
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md
43
+ 'import/no-unresolved': ['error', { commonjs: true, caseSensitive: true }],
44
+
45
+ // ensure named imports coupled with named exports
46
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/named.md#when-not-to-use-it
47
+ 'import/named': 'error',
48
+
49
+ // ensure default import coupled with default export
50
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/default.md#when-not-to-use-it
51
+ 'import/default': 'off',
52
+
53
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/namespace.md
54
+ 'import/namespace': 'off',
55
+
56
+ // Helpful warnings:
57
+
58
+ // disallow invalid exports, e.g. multiple defaults
59
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/export.md
60
+ 'import/export': 'error',
61
+
62
+ // do not allow a default import name to match a named export
63
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-as-default.md
64
+ 'import/no-named-as-default': 'error',
65
+
66
+ // warn on accessing default export property names that are also named exports
67
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-as-default-member.md
68
+ 'import/no-named-as-default-member': 'error',
69
+
70
+ // disallow use of jsdoc-marked-deprecated imports
71
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
72
+ 'import/no-deprecated': 'off',
73
+
74
+ // Forbid the use of extraneous packages
75
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
76
+ // paths are treated both as absolute paths, and relative to process.cwd()
77
+ 'import/no-extraneous-dependencies': ['error', {
78
+ devDependencies: [
79
+ 'test/**', // tape, common npm pattern
80
+ 'tests/**', // also common npm pattern
81
+ 'spec/**', // mocha, rspec-like pattern
82
+ '**/__tests__/**', // jest pattern
83
+ '**/__mocks__/**', // jest pattern
84
+ 'test.{js,jsx}', // repos with a single test file
85
+ 'test-*.{js,jsx}', // repos with multiple top-level test files
86
+ '**/*{.,_}{test,spec}.{js,jsx}', // tests where the extension or filename suffix denotes that it is a test
87
+ '**/jest.config.js', // jest config
88
+ '**/jest.setup.js', // jest setup
89
+ '**/vue.config.js', // vue-cli config
90
+ '**/webpack.config.js', // webpack config
91
+ '**/webpack.config.*.js', // webpack config
92
+ '**/rollup.config.js', // rollup config
93
+ '**/rollup.config.*.js', // rollup config
94
+ '**/gulpfile.js', // gulp config
95
+ '**/gulpfile.*.js', // gulp config
96
+ '**/Gruntfile{,.js}', // grunt config
97
+ '**/protractor.conf.js', // protractor config
98
+ '**/protractor.conf.*.js', // protractor config
99
+ '**/karma.conf.js', // karma config
100
+ '**/.eslintrc.js', // eslint config
101
+ ],
102
+ optionalDependencies: false,
103
+ }],
104
+
105
+ // Forbid mutable exports
106
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-mutable-exports.md
107
+ 'import/no-mutable-exports': 'error',
108
+
109
+ // Module systems:
110
+
111
+ // disallow require()
112
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md
113
+ 'import/no-commonjs': 'off',
114
+
115
+ // disallow AMD require/define
116
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-amd.md
117
+ 'import/no-amd': 'error',
118
+
119
+ // No Node.js builtin modules
120
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-nodejs-modules.md
121
+ // TODO: enable?
122
+ 'import/no-nodejs-modules': 'off',
123
+
124
+ // Style guide:
125
+
126
+ // disallow non-import statements appearing before import statements
127
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/first.md
128
+ 'import/first': 'error',
129
+
130
+ // disallow non-import statements appearing before import statements
131
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/imports-first.md
132
+ // deprecated: use `import/first`
133
+ 'import/imports-first': 'off',
134
+
135
+ // disallow duplicate imports
136
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-duplicates.md
137
+ 'import/no-duplicates': 'error',
138
+
139
+ // disallow namespace imports
140
+ // TODO: enable?
141
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-namespace.md
142
+ 'import/no-namespace': 'off',
143
+
144
+ // Ensure consistent use of file extension within the import path
145
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/extensions.md
146
+ 'import/extensions': ['error', 'ignorePackages', {
147
+ js: 'never',
148
+ mjs: 'never',
149
+ jsx: 'never',
150
+ }],
151
+
152
+ // ensure absolute imports are above relative imports and that unassigned imports are ignored
153
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/order.md
154
+ // TODO: enforce a stricter convention in module import order?
155
+ 'import/order': ['error', { groups: [['builtin', 'external', 'internal']] }],
156
+
157
+ // Require a newline after the last import/require in a group
158
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/newline-after-import.md
159
+ 'import/newline-after-import': 'error',
160
+
161
+ // Require modules with a single export to use a default export
162
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
163
+ 'import/prefer-default-export': 'error',
164
+
165
+ // Restrict which files can be imported in a given folder
166
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-restricted-paths.md
167
+ 'import/no-restricted-paths': 'off',
168
+
169
+ // Forbid modules to have too many dependencies
170
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/max-dependencies.md
171
+ 'import/max-dependencies': ['off', { max: 10 }],
172
+
173
+ // Forbid import of modules using absolute paths
174
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-absolute-path.md
175
+ 'import/no-absolute-path': 'error',
176
+
177
+ // Forbid require() calls with expressions
178
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-dynamic-require.md
179
+ 'import/no-dynamic-require': 'error',
180
+
181
+ // prevent importing the submodules of other modules
182
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-internal-modules.md
183
+ 'import/no-internal-modules': ['off', {
184
+ allow: [],
185
+ }],
186
+
187
+ // Warn if a module could be mistakenly parsed as a script by a consumer
188
+ // leveraging Unambiguous JavaScript Grammar
189
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/unambiguous.md
190
+ // this should not be enabled until this proposal has at least been *presented* to TC39.
191
+ // At the moment, it's not a thing.
192
+ 'import/unambiguous': 'off',
193
+
194
+ // Forbid Webpack loader syntax in imports
195
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-webpack-loader-syntax.md
196
+ 'import/no-webpack-loader-syntax': 'error',
197
+
198
+ // Prevent unassigned imports
199
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-unassigned-import.md
200
+ // importing for side effects is perfectly acceptable, if you need side effects.
201
+ 'import/no-unassigned-import': 'off',
202
+
203
+ // Prevent importing the default as if it were named
204
+ // https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-named-default.md
205
+ 'import/no-named-default': 'error',
206
+
207
+ // Reports if a module's default export is unnamed
208
+ // https://github.com/import-js/eslint-plugin-import/blob/d9b712ac7fd1fddc391f7b234827925c160d956f/docs/rules/no-anonymous-default-export.md
209
+ 'import/no-anonymous-default-export': ['off', {
210
+ allowArray: false,
211
+ allowArrowFunction: false,
212
+ allowAnonymousClass: false,
213
+ allowAnonymousFunction: false,
214
+ allowLiteral: false,
215
+ allowObject: false,
216
+ }],
217
+
218
+ // This rule enforces that all exports are declared at the bottom of the file.
219
+ // https://github.com/import-js/eslint-plugin-import/blob/98acd6afd04dcb6920b81330114e146dc8532ea4/docs/rules/exports-last.md
220
+ // TODO: enable?
221
+ 'import/exports-last': 'off',
222
+
223
+ // Reports when named exports are not grouped together in a single export declaration
224
+ // or when multiple assignments to CommonJS module.exports or exports object are present
225
+ // in a single file.
226
+ // https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/group-exports.md
227
+ 'import/group-exports': 'off',
228
+
229
+ // forbid default exports. this is a terrible rule, do not use it.
230
+ // https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-default-export.md
231
+ 'import/no-default-export': 'off',
232
+
233
+ // Prohibit named exports. this is a terrible rule, do not use it.
234
+ // https://github.com/import-js/eslint-plugin-import/blob/1ec80fa35fa1819e2d35a70e68fb6a149fb57c5e/docs/rules/no-named-export.md
235
+ 'import/no-named-export': 'off',
236
+
237
+ // Forbid a module from importing itself
238
+ // https://github.com/import-js/eslint-plugin-import/blob/44a038c06487964394b1e15b64f3bd34e5d40cde/docs/rules/no-self-import.md
239
+ 'import/no-self-import': 'error',
240
+
241
+ // Forbid cyclical dependencies between modules
242
+ // https://github.com/import-js/eslint-plugin-import/blob/d81f48a2506182738409805f5272eff4d77c9348/docs/rules/no-cycle.md
243
+ 'import/no-cycle': ['error', { maxDepth: '∞' }],
244
+
245
+ // Ensures that there are no useless path segments
246
+ // https://github.com/import-js/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/no-useless-path-segments.md
247
+ 'import/no-useless-path-segments': ['error', { commonjs: true }],
248
+
249
+ // dynamic imports require a leading comment with a webpackChunkName
250
+ // https://github.com/import-js/eslint-plugin-import/blob/ebafcbf59ec9f653b2ac2a0156ca3bcba0a7cf57/docs/rules/dynamic-import-chunkname.md
251
+ 'import/dynamic-import-chunkname': ['off', {
252
+ importFunctions: [],
253
+ webpackChunknameFormat: '[0-9a-zA-Z-_/.]+',
254
+ }],
255
+
256
+ // Use this rule to prevent imports to folders in relative parent paths.
257
+ // https://github.com/import-js/eslint-plugin-import/blob/c34f14f67f077acd5a61b3da9c0b0de298d20059/docs/rules/no-relative-parent-imports.md
258
+ 'import/no-relative-parent-imports': 'off',
259
+
260
+ // Reports modules without any exports, or with unused exports
261
+ // https://github.com/import-js/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md
262
+ // TODO: enable once it supports CJS
263
+ 'import/no-unused-modules': ['off', {
264
+ ignoreExports: [],
265
+ missingExports: true,
266
+ unusedExports: true,
267
+ }],
268
+
269
+ // eslint-disable-next-line max-len
270
+ // Reports the use of import declarations with CommonJS exports in any module except for the main module.
271
+ // https://github.com/import-js/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-import-module-exports.md
272
+ 'import/no-import-module-exports': ['error', {
273
+ exceptions: [],
274
+ }],
275
+
276
+ // Use this rule to prevent importing packages through relative paths.
277
+ // https://github.com/import-js/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-relative-packages.md
278
+ 'import/no-relative-packages': 'error',
279
+
280
+ // enforce a consistent style for type specifiers (inline or top-level)
281
+ // https://github.com/import-js/eslint-plugin-import/blob/d5fc8b670dc8e6903dbb7b0894452f60c03089f5/docs/rules/consistent-type-specifier-style.md
282
+ // TODO, semver-major: enable (just in case)
283
+ 'import/consistent-type-specifier-style': ['off', 'prefer-inline'],
284
+
285
+ // Reports the use of empty named import blocks.
286
+ // https://github.com/import-js/eslint-plugin-import/blob/d5fc8b670dc8e6903dbb7b0894452f60c03089f5/docs/rules/no-empty-named-blocks.md
287
+ // TODO, semver-minor: enable
288
+ 'import/no-empty-named-blocks': 'off',
289
+ },
290
+ };
package/rules/node.js ADDED
@@ -0,0 +1,57 @@
1
+ /*
2
+ * Copyright 2024 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import globals from 'globals';
13
+
14
+ export default {
15
+ languageOptions: {
16
+ globals: {
17
+ ...globals.node,
18
+ },
19
+ },
20
+ rules: {
21
+ // enforce return after a callback
22
+ 'callback-return': 'off',
23
+
24
+ // require all requires be top-level
25
+ // https://eslint.org/docs/rules/global-require
26
+ 'global-require': 'error',
27
+
28
+ // enforces error handling in callbacks (node environment)
29
+ 'handle-callback-err': 'off',
30
+
31
+ // disallow use of the Buffer() constructor
32
+ // https://eslint.org/docs/rules/no-buffer-constructor
33
+ 'no-buffer-constructor': 'error',
34
+
35
+ // disallow mixing regular variable and require declarations
36
+ 'no-mixed-requires': ['off', false],
37
+
38
+ // disallow use of new operator with the require function
39
+ 'no-new-require': 'error',
40
+
41
+ // disallow string concatenation with __dirname and __filename
42
+ // https://eslint.org/docs/rules/no-path-concat
43
+ 'no-path-concat': 'error',
44
+
45
+ // disallow use of process.env
46
+ 'no-process-env': 'off',
47
+
48
+ // disallow process.exit()
49
+ 'no-process-exit': 'off',
50
+
51
+ // restrict usage of specified node modules
52
+ 'no-restricted-modules': 'off',
53
+
54
+ // disallow use of synchronous methods (off by default)
55
+ 'no-sync': 'off',
56
+ },
57
+ };
@@ -0,0 +1,17 @@
1
+ /*
2
+ * Copyright 2024 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ export default {
13
+ rules: {
14
+ // babel inserts `'use strict';` for us
15
+ strict: ['error', 'never'],
16
+ },
17
+ };