| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | import { defineConfig, globalIgnores } from "eslint/config"; | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | import config from "eslint-config-webpack"; | 
					
						
							|  |  |  | import configs from "eslint-config-webpack/configs.js"; | 
					
						
							| 
									
										
										
										
											2025-03-07 23:32:55 +08:00
										 |  |  | import globals from "globals"; | 
					
						
							| 
									
										
										
										
											2024-07-30 21:48:58 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | export default defineConfig([ | 
					
						
							|  |  |  | 	globalIgnores([ | 
					
						
							|  |  |  | 		// Ignore some test files
 | 
					
						
							|  |  |  | 		"test/**/*.*", | 
					
						
							|  |  |  | 		"!test/*.js", | 
					
						
							|  |  |  | 		"!test/*.cjs", | 
					
						
							|  |  |  | 		"!test/*.mjs", | 
					
						
							|  |  |  | 		"!test/**/webpack.config.js", | 
					
						
							|  |  |  | 		"!test/**/test.config.js", | 
					
						
							|  |  |  | 		"!test/**/test.filter.js", | 
					
						
							|  |  |  | 		"test/cases/parsing/es2022/test.filter.js", | 
					
						
							|  |  |  | 		"!test/**/errors.js", | 
					
						
							|  |  |  | 		"!test/**/warnings.js", | 
					
						
							|  |  |  | 		"!test/**/deprecations.js", | 
					
						
							|  |  |  | 		"!test/**/infrastructure-log.js", | 
					
						
							|  |  |  | 		"!test/helpers/*.*", | 
					
						
							| 
									
										
										
										
											2025-05-01 04:52:14 +08:00
										 |  |  | 		"!test/benchmarkCases/**/*.mjs", | 
					
						
							|  |  |  | 		"!test/_helpers/**/*.mjs", | 
					
						
							| 
									
										
										
										
											2025-07-08 20:52:43 +08:00
										 |  |  | 		"!test/runner/*.js", | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 		"test/js/**/*.*", | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 		// TODO fix me
 | 
					
						
							|  |  |  | 		// This is not exactly typescript
 | 
					
						
							|  |  |  | 		"assembly/**/*.ts", | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 		// Ignore some folders
 | 
					
						
							|  |  |  | 		"benchmark", | 
					
						
							|  |  |  | 		"coverage", | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 		// Ignore generated files
 | 
					
						
							|  |  |  | 		"*.check.js", | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 		// Ignore not supported files
 | 
					
						
							|  |  |  | 		"*.d.ts", | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 		// Ignore precompiled schemas
 | 
					
						
							|  |  |  | 		"schemas/**/*.check.js", | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 		// Auto generation
 | 
					
						
							|  |  |  | 		"lib/util/semver.js", | 
					
						
							| 
									
										
										
										
											2024-07-31 09:37:24 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 		// Ignore some examples files
 | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 		"examples/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,md}", | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 		"!examples/*/webpack.config.js" | 
					
						
							|  |  |  | 	]), | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 		ignores: ["lib/**/*.runtime.js", "hot/*.js"], | 
					
						
							|  |  |  | 		extends: [config], | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 		rules: { | 
					
						
							| 
									
										
										
										
											2025-07-03 17:06:45 +08:00
										 |  |  | 			// Too noise
 | 
					
						
							|  |  |  | 			"jsdoc/require-property-description": "off", | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 			// We have helpers for the default configuration
 | 
					
						
							|  |  |  | 			"new-cap": [ | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 				"error", | 
					
						
							|  |  |  | 				{ | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 					newIsCapExceptions: [], | 
					
						
							|  |  |  | 					capIsNewExceptions: ["A", "F", "D", "MODULES_GROUPERS"] | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			], | 
					
						
							| 
									
										
										
										
											2025-07-03 17:06:45 +08:00
										 |  |  | 			// Revisit it in future
 | 
					
						
							|  |  |  | 			"id-length": "off", | 
					
						
							|  |  |  | 			// Revisit it in future
 | 
					
						
							|  |  |  | 			"no-use-before-define": "off", | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// TODO We need allow to have `_arg` in tooling and use `after-used` value for `args`
 | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 			"no-unused-vars": [ | 
					
						
							|  |  |  | 				"error", | 
					
						
							| 
									
										
										
										
											2024-07-31 09:37:24 +08:00
										 |  |  | 				{ | 
					
						
							|  |  |  | 					vars: "all", | 
					
						
							|  |  |  | 					varsIgnorePattern: "^_", | 
					
						
							|  |  |  | 					args: "none", | 
					
						
							|  |  |  | 					argsIgnorePattern: "^_", | 
					
						
							| 
									
										
										
										
											2024-07-31 15:37:05 +08:00
										 |  |  | 					caughtErrors: "all", | 
					
						
							| 
									
										
										
										
											2024-07-31 09:37:24 +08:00
										 |  |  | 					caughtErrorsIgnorePattern: "^_", | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 					destructuredArrayIgnorePattern: "^_", | 
					
						
							|  |  |  | 					ignoreRestSiblings: true, | 
					
						
							|  |  |  | 					ignoreClassWithStaticInitBlock: false, | 
					
						
							|  |  |  | 					reportUsedIgnorePattern: false | 
					
						
							| 
									
										
										
										
											2024-07-31 09:37:24 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			], | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 			// TODO enable me in future
 | 
					
						
							| 
									
										
										
										
											2025-07-03 17:06:45 +08:00
										 |  |  | 			"prefer-destructuring": "off" | 
					
						
							| 
									
										
										
										
											2024-07-31 12:23:44 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2024-07-31 15:37:05 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 		files: ["lib/**/*.js"], | 
					
						
							|  |  |  | 		extends: [configs["webpack/special"]] | 
					
						
							| 
									
										
										
										
											2024-07-31 15:37:05 +08:00
										 |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2024-07-31 12:23:44 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 		files: ["bin/**/*.js"], | 
					
						
							|  |  |  | 		// Allow to use `dynamic` import
 | 
					
						
							|  |  |  | 		languageOptions: { | 
					
						
							|  |  |  | 			ecmaVersion: 2020 | 
					
						
							| 
									
										
										
										
											2024-07-31 12:23:44 +08:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		rules: { | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 			"no-console": "off", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// Allow to use `dynamic` import and hashbang
 | 
					
						
							|  |  |  | 			"n/no-unsupported-features/es-syntax": [ | 
					
						
							| 
									
										
										
										
											2024-07-31 12:23:44 +08:00
										 |  |  | 				"error", | 
					
						
							|  |  |  | 				{ | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 					ignores: ["hashbang", "dynamic-import"] | 
					
						
							| 
									
										
										
										
											2024-07-31 12:23:44 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			] | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 		files: ["lib/**/*.runtime.js", "hot/*.js"], | 
					
						
							|  |  |  | 		extends: [configs["javascript/es5"]], | 
					
						
							|  |  |  | 		languageOptions: { | 
					
						
							|  |  |  | 			sourceType: "commonjs", | 
					
						
							|  |  |  | 			globals: { | 
					
						
							|  |  |  | 				...globals.browser, | 
					
						
							|  |  |  | 				...globals.es5, | 
					
						
							|  |  |  | 				Promise: false, | 
					
						
							|  |  |  | 				Map: false, | 
					
						
							|  |  |  | 				Set: false, | 
					
						
							|  |  |  | 				process: false | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		rules: { | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 			strict: "off", | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 			"block-scoped-var": "off", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// Allow logging
 | 
					
						
							|  |  |  | 			"no-console": "off", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// We replace `$VAR$` on real code
 | 
					
						
							|  |  |  | 			"no-unused-vars": "off", | 
					
						
							|  |  |  | 			"no-undef-init": "off", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			"id-length": "off", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			"jsdoc/require-jsdoc": "off", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// Revisit it in future
 | 
					
						
							|  |  |  | 			"no-use-before-define": "off", | 
					
						
							|  |  |  | 			"func-names": "off", | 
					
						
							|  |  |  | 			"func-style": "off" | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 		files: ["test/**/*.js"], | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 		rules: { | 
					
						
							| 
									
										
										
										
											2025-07-08 22:46:17 +08:00
										 |  |  | 			// Some our tests contain `package.json` without `engines`, but tests should work on Node.js@10, so let's disable it
 | 
					
						
							|  |  |  | 			"n/prefer-node-protocol": "off", | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 			// No need here, we have custom test logic, so except can be placed in different places
 | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 			"jest/no-standalone-expect": "off", | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// We have a lot of custom tests
 | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 			"jest/expect-expect": "off", | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// We have a lot of custom tests
 | 
					
						
							|  |  |  | 			"jest/no-confusing-set-timeout": "off" | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 		files: ["test/helpers/**/*.{js,cjs,mjs}"], | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 		languageOptions: { | 
					
						
							|  |  |  | 			globals: { | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 				...globals.jest | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2024-07-31 04:09:42 +08:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		rules: { | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 			"no-eval": "off", | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 			"no-console": "off", | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// Allow to use any builtins, syntax and node API in tests
 | 
					
						
							|  |  |  | 			"n/no-unsupported-features/es-builtins": "off", | 
					
						
							|  |  |  | 			"n/no-unsupported-features/es-syntax": "off", | 
					
						
							|  |  |  | 			"n/no-unsupported-features/node-builtins": "off" | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 		files: ["test/**/*.mjs"], | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 		languageOptions: { | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 			ecmaVersion: 2022 | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2024-08-02 23:42:44 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 		files: ["setup/**/*.js", "tooling/**/*.js"], | 
					
						
							|  |  |  | 		languageOptions: { | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 			ecmaVersion: 2022 | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2025-03-07 23:32:55 +08:00
										 |  |  | 		rules: { | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 			"no-console": "off" | 
					
						
							| 
									
										
										
										
											2025-03-07 23:32:55 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		files: ["test/Compiler-filesystem-caching.test.js"], | 
					
						
							|  |  |  | 		languageOptions: { | 
					
						
							|  |  |  | 			ecmaVersion: 2022 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 		files: [ | 
					
						
							|  |  |  | 			"test/configCases/{dll-plugin-entry,dll-plugin-side-effects,dll-plugin}/**/webpack.config.js", | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 			"test/NodeTemplatePlugin.test.js", | 
					
						
							|  |  |  | 			"test/PersistentCaching.test.js" | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | 		], | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 		rules: { | 
					
						
							| 
									
										
										
										
											2025-07-09 21:42:54 +08:00
										 |  |  | 			"import/extensions": "off", | 
					
						
							|  |  |  | 			"import/no-unresolved": "off" | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		files: ["examples/**/*.js"], | 
					
						
							|  |  |  | 		rules: { | 
					
						
							|  |  |  | 			// For examples purposes
 | 
					
						
							|  |  |  | 			"n/no-unsupported-features/es-builtins": "off", | 
					
						
							|  |  |  | 			"n/no-unsupported-features/es-syntax": "off", | 
					
						
							|  |  |  | 			"n/no-unsupported-features/node-builtins": "off", | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-02 20:10:54 +08:00
										 |  |  | 			"import/extensions": "off", | 
					
						
							|  |  |  | 			"import/no-unresolved": "off" | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2025-04-22 05:17:46 +08:00
										 |  |  | ]); |