| 
									
										
										
										
											2025-03-07 23:32:55 +08:00
										 |  |  | import js from "@eslint/js"; | 
					
						
							|  |  |  | import prettier from "eslint-plugin-prettier"; | 
					
						
							|  |  |  | import n from "eslint-plugin-n"; | 
					
						
							|  |  |  | import jest from "eslint-plugin-jest"; | 
					
						
							|  |  |  | import jsdoc from "eslint-plugin-jsdoc"; | 
					
						
							|  |  |  | import prettierConfig from "eslint-config-prettier"; | 
					
						
							|  |  |  | import globals from "globals"; | 
					
						
							|  |  |  | import stylistic from "@stylistic/eslint-plugin"; | 
					
						
							|  |  |  | import unicorn from "eslint-plugin-unicorn"; | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-31 09:37:24 +08:00
										 |  |  | const nodeConfig = n.configs["flat/recommended"]; | 
					
						
							| 
									
										
										
										
											2024-07-30 21:48:58 +08:00
										 |  |  | const jsdocConfig = jsdoc.configs["flat/recommended-typescript-flavor-error"]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-07 23:32:55 +08:00
										 |  |  | export default [ | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		ignores: [ | 
					
						
							|  |  |  | 			// Ignore some test files
 | 
					
						
							|  |  |  | 			"test/**/*.*", | 
					
						
							|  |  |  | 			"!test/*.js", | 
					
						
							|  |  |  | 			"!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", | 
					
						
							| 
									
										
										
										
											2024-11-01 21:55:49 +08:00
										 |  |  | 			"!test/**/infrastructure-log.js", | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 			"!test/helpers/*.*", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// Ignore some folders
 | 
					
						
							|  |  |  | 			"benchmark", | 
					
						
							|  |  |  | 			"coverage", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// Ignore generated files
 | 
					
						
							|  |  |  | 			"*.check.js", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// Ignore not supported files
 | 
					
						
							|  |  |  | 			"*.d.ts", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// Ignore precompiled schemas
 | 
					
						
							|  |  |  | 			"schemas/**/*.check.js", | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-31 09:37:24 +08:00
										 |  |  | 			// Auto generation
 | 
					
						
							|  |  |  | 			"lib/util/semver.js", | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 			// Ignore some examples files
 | 
					
						
							|  |  |  | 			"examples/**/*.js", | 
					
						
							|  |  |  | 			"examples/**/*.mjs", | 
					
						
							|  |  |  | 			"!examples/*/webpack.config.js" | 
					
						
							|  |  |  | 		] | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 		...js.configs.recommended, | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 		languageOptions: { | 
					
						
							|  |  |  | 			ecmaVersion: 2018, | 
					
						
							|  |  |  | 			globals: { | 
					
						
							|  |  |  | 				...globals.node, | 
					
						
							| 
									
										
										
										
											2024-07-31 04:09:42 +08:00
										 |  |  | 				...globals.es2018, | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 				WebAssembly: true | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		linterOptions: { | 
					
						
							|  |  |  | 			reportUnusedDisableDirectives: true | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		rules: { | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 			...js.configs.recommended.rules, | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 			"no-template-curly-in-string": "error", | 
					
						
							|  |  |  | 			"no-caller": "error", | 
					
						
							|  |  |  | 			"no-control-regex": "off", | 
					
						
							|  |  |  | 			yoda: "error", | 
					
						
							|  |  |  | 			eqeqeq: "error", | 
					
						
							|  |  |  | 			"eol-last": "error", | 
					
						
							|  |  |  | 			"no-extra-bind": "warn", | 
					
						
							|  |  |  | 			"no-process-exit": "warn", | 
					
						
							|  |  |  | 			"no-use-before-define": "off", | 
					
						
							|  |  |  | 			"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: "^_", | 
					
						
							|  |  |  | 					ignoreRestSiblings: true | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 			], | 
					
						
							|  |  |  | 			"no-inner-declarations": "error", | 
					
						
							| 
									
										
										
										
											2024-07-31 04:09:42 +08:00
										 |  |  | 			"prefer-const": [ | 
					
						
							|  |  |  | 				"error", | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					destructuring: "all", | 
					
						
							|  |  |  | 					ignoreReadBeforeAssign: true | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			], | 
					
						
							|  |  |  | 			"object-shorthand": "error", | 
					
						
							| 
									
										
										
										
											2024-07-31 04:21:27 +08:00
										 |  |  | 			"no-else-return": "error", | 
					
						
							| 
									
										
										
										
											2024-07-31 04:54:55 +08:00
										 |  |  | 			"no-lonely-if": "error", | 
					
						
							| 
									
										
										
										
											2024-07-31 06:15:03 +08:00
										 |  |  | 			"no-undef-init": "error", | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 			// Disallow ts-ignore directive. Use ts-expect-error instead
 | 
					
						
							|  |  |  | 			"no-warning-comments": ["error", { terms: ["@ts-ignore"] }], | 
					
						
							| 
									
										
										
										
											2024-07-31 09:37:24 +08:00
										 |  |  | 			"no-constructor-return": "error", | 
					
						
							|  |  |  | 			"symbol-description": "error", | 
					
						
							|  |  |  | 			"array-callback-return": [ | 
					
						
							| 
									
										
										
										
											2024-06-11 21:26:12 +08:00
										 |  |  | 				"error", | 
					
						
							|  |  |  | 				{ | 
					
						
							| 
									
										
										
										
											2024-07-31 09:37:24 +08:00
										 |  |  | 					allowImplicit: true | 
					
						
							| 
									
										
										
										
											2024-06-11 21:26:12 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			], | 
					
						
							| 
									
										
										
										
											2024-07-31 09:37:24 +08:00
										 |  |  | 			"no-promise-executor-return": "error", | 
					
						
							|  |  |  | 			"no-undef": "error", | 
					
						
							|  |  |  | 			"guard-for-in": "error", | 
					
						
							|  |  |  | 			"no-constant-condition": "error", | 
					
						
							|  |  |  | 			camelcase: [ | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 				"error", | 
					
						
							| 
									
										
										
										
											2024-07-31 09:37:24 +08:00
										 |  |  | 				{ | 
					
						
							|  |  |  | 					allow: [ | 
					
						
							|  |  |  | 						"__webpack_require__", | 
					
						
							|  |  |  | 						"__webpack_public_path__", | 
					
						
							|  |  |  | 						"__webpack_base_uri__", | 
					
						
							|  |  |  | 						"__webpack_modules__", | 
					
						
							|  |  |  | 						"__webpack_chunk_load__", | 
					
						
							|  |  |  | 						"__non_webpack_require__", | 
					
						
							|  |  |  | 						"__webpack_nonce__", | 
					
						
							|  |  |  | 						"__webpack_hash__", | 
					
						
							|  |  |  | 						"__webpack_chunkname__", | 
					
						
							|  |  |  | 						"__webpack_get_script_filename__", | 
					
						
							|  |  |  | 						"__webpack_runtime_id__", | 
					
						
							|  |  |  | 						"__system_context__", | 
					
						
							|  |  |  | 						"__webpack_share_scopes__", | 
					
						
							|  |  |  | 						"__webpack_init_sharing__", | 
					
						
							|  |  |  | 						"__webpack_require_module__", | 
					
						
							|  |  |  | 						"_stream_duplex", | 
					
						
							|  |  |  | 						"_stream_passthrough", | 
					
						
							|  |  |  | 						"_stream_readable", | 
					
						
							|  |  |  | 						"_stream_transform", | 
					
						
							|  |  |  | 						"_stream_writable", | 
					
						
							|  |  |  | 						"string_decoder" | 
					
						
							|  |  |  | 					] | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			], | 
					
						
							|  |  |  | 			"prefer-exponentiation-operator": "error", | 
					
						
							|  |  |  | 			"no-useless-return": "error", | 
					
						
							|  |  |  | 			"no-return-assign": "error", | 
					
						
							|  |  |  | 			"default-case-last": "error", | 
					
						
							|  |  |  | 			"default-param-last": "error", | 
					
						
							|  |  |  | 			"dot-notation": "error", | 
					
						
							|  |  |  | 			"grouped-accessor-pairs": "error", | 
					
						
							|  |  |  | 			"id-match": [ | 
					
						
							|  |  |  | 				"error", | 
					
						
							|  |  |  | 				"^[$a-zA-Z_][$a-zA-Z0-9_]*$", | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					properties: true | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			], | 
					
						
							|  |  |  | 			"no-extra-label": "error", | 
					
						
							|  |  |  | 			"no-label-var": "error", | 
					
						
							|  |  |  | 			"no-lone-blocks": "error", | 
					
						
							|  |  |  | 			"no-multi-str": "error", | 
					
						
							|  |  |  | 			"no-new-func": "error", | 
					
						
							|  |  |  | 			"no-unneeded-ternary": ["error", { defaultAssignment: false }], | 
					
						
							|  |  |  | 			"no-useless-call": "error", | 
					
						
							|  |  |  | 			"no-useless-concat": "error", | 
					
						
							|  |  |  | 			"prefer-object-spread": "error", | 
					
						
							|  |  |  | 			"prefer-regex-literals": "error", | 
					
						
							|  |  |  | 			"prefer-rest-params": "error", | 
					
						
							| 
									
										
										
										
											2024-07-31 09:56:53 +08:00
										 |  |  | 			"no-var": "error", | 
					
						
							|  |  |  | 			"one-var": ["error", "never"], | 
					
						
							| 
									
										
										
										
											2024-07-31 10:39:30 +08:00
										 |  |  | 			"prefer-template": "error", | 
					
						
							| 
									
										
										
										
											2024-07-31 11:11:11 +08:00
										 |  |  | 			"no-implicit-coercion": [ | 
					
						
							|  |  |  | 				"error", | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					boolean: true, | 
					
						
							|  |  |  | 					number: true, | 
					
						
							|  |  |  | 					string: true | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			], | 
					
						
							| 
									
										
										
										
											2024-07-31 11:31:11 +08:00
										 |  |  | 			"arrow-body-style": ["error", "as-needed"], | 
					
						
							| 
									
										
										
										
											2024-07-31 09:37:24 +08:00
										 |  |  | 			"new-cap": [ | 
					
						
							| 
									
										
										
										
											2024-07-31 11:50:02 +08:00
										 |  |  | 				"error", | 
					
						
							| 
									
										
										
										
											2024-07-31 09:37:24 +08:00
										 |  |  | 				{ | 
					
						
							|  |  |  | 					newIsCapExceptions: [], | 
					
						
							| 
									
										
										
										
											2024-07-31 11:50:02 +08:00
										 |  |  | 					capIsNewExceptions: ["A", "F", "D", "MODULES_GROUPERS"] | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			], | 
					
						
							|  |  |  | 			"func-style": [ | 
					
						
							|  |  |  | 				"error", | 
					
						
							|  |  |  | 				"declaration", | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					allowArrowFunctions: true | 
					
						
							| 
									
										
										
										
											2024-07-31 09:37:24 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			], | 
					
						
							| 
									
										
										
										
											2024-07-31 13:38:50 +08:00
										 |  |  | 			"no-loop-func": "error", | 
					
						
							|  |  |  | 			"no-unreachable-loop": "error", | 
					
						
							|  |  |  | 			"no-unmodified-loop-condition": "error", | 
					
						
							|  |  |  | 			"prefer-spread": "error", | 
					
						
							|  |  |  | 			"no-sequences": "error", | 
					
						
							| 
									
										
										
										
											2024-07-31 11:50:02 +08:00
										 |  |  | 			// TODO Enable
 | 
					
						
							| 
									
										
										
										
											2024-07-31 15:37:05 +08:00
										 |  |  | 			"id-length": "off", | 
					
						
							| 
									
										
										
										
											2024-07-31 13:38:50 +08:00
										 |  |  | 			"prefer-destructuring": "off" | 
					
						
							| 
									
										
										
										
											2024-07-31 12:23:44 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2024-07-31 15:37:05 +08:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		plugins: { | 
					
						
							|  |  |  | 			unicorn | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		rules: { | 
					
						
							|  |  |  | 			"unicorn/catch-error-name": [ | 
					
						
							|  |  |  | 				"error", | 
					
						
							|  |  |  | 				{ name: "err", ignore: [/(^_|[0-9]+$)/i] } | 
					
						
							|  |  |  | 			], | 
					
						
							| 
									
										
										
										
											2024-07-31 16:02:41 +08:00
										 |  |  | 			"unicorn/prefer-includes": "error", | 
					
						
							| 
									
										
										
										
											2024-07-31 16:17:46 +08:00
										 |  |  | 			"unicorn/no-zero-fractions": "error", | 
					
						
							|  |  |  | 			"unicorn/prefer-string-starts-ends-with": "error", | 
					
						
							| 
									
										
										
										
											2024-08-02 02:36:27 +08:00
										 |  |  | 			"unicorn/prefer-default-parameters": "error", | 
					
						
							|  |  |  | 			"unicorn/prefer-negative-index": "error", | 
					
						
							|  |  |  | 			"unicorn/prefer-ternary": ["error", "only-single-line"], | 
					
						
							|  |  |  | 			"unicorn/prefer-array-find": "error", | 
					
						
							|  |  |  | 			"unicorn/no-lonely-if": "error", | 
					
						
							|  |  |  | 			"unicorn/no-hex-escape": "error", | 
					
						
							|  |  |  | 			"unicorn/escape-case": "error", | 
					
						
							|  |  |  | 			"unicorn/no-array-for-each": "error", | 
					
						
							|  |  |  | 			"unicorn/prefer-number-properties": "error", | 
					
						
							|  |  |  | 			"unicorn/prefer-native-coercion-functions": "error", | 
					
						
							| 
									
										
										
										
											2024-07-31 15:37:05 +08:00
										 |  |  | 			// TODO Enable
 | 
					
						
							| 
									
										
										
										
											2024-08-02 02:36:27 +08:00
										 |  |  | 			"unicorn/prefer-spread": "off" | 
					
						
							| 
									
										
										
										
											2024-07-31 15:37:05 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2024-07-31 12:23:44 +08:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		plugins: { | 
					
						
							|  |  |  | 			"@stylistic": stylistic | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		rules: { | 
					
						
							|  |  |  | 			"@stylistic/lines-between-class-members": "error", | 
					
						
							|  |  |  | 			"@stylistic/quotes": [ | 
					
						
							|  |  |  | 				"error", | 
					
						
							|  |  |  | 				"double", | 
					
						
							|  |  |  | 				{ avoidEscape: true, allowTemplateLiterals: false } | 
					
						
							|  |  |  | 			], | 
					
						
							|  |  |  | 			"@stylistic/spaced-comment": [ | 
					
						
							|  |  |  | 				"error", | 
					
						
							|  |  |  | 				"always", | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					line: { | 
					
						
							|  |  |  | 						markers: ["=", "!"], // Space here to support sprockets directives
 | 
					
						
							|  |  |  | 						exceptions: ["-", "+"] | 
					
						
							|  |  |  | 					}, | 
					
						
							|  |  |  | 					block: { | 
					
						
							|  |  |  | 						markers: ["=", "!"], // Space here to support sprockets directives
 | 
					
						
							|  |  |  | 						exceptions: ["-", "+"], | 
					
						
							|  |  |  | 						balanced: true | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			] | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		...nodeConfig, | 
					
						
							|  |  |  | 		rules: { | 
					
						
							|  |  |  | 			...nodeConfig.rules, | 
					
						
							|  |  |  | 			"n/no-missing-require": ["error", { allowModules: ["webpack"] }], | 
					
						
							|  |  |  | 			"n/no-unsupported-features/node-builtins": [ | 
					
						
							|  |  |  | 				"error", | 
					
						
							|  |  |  | 				{ | 
					
						
							| 
									
										
										
										
											2025-02-06 07:29:38 +08:00
										 |  |  | 					ignores: [ | 
					
						
							|  |  |  | 						"zlib.createBrotliCompress", | 
					
						
							|  |  |  | 						"zlib.createBrotliDecompress", | 
					
						
							|  |  |  | 						"EventSource" | 
					
						
							|  |  |  | 					] | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			], | 
					
						
							|  |  |  | 			"n/exports-style": "error" | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		...jsdocConfig, | 
					
						
							|  |  |  | 		settings: { | 
					
						
							|  |  |  | 			jsdoc: { | 
					
						
							|  |  |  | 				mode: "typescript", | 
					
						
							|  |  |  | 				// supported tags https://github.com/microsoft/TypeScript-wiki/blob/master/JSDoc-support-in-JavaScript.md
 | 
					
						
							|  |  |  | 				tagNamePreference: { | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 					...["memberof", "yields", "member"].reduce((acc, tag) => { | 
					
						
							|  |  |  | 						acc[tag] = { | 
					
						
							|  |  |  | 							message: `@${tag} currently not supported in TypeScript` | 
					
						
							|  |  |  | 						}; | 
					
						
							|  |  |  | 						return acc; | 
					
						
							|  |  |  | 					}, {}), | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 					extends: "extends", | 
					
						
							|  |  |  | 					return: "returns", | 
					
						
							|  |  |  | 					constructor: "constructor", | 
					
						
							|  |  |  | 					prop: "property", | 
					
						
							|  |  |  | 					arg: "param", | 
					
						
							|  |  |  | 					augments: "extends", | 
					
						
							|  |  |  | 					description: false, | 
					
						
							|  |  |  | 					desc: false, | 
					
						
							|  |  |  | 					inheritdoc: false, | 
					
						
							|  |  |  | 					class: "constructor" | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 				overrideReplacesDocs: false | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		rules: { | 
					
						
							|  |  |  | 			...jsdocConfig.rules, | 
					
						
							|  |  |  | 			// Override recommended
 | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 			//
 | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 			// Doesn't support function overloading/tuples/`readonly`/module keyword/etc
 | 
					
						
							|  |  |  | 			// Also `typescript` reports this itself
 | 
					
						
							|  |  |  | 			"jsdoc/valid-types": "off", | 
					
						
							|  |  |  | 			// A lot of false positive with loops/`switch`/`if`/etc
 | 
					
						
							|  |  |  | 			"jsdoc/require-returns-check": "off", | 
					
						
							|  |  |  | 			// TODO fix and enable in future
 | 
					
						
							|  |  |  | 			"jsdoc/require-property-description": "off", | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// More rules
 | 
					
						
							|  |  |  | 			"jsdoc/check-indentation": "error", | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 			"jsdoc/check-line-alignment": ["error", "never"], | 
					
						
							|  |  |  | 			"jsdoc/require-asterisk-prefix": "error", | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 			"jsdoc/require-hyphen-before-param-description": ["error", "never"], | 
					
						
							|  |  |  | 			"jsdoc/require-template": "error", | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 			"jsdoc/no-bad-blocks": "error", | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 			"jsdoc/no-blank-block-descriptions": "error", | 
					
						
							|  |  |  | 			"jsdoc/no-blank-blocks": "error", | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 			"jsdoc/no-restricted-syntax": [ | 
					
						
							|  |  |  | 				"error", | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					contexts: [ | 
					
						
							| 
									
										
										
										
											2025-03-14 00:34:04 +08:00
										 |  |  | 						// Prefer TypeScript syntax for functions
 | 
					
						
							|  |  |  | 						{ | 
					
						
							|  |  |  | 							comment: "JsdocBlock:has(JsdocTypeFunction[arrow=false])", | 
					
						
							|  |  |  | 							message: | 
					
						
							|  |  |  | 								"Please use TypeScript syntax - `(a: string, b: boolean) => number`" | 
					
						
							|  |  |  | 						}, | 
					
						
							|  |  |  | 						// No `*` type
 | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 						{ | 
					
						
							|  |  |  | 							comment: "JsdocBlock:has(JsdocTypeAny)", | 
					
						
							|  |  |  | 							message: "Please use `any`." | 
					
						
							|  |  |  | 						}, | 
					
						
							| 
									
										
										
										
											2025-03-14 00:34:04 +08:00
										 |  |  | 						// No `?` type
 | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 						{ | 
					
						
							|  |  |  | 							comment: "JsdocBlock:has(JsdocTypeUnknown)", | 
					
						
							|  |  |  | 							message: "Please use `unknown` or `any`" | 
					
						
							|  |  |  | 						}, | 
					
						
							| 
									
										
										
										
											2025-03-14 00:34:04 +08:00
										 |  |  | 						// No `Function` type
 | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 						{ | 
					
						
							| 
									
										
										
										
											2025-03-14 00:34:04 +08:00
										 |  |  | 							comment: | 
					
						
							|  |  |  | 								"JsdocBlock:has(JsdocTypeName[value=/^(function|Function)$/])", | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 							message: | 
					
						
							| 
									
										
										
										
											2025-03-14 00:34:04 +08:00
										 |  |  | 								"Please use provide types for function  - `(a: number, b: number) -> number` instead `Function`" | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2025-03-14 00:34:04 +08:00
										 |  |  | 						// No `Object` type
 | 
					
						
							|  |  |  | 						// {
 | 
					
						
							|  |  |  | 						// 	comment:
 | 
					
						
							|  |  |  | 						// 		"JsdocBlock:has(JsdocTag[tag!=typedef]:has(JsdocTypeName[value=/^(object|Object)$/]))",
 | 
					
						
							|  |  |  | 						// 	message:
 | 
					
						
							|  |  |  | 						// 		"Please use provide types for object  - `{ property: number:, result: () => number}` instead `Object`"
 | 
					
						
							|  |  |  | 						// },
 | 
					
						
							|  |  |  | 						// No `any` type
 | 
					
						
							|  |  |  | 						// {
 | 
					
						
							|  |  |  | 						// 	comment: "JsdocBlock:has(JsdocTypeName[value=/^any$/])",
 | 
					
						
							|  |  |  | 						// 	message:
 | 
					
						
							|  |  |  | 						// 		"Please use provide types instead `any`"
 | 
					
						
							|  |  |  | 						// },
 | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 					] | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			] | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		files: ["bin/**/*.js"], | 
					
						
							|  |  |  | 		// Allow to use `dynamic` import
 | 
					
						
							|  |  |  | 		languageOptions: { | 
					
						
							|  |  |  | 			ecmaVersion: 2020 | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		rules: { | 
					
						
							|  |  |  | 			"n/no-unsupported-features/es-syntax": [ | 
					
						
							|  |  |  | 				"error", | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					ignores: ["hashbang", "dynamic-import"] | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			] | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		files: ["lib/**/*.runtime.js", "hot/*.js"], | 
					
						
							|  |  |  | 		languageOptions: { | 
					
						
							|  |  |  | 			ecmaVersion: 5, | 
					
						
							|  |  |  | 			globals: { | 
					
						
							|  |  |  | 				...globals.browser, | 
					
						
							|  |  |  | 				...globals.es5 | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2024-07-31 04:09:42 +08:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		rules: { | 
					
						
							|  |  |  | 			"prefer-const": "off", | 
					
						
							| 
									
										
										
										
											2024-07-31 04:54:55 +08:00
										 |  |  | 			"object-shorthand": "off", | 
					
						
							| 
									
										
										
										
											2024-07-31 06:15:03 +08:00
										 |  |  | 			"no-undef-init": "off", | 
					
						
							| 
									
										
										
										
											2024-07-31 09:56:53 +08:00
										 |  |  | 			"no-var": "off", | 
					
						
							| 
									
										
										
										
											2024-07-31 10:39:30 +08:00
										 |  |  | 			"n/exports-style": "off", | 
					
						
							| 
									
										
										
										
											2024-07-31 11:11:11 +08:00
										 |  |  | 			"prefer-template": "off", | 
					
						
							| 
									
										
										
										
											2024-07-31 11:50:02 +08:00
										 |  |  | 			"no-implicit-coercion": "off", | 
					
						
							| 
									
										
										
										
											2024-07-31 16:02:41 +08:00
										 |  |  | 			"func-style": "off", | 
					
						
							| 
									
										
										
										
											2024-08-02 02:36:27 +08:00
										 |  |  | 			"unicorn/prefer-includes": "off", | 
					
						
							|  |  |  | 			"unicorn/no-useless-undefined": "off", | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 			"unicorn/no-array-for-each": "off", | 
					
						
							|  |  |  | 			"jsdoc/require-jsdoc": "off" | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		files: ["tooling/**/*.js"], | 
					
						
							|  |  |  | 		languageOptions: { | 
					
						
							|  |  |  | 			ecmaVersion: 2020, | 
					
						
							|  |  |  | 			globals: { | 
					
						
							| 
									
										
										
										
											2024-07-31 04:09:42 +08:00
										 |  |  | 				...globals.es2020 | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		...jest.configs["flat/recommended"], | 
					
						
							|  |  |  | 		files: ["test/**/*.js"], | 
					
						
							|  |  |  | 		languageOptions: { | 
					
						
							|  |  |  | 			ecmaVersion: 2020, | 
					
						
							|  |  |  | 			globals: { | 
					
						
							|  |  |  | 				...globals.jest, | 
					
						
							|  |  |  | 				nsObj: false | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		rules: { | 
					
						
							|  |  |  | 			...jest.configs["flat/recommended"].rules, | 
					
						
							|  |  |  | 			"jest/no-standalone-expect": "off", | 
					
						
							|  |  |  | 			"jest/valid-title": [ | 
					
						
							|  |  |  | 				"error", | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					ignoreTypeOfDescribeName: true, | 
					
						
							|  |  |  | 					ignoreTypeOfTestName: true | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			], | 
					
						
							|  |  |  | 			"jest/no-done-callback": "off", | 
					
						
							|  |  |  | 			"jest/expect-expect": "off", | 
					
						
							|  |  |  | 			"jest/no-conditional-expect": "off", | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 			"object-shorthand": "off", | 
					
						
							|  |  |  | 			camelcase: "off", | 
					
						
							|  |  |  | 			"no-var": "off", | 
					
						
							|  |  |  | 			"jsdoc/require-jsdoc": "off", | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 			"n/no-unsupported-features/node-builtins": [ | 
					
						
							|  |  |  | 				"error", | 
					
						
							|  |  |  | 				{ | 
					
						
							| 
									
										
										
										
											2025-02-07 04:25:59 +08:00
										 |  |  | 					ignores: ["Blob"], | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 					allowExperimental: true | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2025-03-12 09:56:14 +08:00
										 |  |  | 			] | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2024-08-02 23:42:44 +08:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		files: [ | 
					
						
							|  |  |  | 			"test/configCases/{dll-plugin-entry,dll-plugin-side-effects,dll-plugin}/**/webpack.config.js" | 
					
						
							|  |  |  | 		], | 
					
						
							|  |  |  | 		rules: { | 
					
						
							|  |  |  | 			"n/no-missing-require": "off" | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2025-03-07 23:32:55 +08:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		files: ["lib/**/*.js"], | 
					
						
							|  |  |  | 		rules: { | 
					
						
							|  |  |  | 			"no-console": "error" | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		files: ["examples/**/*.js"], | 
					
						
							|  |  |  | 		rules: { | 
					
						
							|  |  |  | 			"n/no-missing-require": "off" | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2025-03-07 23:32:55 +08:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		files: ["*.mjs", "**/*.mjs"], | 
					
						
							|  |  |  | 		languageOptions: { | 
					
						
							|  |  |  | 			sourceType: "module" | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		rules: { | 
					
						
							|  |  |  | 			"n/no-unsupported-features/es-syntax": [ | 
					
						
							|  |  |  | 				"error", | 
					
						
							|  |  |  | 				{ | 
					
						
							|  |  |  | 					ignores: ["modules"] | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			] | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2024-07-31 12:01:14 +08:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		...prettierConfig, | 
					
						
							|  |  |  | 		plugins: { | 
					
						
							|  |  |  | 			...prettierConfig.plugins, | 
					
						
							|  |  |  | 			prettier | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		rules: { | 
					
						
							|  |  |  | 			...prettierConfig.rules, | 
					
						
							|  |  |  | 			"prettier/prettier": "error" | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2024-06-11 20:32:02 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | ]; |