2024-01-08 14:48:45 +08:00
|
|
|
import url from "node:url";
|
|
|
|
|
import eslintPluginJs from "@eslint/js";
|
2025-05-28 04:42:21 +08:00
|
|
|
import eslintPluginStylistic from "@stylistic/eslint-plugin";
|
2024-01-08 14:48:45 +08:00
|
|
|
import eslintPluginTypescriptEslint from "@typescript-eslint/eslint-plugin";
|
|
|
|
|
import { isCI } from "ci-info";
|
|
|
|
|
import eslintConfigPrettier from "eslint-config-prettier";
|
|
|
|
|
import eslintPluginJest from "eslint-plugin-jest";
|
|
|
|
|
import eslintPluginN from "eslint-plugin-n";
|
|
|
|
|
import eslintPluginRegexp from "eslint-plugin-regexp";
|
|
|
|
|
import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort";
|
|
|
|
|
import eslintPluginUnicorn from "eslint-plugin-unicorn";
|
2024-09-19 00:41:52 +08:00
|
|
|
import globals from "globals";
|
2025-10-14 19:30:07 +08:00
|
|
|
import eslintConfigNodeStyleText from "node-style-text/eslint-config";
|
2024-01-08 14:48:45 +08:00
|
|
|
import eslintPluginPrettierInternalRules from "./scripts/tools/eslint-plugin-prettier-internal-rules/index.js";
|
|
|
|
|
|
|
|
|
|
const toPath = (file) => url.fileURLToPath(new URL(file, import.meta.url));
|
2024-06-05 11:32:07 +08:00
|
|
|
|
|
|
|
|
const ignores = `
|
2025-06-25 15:06:36 +08:00
|
|
|
**/.tmp
|
2024-09-27 22:07:12 +09:00
|
|
|
test*.*
|
2024-06-05 11:32:07 +08:00
|
|
|
# Ignore directories and files in 'tests/format'
|
|
|
|
|
tests/format/**/*
|
2025-02-16 15:36:06 +08:00
|
|
|
# Unignore directories and 'format.test.js' file
|
2024-06-05 11:32:07 +08:00
|
|
|
!tests/format/**/
|
|
|
|
|
!tests/format/**/format.test.js
|
|
|
|
|
tests/integration/cli/
|
|
|
|
|
scripts/release/node_modules
|
|
|
|
|
coverage/
|
|
|
|
|
dist*/
|
|
|
|
|
**/node_modules/**
|
|
|
|
|
website/build/
|
|
|
|
|
website/static/lib/
|
2025-04-09 11:07:46 +08:00
|
|
|
website/static/playground/
|
2025-01-30 03:16:21 +01:00
|
|
|
website/.docusaurus
|
2024-06-05 11:32:07 +08:00
|
|
|
scripts/benchmark/*/
|
|
|
|
|
**/.yarn/**
|
|
|
|
|
**/.pnp.*
|
|
|
|
|
`
|
|
|
|
|
.split("\n")
|
|
|
|
|
.filter((pattern) => pattern && !pattern.startsWith("#"));
|
2024-01-08 14:48:45 +08:00
|
|
|
|
2025-09-27 17:13:24 +08:00
|
|
|
const configs = [
|
|
|
|
|
{ files: ["**/*.{js,mjs,cjs,jsx}"] },
|
2024-01-08 14:48:45 +08:00
|
|
|
eslintPluginJs.configs.recommended,
|
2024-05-13 19:32:48 +08:00
|
|
|
eslintPluginRegexp.configs["flat/recommended"],
|
2024-01-08 14:48:45 +08:00
|
|
|
eslintPluginUnicorn.configs["flat/recommended"],
|
|
|
|
|
eslintConfigPrettier,
|
2025-10-14 19:30:07 +08:00
|
|
|
eslintConfigNodeStyleText,
|
2024-01-08 14:48:45 +08:00
|
|
|
{
|
2024-09-19 00:41:52 +08:00
|
|
|
languageOptions: {
|
|
|
|
|
globals: { ...globals.builtin, ...globals.node },
|
|
|
|
|
},
|
2024-01-08 14:48:45 +08:00
|
|
|
plugins: {
|
2025-05-28 04:42:21 +08:00
|
|
|
"@stylistic": eslintPluginStylistic,
|
2024-01-08 14:48:45 +08:00
|
|
|
"@typescript-eslint": eslintPluginTypescriptEslint,
|
|
|
|
|
n: eslintPluginN,
|
|
|
|
|
"prettier-internal-rules": eslintPluginPrettierInternalRules,
|
|
|
|
|
"simple-import-sort": eslintPluginSimpleImportSort,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
rules: {
|
|
|
|
|
"arrow-body-style": ["error", "as-needed"],
|
|
|
|
|
curly: "error",
|
|
|
|
|
"dot-notation": "error",
|
|
|
|
|
eqeqeq: "error",
|
|
|
|
|
"logical-assignment-operators": "error",
|
|
|
|
|
"no-console": isCI ? "error" : "warn",
|
|
|
|
|
"no-constant-binary-expression": "error",
|
|
|
|
|
"no-duplicate-imports": "error",
|
|
|
|
|
"no-else-return": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
allowElseIf: false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
"no-implicit-coercion": "error",
|
|
|
|
|
"no-inner-declarations": "error",
|
|
|
|
|
"no-lonely-if": "error",
|
|
|
|
|
"no-unneeded-ternary": "error",
|
|
|
|
|
"no-useless-return": "error",
|
|
|
|
|
"no-unused-expressions": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
allowShortCircuit: true,
|
|
|
|
|
allowTernary: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
"no-unused-vars": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
ignoreRestSiblings: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
"no-var": "error",
|
|
|
|
|
"object-shorthand": [
|
|
|
|
|
"error",
|
|
|
|
|
"always",
|
|
|
|
|
{
|
|
|
|
|
avoidExplicitReturnArrows: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
"one-var": ["error", "never"],
|
|
|
|
|
"prefer-arrow-callback": "error",
|
|
|
|
|
"prefer-const": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
destructuring: "all",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
"prefer-destructuring": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
VariableDeclarator: {
|
|
|
|
|
array: false,
|
|
|
|
|
object: true,
|
|
|
|
|
},
|
|
|
|
|
AssignmentExpression: {
|
|
|
|
|
array: false,
|
|
|
|
|
object: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
enforceForRenamedProperties: false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
"prefer-object-has-own": "error",
|
|
|
|
|
"prefer-object-spread": "error",
|
|
|
|
|
"prefer-rest-params": "error",
|
|
|
|
|
"prefer-spread": "error",
|
|
|
|
|
"require-await": "error",
|
2025-12-12 04:08:37 +08:00
|
|
|
// The `u` or `v` flag cause problems when dealing with non-ascii characters
|
|
|
|
|
// https://github.com/prettier/prettier/pull/18453
|
|
|
|
|
// https://github.com/prettier/prettier/pull/18455
|
|
|
|
|
"require-unicode-regexp": "off",
|
2024-01-08 14:48:45 +08:00
|
|
|
"symbol-description": "error",
|
|
|
|
|
yoda: [
|
|
|
|
|
"error",
|
|
|
|
|
"never",
|
|
|
|
|
{
|
|
|
|
|
exceptRange: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
// Internal rules
|
|
|
|
|
"prettier-internal-rules/jsx-identifier-case": "error",
|
2024-02-04 14:32:54 +08:00
|
|
|
"prettier-internal-rules/massage-ast-parameter-names": "error",
|
2024-01-08 14:48:45 +08:00
|
|
|
"prettier-internal-rules/no-identifier-n": "error",
|
|
|
|
|
"prettier-internal-rules/prefer-fs-promises-submodule": "error",
|
2025-10-11 01:46:03 +08:00
|
|
|
"prettier-internal-rules/no-useless-ast-path-callback-parameter": "error",
|
2024-01-08 14:48:45 +08:00
|
|
|
|
2025-05-28 04:42:21 +08:00
|
|
|
/* @stylistic/eslint-plugin */
|
|
|
|
|
"@stylistic/quotes": [
|
2024-01-08 14:48:45 +08:00
|
|
|
"error",
|
|
|
|
|
"double",
|
|
|
|
|
{
|
|
|
|
|
avoidEscape: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
2025-09-23 17:24:03 +08:00
|
|
|
"@stylistic/spaced-comment": "error",
|
2025-10-12 21:24:05 +08:00
|
|
|
"@stylistic/no-trailing-spaces": "error",
|
2024-01-08 14:48:45 +08:00
|
|
|
|
2024-06-18 06:52:54 +08:00
|
|
|
/* @typescript-eslint/eslint-plugin */
|
|
|
|
|
"@typescript-eslint/prefer-ts-expect-error": "error",
|
|
|
|
|
|
|
|
|
|
/* eslint-plugin-n */
|
2024-01-08 14:48:45 +08:00
|
|
|
"n/no-path-concat": "error",
|
|
|
|
|
|
2024-06-18 06:52:54 +08:00
|
|
|
/* eslint-plugin-regexp */
|
2024-01-08 14:48:45 +08:00
|
|
|
"regexp/match-any": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
allows: ["dotAll"],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
/* cspell:disable-next-line */
|
|
|
|
|
"regexp/no-extra-lookaround-assertions": "error",
|
|
|
|
|
"regexp/no-missing-g-flag": "error",
|
|
|
|
|
"regexp/no-useless-flag": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
strictTypes: false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
/* cspell:disable-next-line */
|
|
|
|
|
"regexp/prefer-lookaround": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
strictTypes: false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
"regexp/no-super-linear-backtracking": "off",
|
2024-04-10 18:20:06 +08:00
|
|
|
"regexp/unicode-property": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
generalCategory: "never",
|
|
|
|
|
key: "long",
|
|
|
|
|
property: {
|
|
|
|
|
binary: "long",
|
|
|
|
|
generalCategory: "long",
|
|
|
|
|
script: "long",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
2024-01-08 14:48:45 +08:00
|
|
|
|
2024-06-18 06:52:54 +08:00
|
|
|
/* eslint-plugin-simple-import-sort */
|
2024-09-29 17:56:37 +08:00
|
|
|
"simple-import-sort/imports": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
groups: [
|
|
|
|
|
// https://github.com/lydell/eslint-plugin-simple-import-sort/blob/20e25f3b83c713825f96b8494e2091e6600954d6/src/imports.js#L5-L19
|
|
|
|
|
// Side effect imports.
|
|
|
|
|
[String.raw`^\u0000`],
|
|
|
|
|
// Remove blank lines between groups
|
|
|
|
|
// https://github.com/lydell/eslint-plugin-simple-import-sort#how-do-i-remove-all-blank-lines-between-imports
|
|
|
|
|
[
|
|
|
|
|
// Node.js builtins prefixed with `node:`.
|
|
|
|
|
"^node:",
|
|
|
|
|
// Packages.
|
|
|
|
|
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
|
|
|
|
|
String.raw`^@?\w`,
|
|
|
|
|
// Absolute imports and other imports such as Vue-style `@/foo`.
|
|
|
|
|
// Anything not matched in another group.
|
|
|
|
|
"^",
|
|
|
|
|
// Relative imports.
|
|
|
|
|
// Anything that starts with a dot.
|
|
|
|
|
String.raw`^\.`,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
2024-01-08 14:48:45 +08:00
|
|
|
"simple-import-sort/exports": "error",
|
|
|
|
|
|
2024-06-18 06:52:54 +08:00
|
|
|
/* eslint-plugin-unicorn */
|
2024-01-08 14:48:45 +08:00
|
|
|
"unicorn/escape-case": "off",
|
|
|
|
|
"unicorn/catch-error-name": "off",
|
|
|
|
|
"unicorn/consistent-destructuring": "off",
|
|
|
|
|
"unicorn/consistent-function-scoping": "off",
|
|
|
|
|
"unicorn/import-style": "off",
|
|
|
|
|
"unicorn/no-array-callback-reference": "off",
|
|
|
|
|
"unicorn/no-array-method-this-argument": "off",
|
|
|
|
|
"unicorn/no-array-reduce": "off",
|
2025-07-26 10:56:11 +08:00
|
|
|
"unicorn/no-array-reverse": "off",
|
2025-09-07 21:55:09 +08:00
|
|
|
"unicorn/no-array-sort": "off",
|
2024-01-08 14:48:45 +08:00
|
|
|
"unicorn/no-await-expression-member": "off",
|
|
|
|
|
"unicorn/no-for-loop": "off",
|
|
|
|
|
"unicorn/no-hex-escape": "off",
|
|
|
|
|
"unicorn/no-negated-condition": "off",
|
|
|
|
|
"unicorn/no-nested-ternary": "off",
|
|
|
|
|
"unicorn/no-null": "off",
|
|
|
|
|
"unicorn/no-process-exit": "off",
|
|
|
|
|
"unicorn/no-thenable": "off",
|
|
|
|
|
"unicorn/no-unreadable-array-destructuring": "off",
|
|
|
|
|
"unicorn/no-useless-switch-case": "off",
|
|
|
|
|
"unicorn/no-useless-undefined": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
checkArrowFunctionBody: false,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
"unicorn/number-literal-case": "off",
|
|
|
|
|
"unicorn/numeric-separators-style": "off",
|
|
|
|
|
"unicorn/prefer-array-flat": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
functions: ["flat", "flatten"],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
"unicorn/prefer-add-event-listener": "off",
|
|
|
|
|
"unicorn/prefer-at": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
getLastElementFunctions: ["getLast"],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
"unicorn/prefer-code-point": "off",
|
|
|
|
|
"unicorn/prefer-dom-node-append": "off",
|
|
|
|
|
"unicorn/prefer-dom-node-remove": "off",
|
|
|
|
|
"unicorn/prefer-export-from": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
ignoreUsedVariables: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
2024-10-09 11:26:00 +08:00
|
|
|
"unicorn/prefer-global-this": "off",
|
2024-01-08 14:48:45 +08:00
|
|
|
"unicorn/prefer-query-selector": "off",
|
|
|
|
|
"unicorn/prefer-ternary": "off",
|
|
|
|
|
"unicorn/prevent-abbreviations": "off",
|
|
|
|
|
"unicorn/relative-url-style": "off",
|
|
|
|
|
"unicorn/switch-case-braces": ["error", "avoid"],
|
2024-06-13 09:13:41 +08:00
|
|
|
"unicorn/template-indent": "error",
|
2024-01-08 14:48:45 +08:00
|
|
|
},
|
2024-06-05 11:32:07 +08:00
|
|
|
|
|
|
|
|
linterOptions: {
|
|
|
|
|
reportUnusedDisableDirectives: "error",
|
|
|
|
|
},
|
2024-01-08 14:48:45 +08:00
|
|
|
},
|
|
|
|
|
{
|
2024-06-05 11:32:07 +08:00
|
|
|
ignores,
|
2024-01-08 14:48:45 +08:00
|
|
|
},
|
|
|
|
|
// CommonJS modules
|
|
|
|
|
{
|
2025-02-16 15:36:06 +08:00
|
|
|
files: ["**/*.cjs", "website/**/*.js"],
|
2024-01-08 14:48:45 +08:00
|
|
|
languageOptions: {
|
|
|
|
|
sourceType: "script",
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
2024-02-24 19:22:02 +08:00
|
|
|
strict: ["error", "global"],
|
2024-01-08 14:48:45 +08:00
|
|
|
"unicorn/prefer-module": "off",
|
|
|
|
|
"unicorn/prefer-node-protocol": "off",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-11-04 03:54:35 +08:00
|
|
|
files: [
|
|
|
|
|
"scripts/**/*",
|
|
|
|
|
"benchmarks/**",
|
|
|
|
|
"tests/config/install-prettier.js",
|
|
|
|
|
],
|
2024-01-08 14:48:45 +08:00
|
|
|
rules: {
|
|
|
|
|
"no-console": "off",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
files: ["scripts/**/*.js"],
|
|
|
|
|
rules: {
|
|
|
|
|
"unicorn/prefer-top-level-await": "error",
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-02-21 15:36:05 +08:00
|
|
|
{
|
2024-01-08 14:48:45 +08:00
|
|
|
files: [
|
|
|
|
|
"tests/config/**/*.js",
|
2024-05-06 14:25:10 +12:00
|
|
|
"tests/format/**/format.test.js",
|
2024-01-08 14:48:45 +08:00
|
|
|
"tests/integration/**/*.js",
|
|
|
|
|
"tests/unit/**/*.js",
|
|
|
|
|
"tests/dts/unit/**/*.js",
|
|
|
|
|
"scripts/release/__tests__/**/*.spec.js",
|
|
|
|
|
],
|
|
|
|
|
plugins: { jest: eslintPluginJest },
|
2024-02-21 15:36:05 +08:00
|
|
|
languageOptions: {
|
|
|
|
|
globals: eslintPluginJest.environments.globals.globals,
|
|
|
|
|
},
|
2024-01-08 14:48:45 +08:00
|
|
|
rules: {
|
2025-05-28 04:42:21 +08:00
|
|
|
"@stylistic/quotes": [
|
2024-01-08 14:48:45 +08:00
|
|
|
"error",
|
|
|
|
|
"double",
|
|
|
|
|
{
|
|
|
|
|
avoidEscape: true,
|
2025-08-25 14:30:47 +09:00
|
|
|
allowTemplateLiterals: "always",
|
2024-01-08 14:48:45 +08:00
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
"jest/valid-expect": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
alwaysAwait: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
"jest/prefer-to-be": "error",
|
|
|
|
|
},
|
2024-02-21 15:36:05 +08:00
|
|
|
},
|
2024-01-08 14:48:45 +08:00
|
|
|
{
|
|
|
|
|
files: ["tests/format/**/*.js"],
|
|
|
|
|
rules: {
|
2024-01-19 17:20:24 +08:00
|
|
|
"prettier-internal-rules/no-legacy-format-test": "error",
|
2024-01-08 14:48:45 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
files: ["tests/integration/**/*.js"],
|
|
|
|
|
rules: {
|
|
|
|
|
"prettier-internal-rules/await-cli-tests": "error",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
2025-09-07 21:55:09 +08:00
|
|
|
files: ["tests/**/*.{js,cjs}"],
|
2024-01-08 14:48:45 +08:00
|
|
|
rules: {
|
|
|
|
|
// TODO: Enable this when we drop support for Node.js v14
|
|
|
|
|
"logical-assignment-operators": "off",
|
|
|
|
|
"unicorn/prefer-array-flat": "off",
|
|
|
|
|
"unicorn/prefer-array-flat-map": "off",
|
|
|
|
|
"unicorn/prefer-string-replace-all": "off",
|
|
|
|
|
},
|
|
|
|
|
languageOptions: {
|
|
|
|
|
globals: {
|
|
|
|
|
runCli: "readonly",
|
2024-01-19 17:20:24 +08:00
|
|
|
runFormatTest: "readonly",
|
2024-01-08 14:48:45 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
files: ["src/cli/**/*.js"],
|
|
|
|
|
rules: {
|
|
|
|
|
"n/no-restricted-import": [
|
|
|
|
|
"error",
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
name: [
|
|
|
|
|
toPath("src/**"),
|
|
|
|
|
`!${toPath("src/cli/**")}`,
|
|
|
|
|
`!${toPath("src/index.js")}`,
|
|
|
|
|
],
|
|
|
|
|
message: "Don't use code from other directory.",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
files: ["src/language-js/needs-parens.js"],
|
|
|
|
|
rules: {
|
|
|
|
|
"prettier-internal-rules/better-parent-property-check-in-needs-parens":
|
|
|
|
|
"error",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
files: ["src/**/*.js"],
|
|
|
|
|
rules: {
|
|
|
|
|
"prettier-internal-rules/flat-ast-path-call": "error",
|
|
|
|
|
"prettier-internal-rules/no-conflicting-comment-check-flags": "error",
|
|
|
|
|
"prettier-internal-rules/no-doc-public-import": "error",
|
|
|
|
|
"prettier-internal-rules/no-empty-flat-contents-for-if-break": "error",
|
|
|
|
|
"prettier-internal-rules/no-unnecessary-ast-path-call": "error",
|
|
|
|
|
"prettier-internal-rules/prefer-ast-path-each": "error",
|
|
|
|
|
"prettier-internal-rules/prefer-indent-if-break": "error",
|
|
|
|
|
"prettier-internal-rules/prefer-is-non-empty-array": "error",
|
|
|
|
|
"prettier-internal-rules/prefer-ast-path-getters": "error",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
files: ["src/language-*/**/*.js"],
|
|
|
|
|
rules: {
|
|
|
|
|
"prettier-internal-rules/directly-loc-start-end": "error",
|
2025-04-09 11:07:46 +08:00
|
|
|
"prettier-internal-rules/print-function-parameter-order": "error",
|
2024-01-08 14:48:45 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
files: ["src/language-js/**/*.js"],
|
|
|
|
|
ignores: ["src/language-js/parse/postprocess/*.js"],
|
|
|
|
|
rules: {
|
|
|
|
|
"prettier-internal-rules/no-node-comments": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
2025-12-01 07:25:25 +08:00
|
|
|
file: "src/language-js/utilities/index.js",
|
2024-01-08 14:48:45 +08:00
|
|
|
functions: ["hasComment", "getComments"],
|
|
|
|
|
},
|
|
|
|
|
"src/language-js/pragma.js",
|
2025-09-23 17:42:16 +08:00
|
|
|
"src/language-js/parse/angular.js",
|
2024-01-08 14:48:45 +08:00
|
|
|
"src/language-js/parse/babel.js",
|
|
|
|
|
"src/language-js/parse/meriyah.js",
|
|
|
|
|
"src/language-js/parse/json.js",
|
|
|
|
|
"src/language-js/parse/acorn.js",
|
2025-05-27 09:35:31 +08:00
|
|
|
"src/language-js/parse/oxc.js",
|
2025-12-01 07:25:25 +08:00
|
|
|
"src/language-js/parse/utilities/wrap-babel-expression.js",
|
2024-01-08 14:48:45 +08:00
|
|
|
],
|
|
|
|
|
"prettier-internal-rules/prefer-create-type-check-function": [
|
|
|
|
|
"error",
|
|
|
|
|
{
|
|
|
|
|
ignoreSingleType: true,
|
|
|
|
|
onlyTopLevelFunctions: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-09-19 00:41:52 +08:00
|
|
|
{
|
2025-12-10 23:48:10 +08:00
|
|
|
files: ["website/src/pages/**/*.jsx", "website/playground/**/*.jsx"],
|
|
|
|
|
rules: {
|
|
|
|
|
// Doesn't know JSX
|
|
|
|
|
"no-unused-vars": "off",
|
|
|
|
|
},
|
2024-09-19 00:41:52 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
files: ["website/**/*"],
|
|
|
|
|
languageOptions: {
|
|
|
|
|
globals: { ...globals.browser, ...globals.worker },
|
2025-02-25 09:05:54 +08:00
|
|
|
parserOptions: {
|
|
|
|
|
ecmaFeatures: {
|
|
|
|
|
jsx: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-09-19 00:41:52 +08:00
|
|
|
},
|
2024-01-08 14:48:45 +08:00
|
|
|
rules: {
|
|
|
|
|
"unicorn/filename-case": "off",
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-01-30 03:16:21 +01:00
|
|
|
{
|
2025-02-25 09:05:54 +08:00
|
|
|
files: ["website/docusaurus.config.js", "website/playground/**/*"],
|
2024-01-08 14:48:45 +08:00
|
|
|
languageOptions: {
|
|
|
|
|
sourceType: "module",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
files: ["bin/prettier.cjs"],
|
|
|
|
|
languageOptions: {
|
|
|
|
|
ecmaVersion: 5,
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
"no-var": "off",
|
|
|
|
|
"prefer-arrow-callback": "off",
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-11-02 21:18:15 +08:00
|
|
|
{
|
|
|
|
|
files: ["src/document/printer/printer.js"],
|
|
|
|
|
rules: {
|
|
|
|
|
"unicorn/prevent-abbreviations": [
|
|
|
|
|
"error",
|
|
|
|
|
{ replacements: { doc: false } },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2024-01-08 14:48:45 +08:00
|
|
|
];
|
2025-09-27 17:13:24 +08:00
|
|
|
|
|
|
|
|
export default configs;
|