From b1f4dad16fa00ff4c3e1528c48f0216c452ba6d1 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Tue, 22 Nov 2022 02:27:33 -0500 Subject: [PATCH 01/18] docs(website): add version to header, and documented branch flow (#6055) --- packages/website/README.md | 11 ++++++++++- packages/website/docusaurusConfig.ts | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/website/README.md b/packages/website/README.md index fd7bb57cb428..7f4c12e23722 100644 --- a/packages/website/README.md +++ b/packages/website/README.md @@ -1,5 +1,7 @@ # Website +[![Netlify Status](https://api.netlify.com/api/v1/badges/128d21c7-b2fe-45ad-b141-9878fcf5de3a/deploy-status)](https://app.netlify.com/sites/typescript-eslint/deploys) + This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator. ## Installation @@ -26,4 +28,11 @@ This command generates static content into the `build` directory and can be serv ## Deployment -The website is deployed automatically using Netlify. Each pull request into the `main` branch will have a unique preview deployment generated for it. +### Production + +The website is deployed from the `website` branch automatically using Netlify. +That branch gets updated from the `main` branch whenever a new stable version is released (generally weekly). + +### Pull Requests + +Each pull request into the `main` branch will have a unique preview deployment generated for it. diff --git a/packages/website/docusaurusConfig.ts b/packages/website/docusaurusConfig.ts index 0ef589b005a2..7ac111820f2c 100644 --- a/packages/website/docusaurusConfig.ts +++ b/packages/website/docusaurusConfig.ts @@ -8,6 +8,7 @@ import type { UserThemeConfig as AlgoliaThemeConfig } from '@docusaurus/theme-se import type { Config } from '@docusaurus/types'; import tabsPlugin from 'remark-docusaurus-tabs'; +import { version } from './package.json'; import { generatedRuleDocs } from './plugins/generated-rule-docs'; import { rulesMeta } from './rulesMeta'; @@ -91,6 +92,11 @@ const themeConfig: ThemeCommonConfig & AlgoliaThemeConfig = { label: 'Blog', position: 'left', }, + { + position: 'right', + value: `v${version}`, + type: 'html', + }, { to: 'play', activeBasePath: 'play', From 44027db379e6e074a16cda2755ef554c2b0a4c5a Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Wed, 23 Nov 2022 09:01:51 +1030 Subject: [PATCH 02/18] fix(scope-manager): add support for TS4.9 satisfies expression (#6059) feat(scope-manager): add support for TS4.9 satisfies expression --- .prettierignore | 1 + .../src/referencer/Referencer.ts | 9 +- .../fixtures/type-assertion/satisfies.ts | 4 + .../fixtures/type-assertion/satisfies.ts.shot | 84 +++++++++++++++++++ 4 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts create mode 100644 packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts.shot diff --git a/.prettierignore b/.prettierignore index 88af276a1b24..bb855f41157a 100644 --- a/.prettierignore +++ b/.prettierignore @@ -14,6 +14,7 @@ packages/ast-spec/src/*/*/fixtures/_error_/*/fixture.ts # prettier doesn't yet support satisfies packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/ +packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts # Ignore CHANGELOG.md files to avoid issues with automated release job CHANGELOG.md diff --git a/packages/scope-manager/src/referencer/Referencer.ts b/packages/scope-manager/src/referencer/Referencer.ts index 93b0270ebfba..e7b41127ba46 100644 --- a/packages/scope-manager/src/referencer/Referencer.ts +++ b/packages/scope-manager/src/referencer/Referencer.ts @@ -301,7 +301,10 @@ class Referencer extends Visitor { } protected visitTypeAssertion( - node: TSESTree.TSAsExpression | TSESTree.TSTypeAssertion, + node: + | TSESTree.TSAsExpression + | TSESTree.TSTypeAssertion + | TSESTree.TSSatisfiesExpression, ): void { this.visit(node.expression); this.visitType(node.typeAnnotation); @@ -724,6 +727,10 @@ class Referencer extends Visitor { this.close(node); } + protected TSSatisfiesExpression(node: TSESTree.TSSatisfiesExpression): void { + this.visitTypeAssertion(node); + } + protected TSTypeAliasDeclaration( node: TSESTree.TSTypeAliasDeclaration, ): void { diff --git a/packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts b/packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts new file mode 100644 index 000000000000..69dae24ecf27 --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts @@ -0,0 +1,4 @@ +const x = 1; +type T = 1; + +x satisfies T; diff --git a/packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts.shot b/packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts.shot new file mode 100644 index 000000000000..9d6dcc03ce1a --- /dev/null +++ b/packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts.shot @@ -0,0 +1,84 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`type-assertion satisfies 1`] = ` +ScopeManager { + variables: Array [ + ImplicitGlobalConstTypeVariable, + Variable$2 { + defs: Array [ + VariableDefinition$1 { + name: Identifier<"x">, + node: VariableDeclarator$1, + }, + ], + name: "x", + references: Array [ + Reference$1 { + identifier: Identifier<"x">, + init: true, + isRead: false, + isTypeReference: false, + isValueReference: true, + isWrite: true, + resolved: Variable$2, + writeExpr: Literal$2, + }, + Reference$2 { + identifier: Identifier<"x">, + isRead: true, + isTypeReference: false, + isValueReference: true, + isWrite: false, + resolved: Variable$2, + }, + ], + isValueVariable: true, + isTypeVariable: false, + }, + Variable$3 { + defs: Array [ + TypeDefinition$2 { + name: Identifier<"T">, + node: TSTypeAliasDeclaration$3, + }, + ], + name: "T", + references: Array [ + Reference$3 { + identifier: Identifier<"T">, + isRead: true, + isTypeReference: true, + isValueReference: false, + isWrite: false, + resolved: Variable$3, + }, + ], + isValueVariable: false, + isTypeVariable: true, + }, + ], + scopes: Array [ + GlobalScope$1 { + block: Program$4, + isStrict: false, + references: Array [ + Reference$1, + Reference$2, + Reference$3, + ], + set: Map { + "const" => ImplicitGlobalConstTypeVariable, + "x" => Variable$2, + "T" => Variable$3, + }, + type: "global", + upper: null, + variables: Array [ + ImplicitGlobalConstTypeVariable, + Variable$2, + Variable$3, + ], + }, + ], +} +`; From 90d2ce0d0bcb91d198b156b764dce4cf61d18a82 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 23 Nov 2022 11:57:35 +0100 Subject: [PATCH 03/18] chore: update prettier to 2.8 (#6067) * chore: update prettier to 2.8 * prettier * trigger ci --- .lintstagedrc | 4 +- .prettierignore | 4 - package.json | 2 +- .../fixtures/array-array/fixture.ts | 2 +- .../array-array/snapshots/1-TSESTree-AST.shot | 68 ++++++++-------- .../snapshots/2-TSESTree-Tokens.shot | 78 +++++++++---------- .../array-array/snapshots/3-Babel-AST.shot | 68 ++++++++-------- .../array-array/snapshots/4-Babel-Tokens.shot | 78 +++++++++---------- .../arrow-func-no-parentheses/fixture.ts | 2 +- .../snapshots/1-TSESTree-AST.shot | 6 +- .../snapshots/2-TSESTree-Tokens.shot | 10 +++ .../snapshots/3-Babel-AST.shot | 6 +- .../snapshots/4-Babel-Tokens.shot | 10 +++ .../arrow-func-with-parentheses/fixture.ts | 2 +- .../snapshots/1-TSESTree-AST.shot | 6 +- .../snapshots/2-TSESTree-Tokens.shot | 10 +++ .../snapshots/3-Babel-AST.shot | 6 +- .../snapshots/4-Babel-Tokens.shot | 10 +++ .../snapshots/5-AST-Alignment-AST.shot | 6 +- .../conditional-no-parentheses/fixture.ts | 2 +- .../snapshots/1-TSESTree-AST.shot | 28 +++---- .../snapshots/2-TSESTree-Tokens.shot | 44 ++++++++--- .../snapshots/3-Babel-AST.shot | 28 +++---- .../snapshots/4-Babel-Tokens.shot | 44 ++++++++--- .../logical-no-parentheses/fixture.ts | 2 +- .../snapshots/1-TSESTree-AST.shot | 28 +++---- .../snapshots/2-TSESTree-Tokens.shot | 44 ++++++++--- .../snapshots/3-Babel-AST.shot | 28 +++---- .../snapshots/4-Babel-Tokens.shot | 44 ++++++++--- .../fixture.ts | 2 +- .../snapshots/1-TSESTree-AST.shot | 36 ++++----- .../snapshots/2-TSESTree-Tokens.shot | 50 ++++++------ .../snapshots/3-Babel-AST.shot | 36 ++++----- .../snapshots/4-Babel-Tokens.shot | 50 ++++++------ yarn.lock | 8 +- 35 files changed, 483 insertions(+), 369 deletions(-) diff --git a/.lintstagedrc b/.lintstagedrc index 691f6e0eb0e5..c4eebcd2f404 100644 --- a/.lintstagedrc +++ b/.lintstagedrc @@ -1,5 +1,3 @@ { - "*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}": [ - "prettier --write" - ] + "*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}": ["prettier --write"] } diff --git a/.prettierignore b/.prettierignore index bb855f41157a..637f32f77bfc 100644 --- a/.prettierignore +++ b/.prettierignore @@ -12,10 +12,6 @@ packages/eslint-plugin/src/configs/*.json CONTRIBUTORS.md packages/ast-spec/src/*/*/fixtures/_error_/*/fixture.ts -# prettier doesn't yet support satisfies -packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/ -packages/scope-manager/tests/fixtures/type-assertion/satisfies.ts - # Ignore CHANGELOG.md files to avoid issues with automated release job CHANGELOG.md diff --git a/package.json b/package.json index bddf6b4fe48c..30b2b224022b 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "ncp": "^2.0.0", "nx": "14.8.4", "patch-package": "^6.4.7", - "prettier": "2.7.1", + "prettier": "2.8.0", "pretty-format": "^29.0.3", "rimraf": "^3.0.2", "tmp": "^0.2.1", diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/fixture.ts index 917317da825e..36e81ab9edbd 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/fixture.ts +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/fixture.ts @@ -1 +1 @@ -[1,2,3] satisfies [1, 2, 3]; +[1, 2, 3] satisfies [1, 2, 3]; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/1-TSESTree-AST.shot index 8c0e41971eaa..cfbfed088ce2 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/1-TSESTree-AST.shot @@ -27,10 +27,10 @@ Program { raw: "2", value: 2, - range: [3, 4], + range: [4, 5], loc: { - start: { column: 3, line: 1 }, - end: { column: 4, line: 1 }, + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, }, }, Literal { @@ -38,18 +38,18 @@ Program { raw: "3", value: 3, - range: [5, 6], + range: [7, 8], loc: { - start: { column: 5, line: 1 }, - end: { column: 6, line: 1 }, + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, }, }, ], - range: [0, 7], + range: [0, 9], loc: { start: { column: 0, line: 1 }, - end: { column: 7, line: 1 }, + end: { column: 9, line: 1 }, }, }, typeAnnotation: TSTupleType { @@ -62,17 +62,17 @@ Program { raw: "1", value: 1, - range: [19, 20], + range: [21, 22], loc: { - start: { column: 19, line: 1 }, - end: { column: 20, line: 1 }, + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, }, }, - range: [19, 20], + range: [21, 22], loc: { - start: { column: 19, line: 1 }, - end: { column: 20, line: 1 }, + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, }, }, TSLiteralType { @@ -82,17 +82,17 @@ Program { raw: "2", value: 2, - range: [22, 23], + range: [24, 25], loc: { - start: { column: 22, line: 1 }, - end: { column: 23, line: 1 }, + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, }, }, - range: [22, 23], + range: [24, 25], loc: { - start: { column: 22, line: 1 }, - end: { column: 23, line: 1 }, + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, }, }, TSLiteralType { @@ -102,45 +102,45 @@ Program { raw: "3", value: 3, - range: [25, 26], + range: [27, 28], loc: { - start: { column: 25, line: 1 }, - end: { column: 26, line: 1 }, + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, }, }, - range: [25, 26], + range: [27, 28], loc: { - start: { column: 25, line: 1 }, - end: { column: 26, line: 1 }, + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, }, }, ], - range: [18, 27], + range: [20, 29], loc: { - start: { column: 18, line: 1 }, - end: { column: 27, line: 1 }, + start: { column: 20, line: 1 }, + end: { column: 29, line: 1 }, }, }, - range: [0, 27], + range: [0, 29], loc: { start: { column: 0, line: 1 }, - end: { column: 27, line: 1 }, + end: { column: 29, line: 1 }, }, }, - range: [0, 28], + range: [0, 30], loc: { start: { column: 0, line: 1 }, - end: { column: 28, line: 1 }, + end: { column: 30, line: 1 }, }, }, ], sourceType: "script", - range: [0, 29], + range: [0, 31], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 2 }, diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/2-TSESTree-Tokens.shot index 1bde181188ca..b4adbaf21bb9 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/2-TSESTree-Tokens.shot @@ -36,130 +36,130 @@ Array [ type: "Numeric", value: "2", - range: [3, 4], + range: [4, 5], loc: { - start: { column: 3, line: 1 }, - end: { column: 4, line: 1 }, + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, }, }, Punctuator { type: "Punctuator", value: ",", - range: [4, 5], + range: [5, 6], loc: { - start: { column: 4, line: 1 }, - end: { column: 5, line: 1 }, + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, }, }, Numeric { type: "Numeric", value: "3", - range: [5, 6], + range: [7, 8], loc: { - start: { column: 5, line: 1 }, - end: { column: 6, line: 1 }, + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, }, }, Punctuator { type: "Punctuator", value: "]", - range: [6, 7], + range: [8, 9], loc: { - start: { column: 6, line: 1 }, - end: { column: 7, line: 1 }, + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, }, }, Identifier { type: "Identifier", value: "satisfies", - range: [8, 17], + range: [10, 19], loc: { - start: { column: 8, line: 1 }, - end: { column: 17, line: 1 }, + start: { column: 10, line: 1 }, + end: { column: 19, line: 1 }, }, }, Punctuator { type: "Punctuator", value: "[", - range: [18, 19], + range: [20, 21], loc: { - start: { column: 18, line: 1 }, - end: { column: 19, line: 1 }, + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, }, }, Numeric { type: "Numeric", value: "1", - range: [19, 20], + range: [21, 22], loc: { - start: { column: 19, line: 1 }, - end: { column: 20, line: 1 }, + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, }, }, Punctuator { type: "Punctuator", value: ",", - range: [20, 21], + range: [22, 23], loc: { - start: { column: 20, line: 1 }, - end: { column: 21, line: 1 }, + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, }, }, Numeric { type: "Numeric", value: "2", - range: [22, 23], + range: [24, 25], loc: { - start: { column: 22, line: 1 }, - end: { column: 23, line: 1 }, + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, }, }, Punctuator { type: "Punctuator", value: ",", - range: [23, 24], + range: [25, 26], loc: { - start: { column: 23, line: 1 }, - end: { column: 24, line: 1 }, + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, }, }, Numeric { type: "Numeric", value: "3", - range: [25, 26], + range: [27, 28], loc: { - start: { column: 25, line: 1 }, - end: { column: 26, line: 1 }, + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, }, }, Punctuator { type: "Punctuator", value: "]", - range: [26, 27], + range: [28, 29], loc: { - start: { column: 26, line: 1 }, - end: { column: 27, line: 1 }, + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, }, }, Punctuator { type: "Punctuator", value: ";", - range: [27, 28], + range: [29, 30], loc: { - start: { column: 27, line: 1 }, - end: { column: 28, line: 1 }, + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, }, }, ] diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/3-Babel-AST.shot index d7f5aec514ed..635240ef2dd1 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/3-Babel-AST.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/3-Babel-AST.shot @@ -27,10 +27,10 @@ Program { raw: "2", value: 2, - range: [3, 4], + range: [4, 5], loc: { - start: { column: 3, line: 1 }, - end: { column: 4, line: 1 }, + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, }, }, Literal { @@ -38,18 +38,18 @@ Program { raw: "3", value: 3, - range: [5, 6], + range: [7, 8], loc: { - start: { column: 5, line: 1 }, - end: { column: 6, line: 1 }, + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, }, }, ], - range: [0, 7], + range: [0, 9], loc: { start: { column: 0, line: 1 }, - end: { column: 7, line: 1 }, + end: { column: 9, line: 1 }, }, }, typeAnnotation: TSTupleType { @@ -62,17 +62,17 @@ Program { raw: "1", value: 1, - range: [19, 20], + range: [21, 22], loc: { - start: { column: 19, line: 1 }, - end: { column: 20, line: 1 }, + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, }, }, - range: [19, 20], + range: [21, 22], loc: { - start: { column: 19, line: 1 }, - end: { column: 20, line: 1 }, + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, }, }, TSLiteralType { @@ -82,17 +82,17 @@ Program { raw: "2", value: 2, - range: [22, 23], + range: [24, 25], loc: { - start: { column: 22, line: 1 }, - end: { column: 23, line: 1 }, + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, }, }, - range: [22, 23], + range: [24, 25], loc: { - start: { column: 22, line: 1 }, - end: { column: 23, line: 1 }, + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, }, }, TSLiteralType { @@ -102,45 +102,45 @@ Program { raw: "3", value: 3, - range: [25, 26], + range: [27, 28], loc: { - start: { column: 25, line: 1 }, - end: { column: 26, line: 1 }, + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, }, }, - range: [25, 26], + range: [27, 28], loc: { - start: { column: 25, line: 1 }, - end: { column: 26, line: 1 }, + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, }, }, ], - range: [18, 27], + range: [20, 29], loc: { - start: { column: 18, line: 1 }, - end: { column: 27, line: 1 }, + start: { column: 20, line: 1 }, + end: { column: 29, line: 1 }, }, }, - range: [0, 27], + range: [0, 29], loc: { start: { column: 0, line: 1 }, - end: { column: 27, line: 1 }, + end: { column: 29, line: 1 }, }, }, - range: [0, 28], + range: [0, 30], loc: { start: { column: 0, line: 1 }, - end: { column: 28, line: 1 }, + end: { column: 30, line: 1 }, }, }, ], sourceType: "script", - range: [0, 29], + range: [0, 31], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 2 }, diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/4-Babel-Tokens.shot index 02abe5d8cba1..814b7c0915b2 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/array-array/snapshots/4-Babel-Tokens.shot @@ -36,130 +36,130 @@ Array [ type: "Numeric", value: "2", - range: [3, 4], + range: [4, 5], loc: { - start: { column: 3, line: 1 }, - end: { column: 4, line: 1 }, + start: { column: 4, line: 1 }, + end: { column: 5, line: 1 }, }, }, Punctuator { type: "Punctuator", value: ",", - range: [4, 5], + range: [5, 6], loc: { - start: { column: 4, line: 1 }, - end: { column: 5, line: 1 }, + start: { column: 5, line: 1 }, + end: { column: 6, line: 1 }, }, }, Numeric { type: "Numeric", value: "3", - range: [5, 6], + range: [7, 8], loc: { - start: { column: 5, line: 1 }, - end: { column: 6, line: 1 }, + start: { column: 7, line: 1 }, + end: { column: 8, line: 1 }, }, }, Punctuator { type: "Punctuator", value: "]", - range: [6, 7], + range: [8, 9], loc: { - start: { column: 6, line: 1 }, - end: { column: 7, line: 1 }, + start: { column: 8, line: 1 }, + end: { column: 9, line: 1 }, }, }, Identifier { type: "Identifier", value: "satisfies", - range: [8, 17], + range: [10, 19], loc: { - start: { column: 8, line: 1 }, - end: { column: 17, line: 1 }, + start: { column: 10, line: 1 }, + end: { column: 19, line: 1 }, }, }, Punctuator { type: "Punctuator", value: "[", - range: [18, 19], + range: [20, 21], loc: { - start: { column: 18, line: 1 }, - end: { column: 19, line: 1 }, + start: { column: 20, line: 1 }, + end: { column: 21, line: 1 }, }, }, Numeric { type: "Numeric", value: "1", - range: [19, 20], + range: [21, 22], loc: { - start: { column: 19, line: 1 }, - end: { column: 20, line: 1 }, + start: { column: 21, line: 1 }, + end: { column: 22, line: 1 }, }, }, Punctuator { type: "Punctuator", value: ",", - range: [20, 21], + range: [22, 23], loc: { - start: { column: 20, line: 1 }, - end: { column: 21, line: 1 }, + start: { column: 22, line: 1 }, + end: { column: 23, line: 1 }, }, }, Numeric { type: "Numeric", value: "2", - range: [22, 23], + range: [24, 25], loc: { - start: { column: 22, line: 1 }, - end: { column: 23, line: 1 }, + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, }, }, Punctuator { type: "Punctuator", value: ",", - range: [23, 24], + range: [25, 26], loc: { - start: { column: 23, line: 1 }, - end: { column: 24, line: 1 }, + start: { column: 25, line: 1 }, + end: { column: 26, line: 1 }, }, }, Numeric { type: "Numeric", value: "3", - range: [25, 26], + range: [27, 28], loc: { - start: { column: 25, line: 1 }, - end: { column: 26, line: 1 }, + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, }, }, Punctuator { type: "Punctuator", value: "]", - range: [26, 27], + range: [28, 29], loc: { - start: { column: 26, line: 1 }, - end: { column: 27, line: 1 }, + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, }, }, Punctuator { type: "Punctuator", value: ";", - range: [27, 28], + range: [29, 30], loc: { - start: { column: 27, line: 1 }, - end: { column: 28, line: 1 }, + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, }, }, ] diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/fixture.ts index 8478834cb780..23c6cdf5a50c 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/fixture.ts +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/fixture.ts @@ -1 +1 @@ -() => 1 satisfies number +() => 1 satisfies number; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/1-TSESTree-AST.shot index 57067f8fbff5..d678e2b5acef 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/1-TSESTree-AST.shot @@ -50,16 +50,16 @@ Program { }, }, - range: [0, 24], + range: [0, 25], loc: { start: { column: 0, line: 1 }, - end: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, }, }, ], sourceType: "script", - range: [0, 25], + range: [0, 26], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 2 }, diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/2-TSESTree-Tokens.shot index 09102ae267b1..0d642d948246 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/2-TSESTree-Tokens.shot @@ -62,5 +62,15 @@ Array [ end: { column: 24, line: 1 }, }, }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, ] `; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/3-Babel-AST.shot index 1ef0e54b35d8..55e90ce71c0c 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/3-Babel-AST.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/3-Babel-AST.shot @@ -50,16 +50,16 @@ Program { }, }, - range: [0, 24], + range: [0, 25], loc: { start: { column: 0, line: 1 }, - end: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, }, }, ], sourceType: "script", - range: [0, 25], + range: [0, 26], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 2 }, diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/4-Babel-Tokens.shot index 24cc5b2042ed..c921c840faaf 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-no-parentheses/snapshots/4-Babel-Tokens.shot @@ -62,5 +62,15 @@ Array [ end: { column: 24, line: 1 }, }, }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [24, 25], + loc: { + start: { column: 24, line: 1 }, + end: { column: 25, line: 1 }, + }, + }, ] `; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/fixture.ts index 15624b9aaf34..d0e16762720a 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/fixture.ts +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/fixture.ts @@ -1 +1 @@ -(() => 1) satisfies () => number +(() => 1) satisfies () => number; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/1-TSESTree-AST.shot index 7fa95a22000e..193cbbd12e38 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/1-TSESTree-AST.shot @@ -69,16 +69,16 @@ Program { }, }, - range: [0, 32], + range: [0, 33], loc: { start: { column: 0, line: 1 }, - end: { column: 32, line: 1 }, + end: { column: 33, line: 1 }, }, }, ], sourceType: "script", - range: [0, 33], + range: [0, 34], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 2 }, diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/2-TSESTree-Tokens.shot index b590cfdea64d..7e75dcaa2c0c 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/2-TSESTree-Tokens.shot @@ -112,5 +112,15 @@ Array [ end: { column: 32, line: 1 }, }, }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [32, 33], + loc: { + start: { column: 32, line: 1 }, + end: { column: 33, line: 1 }, + }, + }, ] `; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/3-Babel-AST.shot index 71627f35b044..7bddc387f4cf 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/3-Babel-AST.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/3-Babel-AST.shot @@ -69,16 +69,16 @@ Program { }, }, - range: [0, 32], + range: [0, 33], loc: { start: { column: 0, line: 1 }, - end: { column: 32, line: 1 }, + end: { column: 33, line: 1 }, }, }, ], sourceType: "script", - range: [0, 33], + range: [0, 34], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 2 }, diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/4-Babel-Tokens.shot index 58d8821988a5..5edb3e0a8411 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/4-Babel-Tokens.shot @@ -112,5 +112,15 @@ Array [ end: { column: 32, line: 1 }, }, }, + Punctuator { + type: "Punctuator", + value: ";", + + range: [32, 33], + loc: { + start: { column: 32, line: 1 }, + end: { column: 33, line: 1 }, + }, + }, ] `; diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/5-AST-Alignment-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/5-AST-Alignment-AST.shot index b45b591c63da..1999cc34c680 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/5-AST-Alignment-AST.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/arrow-func-with-parentheses/snapshots/5-AST-Alignment-AST.shot @@ -75,16 +75,16 @@ exports[`AST Fixtures expression TSSatisfiesExpression arrow-func-with-parenthes }, }, - range: [0, 32], + range: [0, 33], loc: { start: { column: 0, line: 1 }, - end: { column: 32, line: 1 }, + end: { column: 33, line: 1 }, }, }, ], sourceType: 'script', - range: [0, 33], + range: [0, 34], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 2 }, diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/fixture.ts index 6ead32331fa4..dc8407dc0d6c 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/fixture.ts +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/fixture.ts @@ -1 +1 @@ -foo ? 1 : 0 satisfies number; +foo ? 1 : (0 satisfies number); diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/1-TSESTree-AST.shot index 5674f78acdf1..bb649ea977d4 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/1-TSESTree-AST.shot @@ -15,26 +15,26 @@ Program { raw: "0", value: 0, - range: [10, 11], + range: [11, 12], loc: { - start: { column: 10, line: 1 }, - end: { column: 11, line: 1 }, + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, }, }, typeAnnotation: TSNumberKeyword { type: "TSNumberKeyword", - range: [22, 28], + range: [23, 29], loc: { - start: { column: 22, line: 1 }, - end: { column: 28, line: 1 }, + start: { column: 23, line: 1 }, + end: { column: 29, line: 1 }, }, }, - range: [10, 28], + range: [11, 29], loc: { - start: { column: 10, line: 1 }, - end: { column: 28, line: 1 }, + start: { column: 11, line: 1 }, + end: { column: 29, line: 1 }, }, }, consequent: Literal { @@ -59,23 +59,23 @@ Program { }, }, - range: [0, 28], + range: [0, 30], loc: { start: { column: 0, line: 1 }, - end: { column: 28, line: 1 }, + end: { column: 30, line: 1 }, }, }, - range: [0, 29], + range: [0, 31], loc: { start: { column: 0, line: 1 }, - end: { column: 29, line: 1 }, + end: { column: 31, line: 1 }, }, }, ], sourceType: "script", - range: [0, 30], + range: [0, 32], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 2 }, diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/2-TSESTree-Tokens.shot index 579fa0c06152..43f6da6a6806 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/2-TSESTree-Tokens.shot @@ -42,9 +42,9 @@ Array [ end: { column: 9, line: 1 }, }, }, - Numeric { - type: "Numeric", - value: "0", + Punctuator { + type: "Punctuator", + value: "(", range: [10, 11], loc: { @@ -52,34 +52,54 @@ Array [ end: { column: 11, line: 1 }, }, }, + Numeric { + type: "Numeric", + value: "0", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, Identifier { type: "Identifier", value: "satisfies", - range: [12, 21], + range: [13, 22], loc: { - start: { column: 12, line: 1 }, - end: { column: 21, line: 1 }, + start: { column: 13, line: 1 }, + end: { column: 22, line: 1 }, }, }, Identifier { type: "Identifier", value: "number", - range: [22, 28], + range: [23, 29], + loc: { + start: { column: 23, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [29, 30], loc: { - start: { column: 22, line: 1 }, - end: { column: 28, line: 1 }, + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, }, }, Punctuator { type: "Punctuator", value: ";", - range: [28, 29], + range: [30, 31], loc: { - start: { column: 28, line: 1 }, - end: { column: 29, line: 1 }, + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, }, }, ] diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/3-Babel-AST.shot index 9c3ff77da55f..4cba5b2f4f14 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/3-Babel-AST.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/3-Babel-AST.shot @@ -15,26 +15,26 @@ Program { raw: "0", value: 0, - range: [10, 11], + range: [11, 12], loc: { - start: { column: 10, line: 1 }, - end: { column: 11, line: 1 }, + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, }, }, typeAnnotation: TSNumberKeyword { type: "TSNumberKeyword", - range: [22, 28], + range: [23, 29], loc: { - start: { column: 22, line: 1 }, - end: { column: 28, line: 1 }, + start: { column: 23, line: 1 }, + end: { column: 29, line: 1 }, }, }, - range: [10, 28], + range: [11, 29], loc: { - start: { column: 10, line: 1 }, - end: { column: 28, line: 1 }, + start: { column: 11, line: 1 }, + end: { column: 29, line: 1 }, }, }, consequent: Literal { @@ -59,23 +59,23 @@ Program { }, }, - range: [0, 28], + range: [0, 30], loc: { start: { column: 0, line: 1 }, - end: { column: 28, line: 1 }, + end: { column: 30, line: 1 }, }, }, - range: [0, 29], + range: [0, 31], loc: { start: { column: 0, line: 1 }, - end: { column: 29, line: 1 }, + end: { column: 31, line: 1 }, }, }, ], sourceType: "script", - range: [0, 30], + range: [0, 32], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 2 }, diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/4-Babel-Tokens.shot index d9c69f96e5ef..80d8c6ce89ea 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/conditional-no-parentheses/snapshots/4-Babel-Tokens.shot @@ -42,9 +42,9 @@ Array [ end: { column: 9, line: 1 }, }, }, - Numeric { - type: "Numeric", - value: "0", + Punctuator { + type: "Punctuator", + value: "(", range: [10, 11], loc: { @@ -52,34 +52,54 @@ Array [ end: { column: 11, line: 1 }, }, }, + Numeric { + type: "Numeric", + value: "0", + + range: [11, 12], + loc: { + start: { column: 11, line: 1 }, + end: { column: 12, line: 1 }, + }, + }, Identifier { type: "Identifier", value: "satisfies", - range: [12, 21], + range: [13, 22], loc: { - start: { column: 12, line: 1 }, - end: { column: 21, line: 1 }, + start: { column: 13, line: 1 }, + end: { column: 22, line: 1 }, }, }, Identifier { type: "Identifier", value: "number", - range: [22, 28], + range: [23, 29], + loc: { + start: { column: 23, line: 1 }, + end: { column: 29, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [29, 30], loc: { - start: { column: 22, line: 1 }, - end: { column: 28, line: 1 }, + start: { column: 29, line: 1 }, + end: { column: 30, line: 1 }, }, }, Punctuator { type: "Punctuator", value: ";", - range: [28, 29], + range: [30, 31], loc: { - start: { column: 28, line: 1 }, - end: { column: 29, line: 1 }, + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, }, }, ] diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/fixture.ts index 09a4c612e307..953653b0e23a 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/fixture.ts +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/fixture.ts @@ -1 +1 @@ -foo === 1 satisfies number; +foo === (1 satisfies number); diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/1-TSESTree-AST.shot index f80151c90329..1ad1131264a4 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/1-TSESTree-AST.shot @@ -26,46 +26,46 @@ Program { raw: "1", value: 1, - range: [8, 9], + range: [9, 10], loc: { - start: { column: 8, line: 1 }, - end: { column: 9, line: 1 }, + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, }, }, typeAnnotation: TSNumberKeyword { type: "TSNumberKeyword", - range: [20, 26], + range: [21, 27], loc: { - start: { column: 20, line: 1 }, - end: { column: 26, line: 1 }, + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, }, }, - range: [8, 26], + range: [9, 27], loc: { - start: { column: 8, line: 1 }, - end: { column: 26, line: 1 }, + start: { column: 9, line: 1 }, + end: { column: 27, line: 1 }, }, }, - range: [0, 26], + range: [0, 28], loc: { start: { column: 0, line: 1 }, - end: { column: 26, line: 1 }, + end: { column: 28, line: 1 }, }, }, - range: [0, 27], + range: [0, 29], loc: { start: { column: 0, line: 1 }, - end: { column: 27, line: 1 }, + end: { column: 29, line: 1 }, }, }, ], sourceType: "script", - range: [0, 28], + range: [0, 30], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 2 }, diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/2-TSESTree-Tokens.shot index 5391022e27f0..f5e333ee1db9 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/2-TSESTree-Tokens.shot @@ -22,9 +22,9 @@ Array [ end: { column: 7, line: 1 }, }, }, - Numeric { - type: "Numeric", - value: "1", + Punctuator { + type: "Punctuator", + value: "(", range: [8, 9], loc: { @@ -32,34 +32,54 @@ Array [ end: { column: 9, line: 1 }, }, }, + Numeric { + type: "Numeric", + value: "1", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, Identifier { type: "Identifier", value: "satisfies", - range: [10, 19], + range: [11, 20], loc: { - start: { column: 10, line: 1 }, - end: { column: 19, line: 1 }, + start: { column: 11, line: 1 }, + end: { column: 20, line: 1 }, }, }, Identifier { type: "Identifier", value: "number", - range: [20, 26], + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [27, 28], loc: { - start: { column: 20, line: 1 }, - end: { column: 26, line: 1 }, + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, }, }, Punctuator { type: "Punctuator", value: ";", - range: [26, 27], + range: [28, 29], loc: { - start: { column: 26, line: 1 }, - end: { column: 27, line: 1 }, + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, }, }, ] diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/3-Babel-AST.shot index 60189a703583..a2add0503752 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/3-Babel-AST.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/3-Babel-AST.shot @@ -26,46 +26,46 @@ Program { raw: "1", value: 1, - range: [8, 9], + range: [9, 10], loc: { - start: { column: 8, line: 1 }, - end: { column: 9, line: 1 }, + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, }, }, typeAnnotation: TSNumberKeyword { type: "TSNumberKeyword", - range: [20, 26], + range: [21, 27], loc: { - start: { column: 20, line: 1 }, - end: { column: 26, line: 1 }, + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, }, }, - range: [8, 26], + range: [9, 27], loc: { - start: { column: 8, line: 1 }, - end: { column: 26, line: 1 }, + start: { column: 9, line: 1 }, + end: { column: 27, line: 1 }, }, }, - range: [0, 26], + range: [0, 28], loc: { start: { column: 0, line: 1 }, - end: { column: 26, line: 1 }, + end: { column: 28, line: 1 }, }, }, - range: [0, 27], + range: [0, 29], loc: { start: { column: 0, line: 1 }, - end: { column: 27, line: 1 }, + end: { column: 29, line: 1 }, }, }, ], sourceType: "script", - range: [0, 28], + range: [0, 30], loc: { start: { column: 0, line: 1 }, end: { column: 0, line: 2 }, diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/4-Babel-Tokens.shot index cac159f58dc3..e4fa1f6cea58 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/logical-no-parentheses/snapshots/4-Babel-Tokens.shot @@ -22,9 +22,9 @@ Array [ end: { column: 7, line: 1 }, }, }, - Numeric { - type: "Numeric", - value: "1", + Punctuator { + type: "Punctuator", + value: "(", range: [8, 9], loc: { @@ -32,34 +32,54 @@ Array [ end: { column: 9, line: 1 }, }, }, + Numeric { + type: "Numeric", + value: "1", + + range: [9, 10], + loc: { + start: { column: 9, line: 1 }, + end: { column: 10, line: 1 }, + }, + }, Identifier { type: "Identifier", value: "satisfies", - range: [10, 19], + range: [11, 20], loc: { - start: { column: 10, line: 1 }, - end: { column: 19, line: 1 }, + start: { column: 11, line: 1 }, + end: { column: 20, line: 1 }, }, }, Identifier { type: "Identifier", value: "number", - range: [20, 26], + range: [21, 27], + loc: { + start: { column: 21, line: 1 }, + end: { column: 27, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + + range: [27, 28], loc: { - start: { column: 20, line: 1 }, - end: { column: 26, line: 1 }, + start: { column: 27, line: 1 }, + end: { column: 28, line: 1 }, }, }, Punctuator { type: "Punctuator", value: ";", - range: [26, 27], + range: [28, 29], loc: { - start: { column: 26, line: 1 }, - end: { column: 27, line: 1 }, + start: { column: 28, line: 1 }, + end: { column: 29, line: 1 }, }, }, ] diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/fixture.ts b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/fixture.ts index ec7b71c8e2b1..b7726f7f1404 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/fixture.ts +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/fixture.ts @@ -1 +1 @@ -({ prop: 'string' }) satisfies { prop: string }; +({ prop: 'string' } satisfies { prop: string }); diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/1-TSESTree-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/1-TSESTree-AST.shot index 1ed0e662a991..c39ffc049d11 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/1-TSESTree-AST.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/1-TSESTree-AST.shot @@ -63,10 +63,10 @@ Program { type: "Identifier", name: "prop", - range: [33, 37], + range: [32, 36], loc: { - start: { column: 33, line: 1 }, - end: { column: 37, line: 1 }, + start: { column: 32, line: 1 }, + end: { column: 36, line: 1 }, }, }, typeAnnotation: TSTypeAnnotation { @@ -74,39 +74,39 @@ Program { typeAnnotation: TSStringKeyword { type: "TSStringKeyword", - range: [39, 45], + range: [38, 44], loc: { - start: { column: 39, line: 1 }, - end: { column: 45, line: 1 }, + start: { column: 38, line: 1 }, + end: { column: 44, line: 1 }, }, }, - range: [37, 45], + range: [36, 44], loc: { - start: { column: 37, line: 1 }, - end: { column: 45, line: 1 }, + start: { column: 36, line: 1 }, + end: { column: 44, line: 1 }, }, }, - range: [33, 45], + range: [32, 44], loc: { - start: { column: 33, line: 1 }, - end: { column: 45, line: 1 }, + start: { column: 32, line: 1 }, + end: { column: 44, line: 1 }, }, }, ], - range: [31, 47], + range: [30, 46], loc: { - start: { column: 31, line: 1 }, - end: { column: 47, line: 1 }, + start: { column: 30, line: 1 }, + end: { column: 46, line: 1 }, }, }, - range: [0, 47], + range: [1, 46], loc: { - start: { column: 0, line: 1 }, - end: { column: 47, line: 1 }, + start: { column: 1, line: 1 }, + end: { column: 46, line: 1 }, }, }, diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/2-TSESTree-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/2-TSESTree-Tokens.shot index 99f068a424bf..be50e77f2710 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/2-TSESTree-Tokens.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/2-TSESTree-Tokens.shot @@ -62,70 +62,70 @@ Array [ end: { column: 19, line: 1 }, }, }, - Punctuator { - type: "Punctuator", - value: ")", - - range: [19, 20], - loc: { - start: { column: 19, line: 1 }, - end: { column: 20, line: 1 }, - }, - }, Identifier { type: "Identifier", value: "satisfies", - range: [21, 30], + range: [20, 29], loc: { - start: { column: 21, line: 1 }, - end: { column: 30, line: 1 }, + start: { column: 20, line: 1 }, + end: { column: 29, line: 1 }, }, }, Punctuator { type: "Punctuator", value: "{", - range: [31, 32], + range: [30, 31], loc: { - start: { column: 31, line: 1 }, - end: { column: 32, line: 1 }, + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, }, }, Identifier { type: "Identifier", value: "prop", - range: [33, 37], + range: [32, 36], loc: { - start: { column: 33, line: 1 }, - end: { column: 37, line: 1 }, + start: { column: 32, line: 1 }, + end: { column: 36, line: 1 }, }, }, Punctuator { type: "Punctuator", value: ":", - range: [37, 38], + range: [36, 37], loc: { - start: { column: 37, line: 1 }, - end: { column: 38, line: 1 }, + start: { column: 36, line: 1 }, + end: { column: 37, line: 1 }, }, }, Identifier { type: "Identifier", value: "string", - range: [39, 45], + range: [38, 44], loc: { - start: { column: 39, line: 1 }, - end: { column: 45, line: 1 }, + start: { column: 38, line: 1 }, + end: { column: 44, line: 1 }, }, }, Punctuator { type: "Punctuator", value: "}", + range: [45, 46], + loc: { + start: { column: 45, line: 1 }, + end: { column: 46, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + range: [46, 47], loc: { start: { column: 46, line: 1 }, diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/3-Babel-AST.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/3-Babel-AST.shot index c5868aaf0d1e..90c569abf825 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/3-Babel-AST.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/3-Babel-AST.shot @@ -63,10 +63,10 @@ Program { type: "Identifier", name: "prop", - range: [33, 37], + range: [32, 36], loc: { - start: { column: 33, line: 1 }, - end: { column: 37, line: 1 }, + start: { column: 32, line: 1 }, + end: { column: 36, line: 1 }, }, }, typeAnnotation: TSTypeAnnotation { @@ -74,39 +74,39 @@ Program { typeAnnotation: TSStringKeyword { type: "TSStringKeyword", - range: [39, 45], + range: [38, 44], loc: { - start: { column: 39, line: 1 }, - end: { column: 45, line: 1 }, + start: { column: 38, line: 1 }, + end: { column: 44, line: 1 }, }, }, - range: [37, 45], + range: [36, 44], loc: { - start: { column: 37, line: 1 }, - end: { column: 45, line: 1 }, + start: { column: 36, line: 1 }, + end: { column: 44, line: 1 }, }, }, - range: [33, 45], + range: [32, 44], loc: { - start: { column: 33, line: 1 }, - end: { column: 45, line: 1 }, + start: { column: 32, line: 1 }, + end: { column: 44, line: 1 }, }, }, ], - range: [31, 47], + range: [30, 46], loc: { - start: { column: 31, line: 1 }, - end: { column: 47, line: 1 }, + start: { column: 30, line: 1 }, + end: { column: 46, line: 1 }, }, }, - range: [0, 47], + range: [1, 46], loc: { - start: { column: 0, line: 1 }, - end: { column: 47, line: 1 }, + start: { column: 1, line: 1 }, + end: { column: 46, line: 1 }, }, }, diff --git a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/4-Babel-Tokens.shot b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/4-Babel-Tokens.shot index 128fc9c61284..45fc90349daf 100644 --- a/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/4-Babel-Tokens.shot +++ b/packages/ast-spec/src/expression/TSSatisfiesExpression/fixtures/object-object-inner-parentheses/snapshots/4-Babel-Tokens.shot @@ -62,70 +62,70 @@ Array [ end: { column: 19, line: 1 }, }, }, - Punctuator { - type: "Punctuator", - value: ")", - - range: [19, 20], - loc: { - start: { column: 19, line: 1 }, - end: { column: 20, line: 1 }, - }, - }, Identifier { type: "Identifier", value: "satisfies", - range: [21, 30], + range: [20, 29], loc: { - start: { column: 21, line: 1 }, - end: { column: 30, line: 1 }, + start: { column: 20, line: 1 }, + end: { column: 29, line: 1 }, }, }, Punctuator { type: "Punctuator", value: "{", - range: [31, 32], + range: [30, 31], loc: { - start: { column: 31, line: 1 }, - end: { column: 32, line: 1 }, + start: { column: 30, line: 1 }, + end: { column: 31, line: 1 }, }, }, Identifier { type: "Identifier", value: "prop", - range: [33, 37], + range: [32, 36], loc: { - start: { column: 33, line: 1 }, - end: { column: 37, line: 1 }, + start: { column: 32, line: 1 }, + end: { column: 36, line: 1 }, }, }, Punctuator { type: "Punctuator", value: ":", - range: [37, 38], + range: [36, 37], loc: { - start: { column: 37, line: 1 }, - end: { column: 38, line: 1 }, + start: { column: 36, line: 1 }, + end: { column: 37, line: 1 }, }, }, Identifier { type: "Identifier", value: "string", - range: [39, 45], + range: [38, 44], loc: { - start: { column: 39, line: 1 }, - end: { column: 45, line: 1 }, + start: { column: 38, line: 1 }, + end: { column: 44, line: 1 }, }, }, Punctuator { type: "Punctuator", value: "}", + range: [45, 46], + loc: { + start: { column: 45, line: 1 }, + end: { column: 46, line: 1 }, + }, + }, + Punctuator { + type: "Punctuator", + value: ")", + range: [46, 47], loc: { start: { column: 46, line: 1 }, diff --git a/yarn.lock b/yarn.lock index f771e6ece9f6..3ca3e9af00c5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11560,10 +11560,10 @@ prepend-http@^2.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= -prettier@*, prettier@2.7.1, prettier@^2.6.2: - version "2.7.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" - integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== +prettier@*, prettier@2.8.0, prettier@^2.6.2: + version "2.8.0" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.0.tgz#c7df58393c9ba77d6fba3921ae01faf994fb9dc9" + integrity sha512-9Lmg8hTFZKG0Asr/kW9Bp8tJjRVluO8EJQVfY2T7FMw9T5jy4I/Uvx0Rca/XWf50QQ1/SS48+6IJWnrb+2yemA== pretty-bytes@^5.3.0: version "5.6.0" From c4ba3877b793a8e81a773cb62e313dcf61b9cb1c Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 23 Nov 2022 18:23:02 -0500 Subject: [PATCH 04/18] chore(website): add details to Configurations page (#5719) --- docs/linting/CONFIGURATIONS.md | 122 ------------------ docs/linting/CONFIGURATIONS.mdx | 141 +++++++++++++++++++++ docs/linting/troubleshooting/FORMATTING.md | 16 +++ 3 files changed, 157 insertions(+), 122 deletions(-) delete mode 100644 docs/linting/CONFIGURATIONS.md create mode 100644 docs/linting/CONFIGURATIONS.mdx diff --git a/docs/linting/CONFIGURATIONS.md b/docs/linting/CONFIGURATIONS.md deleted file mode 100644 index de05a216ff87..000000000000 --- a/docs/linting/CONFIGURATIONS.md +++ /dev/null @@ -1,122 +0,0 @@ ---- -id: configs -title: Configurations ---- - -[ESLint shareable configurations](https://eslint.org/docs/latest/developer-guide/shareable-configs) exist to provide a comprehensive base config for you, with the intention that you add the config and it gives you an opinionated setup. - -## Built-In Configurations - -`@typescript-eslint/eslint-plugin` includes built-in configurations you can extend from to pull in the recommended starting rules. - -With the exception of `strict`, all configurations are considered "stable". -Rule additions and removals are treated as breaking changes and will only be done in major version bumps. - -:::note -We recommend most packages extend from [`recommended-requiring-type-checking`](#recommended-requiring-type-checking) (which requires [typed linting](./TYPED_LINTING.md)). -::: - -### `eslint-recommended` - -This ruleset is meant to be used after extending `eslint:recommended`. -It disables core ESLint rules that are already checked by the TypeScript compiler. -Additionally, it enables rules that promote using the more modern constructs TypeScript allows for. - -```jsonc -{ - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended" - ] -} -``` - -This config is automatically included if you use any of the other configurations mentioned on this page. - -### `recommended` - -Recommended rules for code correctness that you can drop in without additional configuration. -These rules are those whose reports are almost always for a bad practice and/or likely bug. -`recommended` also disables rules known to conflict with this repository, or cause issues in TypeScript codebases. - -```json -{ - "extends": ["plugin:@typescript-eslint/recommended"] -} -``` - -:::tip -We strongly recommend all TypeScript projects extend from this configuration. -::: - -### `recommended-requiring-type-checking` - -Additional recommended rules that require type information. -Rules in this configuration are similarly useful to those in `recommended`. - -```json -{ - "extends": [ - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking" - ] -} -``` - -:::tip -We recommend all TypeScript projects extend from this configuration, with the caveat that rules using type information take longer to run. -See [Linting with Type Information](/docs/linting/typed-linting) for more details. -::: - -### `strict` - -Additional strict rules that can also catch bugs but are more opinionated than recommended rules. - -```json -{ - "extends": [ - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking", - "plugin:@typescript-eslint/strict" - ] -} -``` - -:::tip -We recommend a TypeScript project extend from this configuration only if a nontrivial percentage of its developers are highly proficient in TypeScript. -::: - -## Overriding Configurations - -These configurations are our recommended starting points, but **you don't need to use them as-is**. -ESLint allows you to configure your own rule settings on top of any extended configurations. -See [ESLint's Configuring Rules docs](https://eslint.org/docs/user-guide/configuring/rules#using-configuration-files). - -### Suggesting Configuration Changes - -If you feel strongly that a specific rule should (or should not) be one of these configurations, please [file an issue](https://github.com/typescript-eslint/typescript-eslint/issues/new?assignees=&labels=package%3A+eslint-plugin%2Cpreset+config+change%2Ctriage&template=09-config-change.yaml&title=Configs%3A+%3Ca+short+description+of+my+proposal%3E) along with a **detailed** argument explaining your reasoning. - -## Prettier - -If you use [`prettier`](https://www.npmjs.com/package/prettier), there is also a helpful config to help ensure ESLint doesn't report on formatting issues that prettier will fix: [`eslint-config-prettier`](https://www.npmjs.com/package/eslint-config-prettier). - -Using this config by adding it to the end of your `extends`: - -```js title=".eslintrc.js" -module.exports = { - root: true, - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint'], - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - // Add this line - 'prettier', - ], -}; -``` - -:::warning -**We strongly recommend you use Prettier or an equivalent**, not ESLint formatting rules. -See [this issue](https://github.com/typescript-eslint/typescript-eslint/issues/4907 'Issue: Docs: Add our opinion on delegating stylistic issues to a tool such as Prettier #4907') for more information. -::: diff --git a/docs/linting/CONFIGURATIONS.mdx b/docs/linting/CONFIGURATIONS.mdx new file mode 100644 index 000000000000..eebf58cf8fd2 --- /dev/null +++ b/docs/linting/CONFIGURATIONS.mdx @@ -0,0 +1,141 @@ +--- +id: configs +title: Configurations +--- + +[ESLint shareable configurations](https://eslint.org/docs/latest/developer-guide/shareable-configs) exist to provide a comprehensive base config for you. +`@typescript-eslint/eslint-plugin` includes built-in configurations you can extend from to pull in the recommended starting rules. + +> With the exception of `strict`, all configurations are considered "stable". +> Rule additions and removals are treated as breaking changes and will only be done in major version bumps. + +## Recommended Configurations + +Most projects should extend from at least one of: + +- [`recommended`](#recommended): Recommended rules for code correctness that you can drop in without additional configuration. +- [`recommended-requiring-type-checking`](#recommended-requiring-type-checking): Additional recommended rules that require type information. +- [`strict`](#strict): Additional strict rules that can also catch bugs but are more opinionated than recommended rules. + +:::tip +We recommend most projects use [`recommended-requiring-type-checking`](#recommended-requiring-type-checking) (which requires [typed linting](./TYPED_LINTING.md)). +::: + +:::note +These configurations are our recommended starting points, but **you don't need to use them as-is**. +ESLint allows configuring own rule settings on top of extended configurations. +See [ESLint's Configuring Rules docs](https://eslint.org/docs/user-guide/configuring/rules#using-configuration-files). +::: + +### `recommended` + +Recommended rules for code correctness that you can drop in without additional configuration. +These rules are those whose reports are almost always for a bad practice and/or likely bug. +`recommended` also disables rules known to conflict with this repository, or cause issues in TypeScript codebases. + +```json +{ + "extends": ["plugin:@typescript-eslint/recommended"] +} +``` + +See [`configs/recommended.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended.ts) for the exact contents of this config. + +:::tip +We strongly recommend all TypeScript projects extend from `plugin:@typescript-eslint/recommended`. +::: + +### `recommended-requiring-type-checking` + +Additional recommended rules that require type information. +Rules in this configuration are similarly useful to those in `recommended`. + +```json +{ + "extends": [ + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking" + ] +} +``` + +See [`configs/recommended-requiring-type-checking.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/recommended-requiring-type-checking.ts) for the exact contents of this config. + +:::tip +We recommend all TypeScript projects extend from `plugin:@typescript-eslint/recommended-requiring-type-checking`, with the caveat that rules using type information take longer to run. +See [Linting with Type Information](/docs/linting/typed-linting) for more details. +::: + +### `strict` + +Additional strict rules that can also catch bugs but are more opinionated than recommended rules. + +```json +{ + "extends": [ + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "plugin:@typescript-eslint/strict" + ] +} +``` + +See [`configs/strict.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/strict.ts) for the exact contents of this config. + +:::caution +We recommend a TypeScript project extend from `plugin:@typescript-eslint/strict` only if a nontrivial percentage of its developers are highly proficient in TypeScript. +::: + +## Other Configurations + +TypeScript ESLint includes a scattering of utility configurations used by the recommended configurations. +We don't recommend using these directly; instead, extend from an earlier recommended rule. + +### `all` + +Enables each the rules provided as a part of TypeScript ESLint. +Note that many rules are not applicable in all codebases, or are meant to be configured. + +See [`configs/all.ts`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/all.ts) for the exact contents of this config. + +:::warning +We do not recommend a TypeScript projects extend from `plugin:@typescript-eslint/all`. +Many rules conflict with each other and/or are intended to be configured per-project. +::: + +### `base` + +A minimal ruleset that sets only the required parser and plugin options needed to run TypeScript ESLint. + + + +This config is automatically included if you use any of the recommended configurations. + +### `eslint-recommended` + +This ruleset is meant to be used after extending `eslint:recommended`. +It disables core ESLint rules that are already checked by the TypeScript compiler. +Additionally, it enables rules that promote using the more modern constructs TypeScript allows for. + +```jsonc +{ + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended" + ] +} +``` + +This config is automatically included if you use any of the recommended configurations. + +See [`configs/eslint-recommended.ts``](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts) for the exact contents of this config. + +## Suggesting Configuration Changes + +If you feel strongly that a specific rule should (or should not) be one of these configurations, please [file an issue](https://github.com/typescript-eslint/typescript-eslint/issues/new?assignees=&labels=package%3A+eslint-plugin%2Cpreset+config+change%2Ctriage&template=09-config-change.yaml&title=Configs%3A+%3Ca+short+description+of+my+proposal%3E) along with a **detailed** argument explaining your reasoning. + +## Formatting + +None of the preset configs provided by TypeScript ESLint enable formatting rules (rules that only serve to enforce code whitespace and other trivia). +We strongly recommend you use Prettier or an equivalent for formatting your code, not ESLint formatting rules. +See [What About Formatting? > Suggested Usage](./troubleshooting/formatting#suggested-usage). diff --git a/docs/linting/troubleshooting/FORMATTING.md b/docs/linting/troubleshooting/FORMATTING.md index 2acb36d0e600..47ff57c3b45c 100644 --- a/docs/linting/troubleshooting/FORMATTING.md +++ b/docs/linting/troubleshooting/FORMATTING.md @@ -27,6 +27,22 @@ Linters typically run on a rule-by-rule basis, typically resulting in many edge We recommend using [`eslint-config-prettier`](https://github.com/prettier/eslint-config-prettier) to disable formatting rules in your ESLint configuration. You can then configure your formatter separately from ESLint. +Using this config by adding it to the end of your `extends`: + +```js title=".eslintrc.js" +module.exports = { + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + // Add this line + 'prettier', + ], + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + root: true, +}; +``` + ## ESLint Core and Formatting Per [ESLint's 2020 Changes to Rule Policies blog post](https://eslint.org/blog/2020/05/changes-to-rules-policies#what-are-the-changes): From 6de4a9a6493fcab3d9d753c8ec5c643c60f22210 Mon Sep 17 00:00:00 2001 From: James Henry Date: Thu, 24 Nov 2022 03:28:44 +0400 Subject: [PATCH 05/18] chore: add automation for @nrwl + nx package updates (#5797) * chore: add automation for @nrwl + nx package updates * chore: fix formatting --- .github/renovate.json5 | 4 +- .github/workflows/nx-migrate.yml | 85 ++++++++++++++++++++++++++++++++ package.json | 3 +- tools/postinstall.ts | 34 +++++++++++++ yarn.lock | 2 +- 5 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/nx-migrate.yml create mode 100644 tools/postinstall.ts diff --git a/.github/renovate.json5 b/.github/renovate.json5 index f5d016eb6dbb..0c18b35da840 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -5,14 +5,14 @@ 'globby', // this dep now uses package.json exports - we will be removing it next major 'eslint-scope', + // this dep is now ESM only + 'execa', // the nx packages get updated using the nx migrate CLI '@nrwl/cli', '@nrwl/devkit', '@nrwl/jest', '@nrwl/nx-cloud', '@nrwl/tao', - '@nrwl/workspace', - 'nx', ], ignorePaths: [ // integration test package.json's should never be updated as they're purposely fixed tests diff --git a/.github/workflows/nx-migrate.yml b/.github/workflows/nx-migrate.yml new file mode 100644 index 000000000000..af107f6c3910 --- /dev/null +++ b/.github/workflows/nx-migrate.yml @@ -0,0 +1,85 @@ +# This workflow is used to augment the capabilities of the renovate GitHub app by running a full +# `nx migrate` when renovate opens a PR to change the version of @nrwl/workspace. +# +# You will therefore also notice that in the renovate configuration, we ignore any packages which +# Nx will manage for us as part of `nx migrate` such as the remaining @nrwl/* packages and jest. + +name: Nx Migrate + +on: + pull_request: + branches: [main] + paths: + - 'package.json' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.number || github.ref }} + cancel-in-progress: true + +jobs: + maybe_nx_migrate: + # Only run if it was the renovate bot that triggered the workflow (otherwise we'll create a loop) + if: contains('["renovate[bot]"]', github.actor) == true + name: Run nx migrate if required + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + # To allow us to perform the git diff we need the git history + fetch-depth: 0 + # To ensure we can push from a different user (and therefore cause actions to rerun) + persist-credentials: false + + - name: Derive appropriate SHAs for base and head for `nx affected` commands + uses: nrwl/nx-set-shas@v3 + + - name: Check if @nrwl/workspace was changed as part of the latest commit on the PR + id: nrwl-workspace-package-check + run: | + git diff HEAD~1 -G"@nrwl/workspace" --exit-code package.json && echo "@nrwl/workspace unchanged" || echo "::set-output name=was-changed::true" + + - name: Run nx migrate if @nrwl/workspace changed and commit the results + if: ${{ steps.nrwl-workspace-package-check.outputs.was-changed == 'true' }} + env: + # We cannot use secrets.GITHUB_TOKEN for this because it is not permitted to kick off subsequent actions worfklow runs, so we use a PAT instead + GITHUB_TOKEN: ${{ secrets.JAMES_HENRY_GITHUB_TOKEN }} + # We don't want to run any of our postinstall logic when Nx is invoking install behind the scenes + SKIP_POSTINSTALL: 'true' + run: | + # Checkout the PR branch using the github CLI + gh pr checkout ${{ github.event.pull_request.number }} + + # Get the version of Nx we are migrating to + NX_VERSION=$(node -e "console.log(require('./package.json').devDependencies['@nrwl/workspace'])") + + # Revert renovate's changes to package.json and yarn.lock so that it is a clean migrate from the status quo + git checkout HEAD~1 -- package.json yarn.lock + + yarn --ignore-scripts + + npx nx migrate @nrwl/workspace@$NX_VERSION + + # Sometimes Nx can require config formatting changes after a migrate command + yarn --ignore-scripts + npx nx format + + # migrations.json may or may not exist after running nx migrate + if [ -f migrations.json ]; then + # This will also invoke yarn automatically + npx nx migrate --run-migrations=migrations.json + + # After we have run its migrations, we no longer need the migrations.json file + rm migrations.json + fi + + # Ensure all the changed files are formatted appropriately + yarn format + + # Commit all the changes to the PR (see note on not being able to use secrets.GITHUB_TOKEN for this) + git config --global user.email "james@henry.sc" + git config --global user.name "JamesHenry" + git remote set-url origin https://x-access-token:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git + + git add --all + git commit -m "chore: run nx migrate for @nrwl/workspace v$NX_VERSION" + git push diff --git a/package.json b/package.json index 30b2b224022b..c5c7499365c3 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "lint-markdown-fix": "yarn lint-markdown --fix", "lint-markdown": "markdownlint \"**/*.md\" --config=.markdownlint.json --ignore-path=.markdownlintignore", "lint": "nx run-many --target=lint --all --parallel", - "postinstall": "yarn patch-package && yarn husky install && yarn build", + "postinstall": "yarn ts-node --transpile-only ./tools/postinstall.ts", "pre-commit": "yarn lint-staged", "start": "nx run website:start", "test": "nx run-many --target=test --all --parallel", @@ -86,6 +86,7 @@ "eslint-plugin-import": "^2.26.0", "eslint-plugin-jest": "^26.1.5", "eslint-plugin-simple-import-sort": "^8.0.0", + "execa": "5.1.1", "glob": "^8.0.1", "husky": "^8.0.1", "jest": "^29.0.3", diff --git a/tools/postinstall.ts b/tools/postinstall.ts new file mode 100644 index 000000000000..b222b290e681 --- /dev/null +++ b/tools/postinstall.ts @@ -0,0 +1,34 @@ +import * as execa from 'execa'; + +/** + * In certain circumstances we want to skip the below the steps and it may not always + * be possible to use --ignore-scripts (e.g. if another tool is what is invoking the + * install command, such as when nx migrate runs). We therefore use and env var for this. + */ + +if (process.env.SKIP_POSTINSTALL) { + console.log( + '\nSkipping postinstall script because $SKIP_POSTINSTALL is set...\n', + ); + // eslint-disable-next-line no-process-exit + process.exit(0); +} + +void (async function (): Promise { + // Apply patches to installed node_modules + await $`yarn patch-package`; + + // Install git hooks + await $`yarn husky install`; + + // // Build all the packages ready for use + await $`yarn build`; +})(); + +async function $(cmd: TemplateStringsArray): Promise { + const command = cmd.join(); + console.log(`\n$ ${command}`); + return execa.command(command, { + stdio: 'inherit', + }); +} diff --git a/yarn.lock b/yarn.lock index 3ca3e9af00c5..2598bd29b00e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7132,7 +7132,7 @@ events@^3.2.0: resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== -execa@^5.0.0: +execa@5.1.1, execa@^5.0.0: version "5.1.1" resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== From 42b33af256e5269feb214c7bb161079f770964fa Mon Sep 17 00:00:00 2001 From: Muhammad Hammad <33136628+mhnaeem@users.noreply.github.com> Date: Wed, 23 Nov 2022 18:40:20 -0500 Subject: [PATCH 06/18] fix(eslint-plugin): [array-type] --fix flag removes parentheses from type (#5997) --- .../eslint-plugin/src/rules/array-type.ts | 3 +- .../tests/rules/array-type.test.ts | 55 +++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/src/rules/array-type.ts b/packages/eslint-plugin/src/rules/array-type.ts index 92040d8106aa..f353207e7d5d 100644 --- a/packages/eslint-plugin/src/rules/array-type.ts +++ b/packages/eslint-plugin/src/rules/array-type.ts @@ -252,8 +252,7 @@ export default util.createRule({ } const type = typeParams[0]; - const typeParens = - !util.isParenthesized(type, sourceCode) && typeNeedsParentheses(type); + const typeParens = typeNeedsParentheses(type); const parentParens = readonlyPrefix && node.parent?.type === AST_NODE_TYPES.TSArrayType && diff --git a/packages/eslint-plugin/tests/rules/array-type.test.ts b/packages/eslint-plugin/tests/rules/array-type.test.ts index c32da51cc08a..04ab47d0b8a0 100644 --- a/packages/eslint-plugin/tests/rules/array-type.test.ts +++ b/packages/eslint-plugin/tests/rules/array-type.test.ts @@ -1982,6 +1982,61 @@ class Foo extends Bar implements Baz { } `, ); + testOutput( + 'array', + ` +interface WorkingArray { + outerProperty: Array< + { innerPropertyOne: string } & { innerPropertyTwo: string } + >; +} + +interface BrokenArray { + outerProperty: Array< + ({ innerPropertyOne: string } & { innerPropertyTwo: string }) + >; +} + `, + ` +interface WorkingArray { + outerProperty: ({ innerPropertyOne: string } & { innerPropertyTwo: string })[]; +} + +interface BrokenArray { + outerProperty: ({ innerPropertyOne: string } & { innerPropertyTwo: string })[]; +} + `, + ); + testOutput( + 'array', + ` +type WorkingArray = { + outerProperty: Array< + { innerPropertyOne: string } & { innerPropertyTwo: string } + >; +} + +type BrokenArray = { + outerProperty: Array< + ({ innerPropertyOne: string } & { innerPropertyTwo: string }) + >; +} + `, + ` +type WorkingArray = { + outerProperty: ({ innerPropertyOne: string } & { innerPropertyTwo: string })[]; +} + +type BrokenArray = { + outerProperty: ({ innerPropertyOne: string } & { innerPropertyTwo: string })[]; +} + `, + ); + testOutput( + 'array', + 'const a: Array<(string|number)>;', + 'const a: (string|number)[];', + ); testOutput( 'array-simple', 'let xx: Array> = [[1, 2], [3]];', From 1f19998e3ec6d592fc679a7490708e2e96816f4c Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 23 Nov 2022 19:20:42 -0500 Subject: [PATCH 07/18] fix(eslint-plugin): [keyword-spacing] prevent crash on no options (#6073) --- packages/eslint-plugin/src/rules/keyword-spacing.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/eslint-plugin/src/rules/keyword-spacing.ts b/packages/eslint-plugin/src/rules/keyword-spacing.ts index 6af42e5c2fb7..32fb2aaeb717 100644 --- a/packages/eslint-plugin/src/rules/keyword-spacing.ts +++ b/packages/eslint-plugin/src/rules/keyword-spacing.ts @@ -25,7 +25,7 @@ export default util.createRule({ }, defaultOptions: [{}], - create(context) { + create(context, [{ after }]) { const sourceCode = context.getSourceCode(); const baseRules = baseRule.create(context); return { @@ -58,7 +58,7 @@ export default util.createRule({ const punctuatorToken = sourceCode.getTokenAfter(typeToken)!; const spacesBetweenTypeAndPunctuator = punctuatorToken.range[0] - typeToken.range[1]; - if (context.options[0].after && spacesBetweenTypeAndPunctuator === 0) { + if (after && spacesBetweenTypeAndPunctuator === 0) { context.report({ loc: punctuatorToken.loc, messageId: 'expectedBefore', @@ -68,7 +68,7 @@ export default util.createRule({ }, }); } - if (!context.options[0].after && spacesBetweenTypeAndPunctuator > 0) { + if (!after && spacesBetweenTypeAndPunctuator > 0) { context.report({ loc: punctuatorToken.loc, messageId: 'unexpectedBefore', From 53671d30daa7a307b01492c1ccfcd87aa4348837 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Thu, 24 Nov 2022 13:27:01 +1030 Subject: [PATCH 08/18] chore: add action to enforce semantic-pr titles (#6075) --- .github/workflows/semantic-pr-titles.yml | 52 ++++++++++++++++++++++++ CONTRIBUTING.md | 2 + 2 files changed, 54 insertions(+) create mode 100644 .github/workflows/semantic-pr-titles.yml diff --git a/.github/workflows/semantic-pr-titles.yml b/.github/workflows/semantic-pr-titles.yml new file mode 100644 index 000000000000..24b6fb7c7ab9 --- /dev/null +++ b/.github/workflows/semantic-pr-titles.yml @@ -0,0 +1,52 @@ +name: Semantic PR Titles + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + main: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # keep this synchronized with the /CONTRIBUTING.md + types: | + docs + feat + fix + test + chore + # deps is used by renovate for its PRs + scopes: | + deps + ast-spec + eslint-plugin + eslint-plugin-internal + eslint-plugin-tslint + experimental-utils + parser + scope-manager + type-utils + types + typescript-estree + utils + visitor-keys + website + # we allow "cross package" PRs with no scope + requireScope: false + # ensure that the subject is lower-case first + # also allows "[rule-name] " prefix for eslint-plugin rule PRs + # https://regexr.com/733ed + subjectPattern: ^(\[[a-z\-]+\] )?[a-z].+[^\.]$ + subjectPatternError: | + The "subject" must start with a lower-case letter and must not + end with a full-stop. + For PRs that add or change ESLint-plugin rules, you should begin + the title with "[rule-name] " diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3c08116cdc9c..aaf07b243ee4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,6 +84,8 @@ Within the body of your PR, make sure you reference the issue that you have work Must be one of the following: + + - `docs` - if you only change documentation, and not shipped code - `feat` - for any new functionality additions - `fix` - for any bug fixes that don't add new functionality From 1302b30ecad9eb55aa9f1daa5068d9fb72c3688e Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Fri, 25 Nov 2022 01:51:36 +1030 Subject: [PATCH 09/18] fix(typescript-estree): stub out `ts.SatisfiesExpression` on old TS versions (#6076) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## PR Checklist - [x] Steps in [CONTRIBUTING.md](https://github.com/typescript-eslint/typescript-eslint/blob/main/CONTRIBUTING.md) were taken ## Overview Another thing we need to add to the "new syntax" contributor guide. This union is part of the API surface for the package, so we need to ensure we don't break the build on old TS versions by "stubbing" out the new AST node types. Also added version comments so it's easy to tell when we can remove them as we bump the minimum TS version Co-authored-by: bjz@Brads-MacBook-Pro.local <> --- packages/typescript-estree/src/ts-estree/ts-nodes.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/typescript-estree/src/ts-estree/ts-nodes.ts b/packages/typescript-estree/src/ts-estree/ts-nodes.ts index 873f98e5a152..0ba5414e1376 100644 --- a/packages/typescript-estree/src/ts-estree/ts-nodes.ts +++ b/packages/typescript-estree/src/ts-estree/ts-nodes.ts @@ -4,12 +4,18 @@ import type * as ts from 'typescript'; // Eg: https://github.com/typescript-eslint/typescript-eslint/issues/2388, https://github.com/typescript-eslint/typescript-eslint/issues/2784 declare module 'typescript' { /* eslint-disable @typescript-eslint/no-empty-interface */ + // added in TS 4.0 export interface NamedTupleMember extends ts.Node {} + // added in TS 4.1 export interface TemplateLiteralTypeNode extends ts.Node {} + // added in TS 4.3 export interface PrivateIdentifier extends ts.Node {} export interface ClassStaticBlockDeclaration extends ts.Node {} + // added in TS 4.5 export interface AssertClause extends ts.Node {} export interface AssertEntry extends ts.Node {} + // added in TS 4.9 + export interface SatisfiesExpression extends ts.Node {} /* eslint-enable @typescript-eslint/no-empty-interface */ } From ee62b0b18afb85fe901a48f816bda5802acc907a Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Thu, 24 Nov 2022 14:39:19 -0500 Subject: [PATCH 10/18] chore: use no-restricted-syntax to enforce created options in rules (#6074) * fix(eslint-plugin): [keyword-spacing] prevent crash on no options * chore: add internal lint rule to always prefer created options * All right base rules, you do you --- .eslintrc.js | 10 ++++++++++ packages/eslint-plugin/src/rules/brace-style.ts | 1 + packages/eslint-plugin/src/rules/no-unused-vars.ts | 4 +--- .../eslint-plugin/src/rules/object-curly-spacing.ts | 1 + .../src/rules/padding-line-between-statements.ts | 1 + .../eslint-plugin/src/rules/space-before-blocks.ts | 3 +-- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 6dfb0c353629..81f745d38247 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -264,6 +264,16 @@ module.exports = { // specifically for rules - default exports makes the tooling easier 'import/no-default-export': 'off', + + 'no-restricted-syntax': [ + 'error', + { + selector: + 'ExportDefaultDeclaration Property[key.name="create"] MemberExpression[object.name="context"][property.name="options"]', + message: + "Retrieve options from create's second parameter so that defaultOptions are applied.", + }, + ], }, }, // plugin rule tests diff --git a/packages/eslint-plugin/src/rules/brace-style.ts b/packages/eslint-plugin/src/rules/brace-style.ts index c4b052beaddb..43d4ba63c3cf 100644 --- a/packages/eslint-plugin/src/rules/brace-style.ts +++ b/packages/eslint-plugin/src/rules/brace-style.ts @@ -29,6 +29,7 @@ export default createRule({ defaultOptions: ['1tbs'], create(context) { const [style, { allowSingleLine } = { allowSingleLine: false }] = + // eslint-disable-next-line no-restricted-syntax -- Use raw options for extended rules. context.options; const isAllmanStyle = style === 'allman'; diff --git a/packages/eslint-plugin/src/rules/no-unused-vars.ts b/packages/eslint-plugin/src/rules/no-unused-vars.ts index 5fcde1986676..77da885048d7 100644 --- a/packages/eslint-plugin/src/rules/no-unused-vars.ts +++ b/packages/eslint-plugin/src/rules/no-unused-vars.ts @@ -84,7 +84,7 @@ export default util.createRule({ }, }, defaultOptions: [{}], - create(context) { + create(context, [firstOption]) { const filename = context.getFilename(); const sourceCode = context.getSourceCode(); const MODULE_DECL_CACHE = new Map(); @@ -97,8 +97,6 @@ export default util.createRule({ caughtErrors: 'none', }; - const [firstOption] = context.options; - if (firstOption) { if (typeof firstOption === 'string') { options.vars = firstOption; diff --git a/packages/eslint-plugin/src/rules/object-curly-spacing.ts b/packages/eslint-plugin/src/rules/object-curly-spacing.ts index 5c188bb2c07b..1c1c737c8425 100644 --- a/packages/eslint-plugin/src/rules/object-curly-spacing.ts +++ b/packages/eslint-plugin/src/rules/object-curly-spacing.ts @@ -31,6 +31,7 @@ export default createRule({ }, defaultOptions: ['never'], create(context) { + // eslint-disable-next-line no-restricted-syntax -- Use raw options for extended rules. const [firstOption, secondOption] = context.options; const spaced = firstOption === 'always'; const sourceCode = context.getSourceCode(); diff --git a/packages/eslint-plugin/src/rules/padding-line-between-statements.ts b/packages/eslint-plugin/src/rules/padding-line-between-statements.ts index a3c354ea737b..f9b97096afc8 100644 --- a/packages/eslint-plugin/src/rules/padding-line-between-statements.ts +++ b/packages/eslint-plugin/src/rules/padding-line-between-statements.ts @@ -634,6 +634,7 @@ export default util.createRule({ defaultOptions: [], create(context) { const sourceCode = context.getSourceCode(); + // eslint-disable-next-line no-restricted-syntax -- We need all raw options. const configureList = context.options || []; type Scope = null | { diff --git a/packages/eslint-plugin/src/rules/space-before-blocks.ts b/packages/eslint-plugin/src/rules/space-before-blocks.ts index 569be350cd74..5f16929aa52e 100644 --- a/packages/eslint-plugin/src/rules/space-before-blocks.ts +++ b/packages/eslint-plugin/src/rules/space-before-blocks.ts @@ -29,9 +29,8 @@ export default util.createRule({ }, }, defaultOptions: ['always'], - create(context) { + create(context, [config]) { const rules = baseRule.create(context); - const config = context.options[0]; const sourceCode = context.getSourceCode(); let requireSpace = true; From f02761af19848a84b8d1832bd00fd6c95d38fa0c Mon Sep 17 00:00:00 2001 From: Sviatoslav Zaytsev Date: Fri, 25 Nov 2022 04:09:46 +0300 Subject: [PATCH 11/18] fix(eslint-plugin): [member-ordering] support private fields (#5859) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Святослав Зайцев --- .../docs/rules/member-ordering.md | 50 +++- .../src/rules/member-ordering.ts | 102 ++++--- .../tests/rules/member-ordering.test.ts | 249 +++++++++++++++++- 3 files changed, 351 insertions(+), 50 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/member-ordering.md b/packages/eslint-plugin/docs/rules/member-ordering.md index 7adde7ba9a63..bfab82652607 100644 --- a/packages/eslint-plugin/docs/rules/member-ordering.md +++ b/packages/eslint-plugin/docs/rules/member-ordering.md @@ -54,7 +54,7 @@ The `OrderConfig` settings for each kind of construct may configure sorting on o You can define many different groups based on different attributes of members. The supported member attributes are, in order: -- **Accessibility** (`'public' | 'protected' | 'private'`) +- **Accessibility** (`'public' | 'protected' | 'private' | '#private'`) - **Decoration** (`'decorated'`): Whether the member has an explicit accessibility decorator - **Kind** (`'call-signature' | 'constructor' | 'field' | 'get' | 'method' | 'set' | 'signature'`) @@ -81,11 +81,13 @@ The default configuration looks as follows: "default": [ // Index signature "signature", + "call-signature", // Fields "public-static-field", "protected-static-field", "private-static-field", + "#private-static-field", "public-decorated-field", "protected-decorated-field", @@ -94,14 +96,15 @@ The default configuration looks as follows: "public-instance-field", "protected-instance-field", "private-instance-field", + "#private-instance-field", "public-abstract-field", "protected-abstract-field", - "private-abstract-field", "public-field", "protected-field", "private-field", + "#private-field", "static-field", "instance-field", @@ -125,6 +128,7 @@ The default configuration looks as follows: "public-static-get", "protected-static-get", "private-static-get", + "#private-static-get", "public-decorated-get", "protected-decorated-get", @@ -133,14 +137,15 @@ The default configuration looks as follows: "public-instance-get", "protected-instance-get", "private-instance-get", + "#private-instance-get", "public-abstract-get", "protected-abstract-get", - "private-abstract-get", "public-get", "protected-get", "private-get", + "#private-get", "static-get", "instance-get", @@ -154,6 +159,7 @@ The default configuration looks as follows: "public-static-set", "protected-static-set", "private-static-set", + "#private-static-set", "public-decorated-set", "protected-decorated-set", @@ -162,14 +168,15 @@ The default configuration looks as follows: "public-instance-set", "protected-instance-set", "private-instance-set", + "#private-instance-set", "public-abstract-set", "protected-abstract-set", - "private-abstract-set", "public-set", "protected-set", "private-set", + "#private-set", "static-set", "instance-set", @@ -183,6 +190,7 @@ The default configuration looks as follows: "public-static-method", "protected-static-method", "private-static-method", + "#private-static-method", "public-decorated-method", "protected-decorated-method", @@ -191,14 +199,15 @@ The default configuration looks as follows: "public-instance-method", "protected-instance-method", "private-instance-method", + "#private-instance-method", "public-abstract-method", "protected-abstract-method", - "private-abstract-method", "public-method", "protected-method", "private-method", + "#private-method", "static-method", "instance-method", @@ -918,15 +927,32 @@ The most explicit and granular form is the following: "public-static-field", "protected-static-field", "private-static-field", + "#private-static-field", + "public-decorated-field", "protected-decorated-field", "private-decorated-field", + "public-instance-field", "protected-instance-field", "private-instance-field", + "#private-instance-field", + "public-abstract-field", "protected-abstract-field", - "private-abstract-field", + + "public-field", + "protected-field", + "private-field", + "#private-field", + + "static-field", + "instance-field", + "abstract-field", + + "decorated-field", + + "field", // Static initialization "static-initialization", @@ -940,6 +966,7 @@ The most explicit and granular form is the following: "public-static-get", "protected-static-get", "private-static-get", + "#private-static-get", "public-decorated-get", "protected-decorated-get", @@ -948,14 +975,15 @@ The most explicit and granular form is the following: "public-instance-get", "protected-instance-get", "private-instance-get", + "#private-instance-get", "public-abstract-get", "protected-abstract-get", - "private-abstract-get", "public-get", "protected-get", "private-get", + "#private-get", "static-get", "instance-get", @@ -969,6 +997,7 @@ The most explicit and granular form is the following: "public-static-set", "protected-static-set", "private-static-set", + "#private-static-set", "public-decorated-set", "protected-decorated-set", @@ -977,10 +1006,10 @@ The most explicit and granular form is the following: "public-instance-set", "protected-instance-set", "private-instance-set", + "#private-instance-set", "public-abstract-set", "protected-abstract-set", - "private-abstract-set", "public-set", "protected-set", @@ -998,15 +1027,16 @@ The most explicit and granular form is the following: "public-static-method", "protected-static-method", "private-static-method", + "#private-static-method", "public-decorated-method", "protected-decorated-method", "private-decorated-method", "public-instance-method", "protected-instance-method", "private-instance-method", + "#private-instance-method", "public-abstract-method", - "protected-abstract-method", - "private-abstract-method" + "protected-abstract-method" ] ``` diff --git a/packages/eslint-plugin/src/rules/member-ordering.ts b/packages/eslint-plugin/src/rules/member-ordering.ts index 3892c989bc9a..c92af2650ceb 100644 --- a/packages/eslint-plugin/src/rules/member-ordering.ts +++ b/packages/eslint-plugin/src/rules/member-ordering.ts @@ -22,15 +22,17 @@ type NonCallableMemberKind = Exclude; type MemberScope = 'static' | 'instance' | 'abstract'; +type Accessibility = TSESTree.Accessibility | '#private'; + type BaseMemberType = | MemberKind - | `${TSESTree.Accessibility}-${Exclude< + | `${Accessibility}-${Exclude< MemberKind, 'signature' | 'static-initialization' >}` - | `${TSESTree.Accessibility}-decorated-${DecoratedMemberKind}` + | `${Accessibility}-decorated-${DecoratedMemberKind}` | `decorated-${DecoratedMemberKind}` - | `${TSESTree.Accessibility}-${MemberScope}-${NonCallableMemberKind}` + | `${Accessibility}-${MemberScope}-${NonCallableMemberKind}` | `${MemberScope}-${NonCallableMemberKind}`; type MemberType = BaseMemberType | BaseMemberType[]; @@ -112,6 +114,7 @@ export const defaultOrder: MemberType[] = [ 'public-static-field', 'protected-static-field', 'private-static-field', + '#private-static-field', 'public-decorated-field', 'protected-decorated-field', @@ -120,14 +123,15 @@ export const defaultOrder: MemberType[] = [ 'public-instance-field', 'protected-instance-field', 'private-instance-field', + '#private-instance-field', 'public-abstract-field', 'protected-abstract-field', - 'private-abstract-field', 'public-field', 'protected-field', 'private-field', + '#private-field', 'static-field', 'instance-field', @@ -151,6 +155,7 @@ export const defaultOrder: MemberType[] = [ 'public-static-get', 'protected-static-get', 'private-static-get', + '#private-static-get', 'public-decorated-get', 'protected-decorated-get', @@ -159,14 +164,15 @@ export const defaultOrder: MemberType[] = [ 'public-instance-get', 'protected-instance-get', 'private-instance-get', + '#private-instance-get', 'public-abstract-get', 'protected-abstract-get', - 'private-abstract-get', 'public-get', 'protected-get', 'private-get', + '#private-get', 'static-get', 'instance-get', @@ -180,6 +186,7 @@ export const defaultOrder: MemberType[] = [ 'public-static-set', 'protected-static-set', 'private-static-set', + '#private-static-set', 'public-decorated-set', 'protected-decorated-set', @@ -188,14 +195,15 @@ export const defaultOrder: MemberType[] = [ 'public-instance-set', 'protected-instance-set', 'private-instance-set', + '#private-instance-set', 'public-abstract-set', 'protected-abstract-set', - 'private-abstract-set', 'public-set', 'protected-set', 'private-set', + '#private-set', 'static-set', 'instance-set', @@ -209,6 +217,7 @@ export const defaultOrder: MemberType[] = [ 'public-static-method', 'protected-static-method', 'private-static-method', + '#private-static-method', 'public-decorated-method', 'protected-decorated-method', @@ -217,14 +226,15 @@ export const defaultOrder: MemberType[] = [ 'public-instance-method', 'protected-instance-method', 'private-instance-method', + '#private-instance-method', 'public-abstract-method', 'protected-abstract-method', - 'private-abstract-method', 'public-method', 'protected-method', 'private-method', + '#private-method', 'static-method', 'instance-method', @@ -250,30 +260,49 @@ const allMemberTypes = Array.from( ).reduce>((all, type) => { all.add(type); - (['public', 'protected', 'private'] as const).forEach(accessibility => { - if (type !== 'signature' && type !== 'static-initialization') { - all.add(`${accessibility}-${type}`); // e.g. `public-field` - } + (['public', 'protected', 'private', '#private'] as const).forEach( + accessibility => { + if ( + type !== 'signature' && + type !== 'static-initialization' && + type !== 'call-signature' && + !(type === 'constructor' && accessibility === '#private') + ) { + all.add(`${accessibility}-${type}`); // e.g. `public-field` + } - // Only class instance fields, methods, get and set can have decorators attached to them - if ( - type === 'field' || - type === 'method' || - type === 'get' || - type === 'set' - ) { - all.add(`${accessibility}-decorated-${type}`); - all.add(`decorated-${type}`); - } + // Only class instance fields, methods, get and set can have decorators attached to them + if ( + accessibility !== '#private' && + (type === 'field' || + type === 'method' || + type === 'get' || + type === 'set') + ) { + all.add(`${accessibility}-decorated-${type}`); + all.add(`decorated-${type}`); + } - if (type !== 'constructor' && type !== 'signature') { - // There is no `static-constructor` or `instance-constructor` or `abstract-constructor` - (['static', 'instance', 'abstract'] as const).forEach(scope => { - all.add(`${scope}-${type}`); - all.add(`${accessibility}-${scope}-${type}`); - }); - } - }); + if ( + type !== 'constructor' && + type !== 'signature' && + type !== 'call-signature' + ) { + // There is no `static-constructor` or `instance-constructor` or `abstract-constructor` + if (accessibility === '#private' || accessibility === 'private') { + (['static', 'instance'] as const).forEach(scope => { + all.add(`${scope}-${type}`); + all.add(`${accessibility}-${scope}-${type}`); + }); + } else { + (['static', 'instance', 'abstract'] as const).forEach(scope => { + all.add(`${scope}-${type}`); + all.add(`${accessibility}-${scope}-${type}`); + }); + } + } + }, + ); return all; }, new Set()), @@ -407,6 +436,16 @@ function getRankOrder( return rank; } +function getAccessibility(node: Member): Accessibility { + if ('accessibility' in node && node.accessibility) { + return node.accessibility; + } + if ('key' in node && node.key?.type === AST_NODE_TYPES.PrivateIdentifier) { + return '#private'; + } + return 'public'; +} + /** * Gets the rank of the node given the order. * @param node the node to be evaluated. @@ -435,10 +474,7 @@ function getRank( : abstract ? 'abstract' : 'instance'; - const accessibility = - 'accessibility' in node && node.accessibility - ? node.accessibility - : 'public'; + const accessibility = getAccessibility(node); // Collect all existing member groups that apply to this node... // (e.g. 'public-instance-field', 'instance-field', 'public-field', 'constructor' etc.) diff --git a/packages/eslint-plugin/tests/rules/member-ordering.test.ts b/packages/eslint-plugin/tests/rules/member-ordering.test.ts index cfff36914760..3305bebfa8cd 100644 --- a/packages/eslint-plugin/tests/rules/member-ordering.test.ts +++ b/packages/eslint-plugin/tests/rules/member-ordering.test.ts @@ -425,16 +425,20 @@ class Foo { public static A: string; protected static B: string = ''; private static C: string = ''; + static #C: string = ''; public D: string = ''; protected E: string = ''; private F: string = ''; + #F: string = ''; constructor() {} public static G() {} protected static H() {} private static I() {} + static #I() {} public J() {} protected K() {} private L() {} + #L() {} } `, { @@ -444,16 +448,20 @@ class Foo { public static A: string; protected static B: string = ''; private static C: string = ''; + static #C: string = ''; public D: string = ''; protected E: string = ''; private F: string = ''; + #F: string = ''; constructor() {} public static G() {} protected static H() {} private static I() {} + static #I() {} public J() {} protected K() {} private L() {} + #L() {} } `, options: [{ default: 'never' }], @@ -465,16 +473,20 @@ class Foo { public static A: string; protected static B: string = ''; private static C: string = ''; + static #C: string = ''; public D: string = ''; protected E: string = ''; private F: string = ''; + #F: string = ''; constructor() {} public static G() {} protected static H() {} private static I() {} + static #I() {} public J() {} protected K() {} private L() {} + #L() {} } `, options: [{ default: ['signature', 'field', 'constructor', 'method'] }], @@ -487,15 +499,19 @@ class Foo { public static A: string; protected static B: string = ''; private static C: string = ''; + static #C: string = ''; public D: string = ''; protected E: string = ''; private F: string = ''; + #F: string = ''; public static G() {} protected static H() {} private static I() {} + static #I() {} public J() {} protected K() {} private L() {} + #L() {} } `, options: [{ default: ['field', 'method'] }], @@ -527,16 +543,20 @@ class Foo { public static G() {} protected static H() {} private static I() {} + static #I() {} public J() {} protected K() {} private L() {} + #L() {} [Z: string]: any; public static A: string; protected static B: string = ''; private static C: string = ''; + static #C: string = ''; public D: string = ''; protected E: string = ''; private F: string = ''; + #F: string = ''; constructor() {} } `, @@ -619,6 +639,8 @@ class Foo { public static A: string; private static C: string = ''; private F: string = ''; + static #M: string = ''; + #N: string = ''; protected static B: string = ''; protected E: string = ''; } @@ -631,6 +653,7 @@ class Foo { 'constructor', 'public-field', 'private-field', + '#private-field', 'protected-field', ], }, @@ -653,6 +676,7 @@ class Foo { protected E: string = ''; private static C: string = ''; private F: string = ''; + #M: string = ''; } `, options: [ @@ -667,6 +691,7 @@ class Foo { 'public-field', 'protected-field', 'private-field', + '#private-field', ], }, ], @@ -681,12 +706,16 @@ class Foo { constructor() {} protected K() {} private L() {} + #P() {} protected static H() {} private static I() {} + static #O() {} protected static B: string = ''; private static C: string = ''; + static #N: string = ''; protected E: string = ''; private F: string = ''; + #M: string = ''; [Z: string]: any; } `, @@ -710,15 +739,19 @@ class Foo { public static G() {} protected static H() {} private static I() {} + static #I() {} protected K() {} private L() {} + #L() {} constructor() {} [Z: string]: any; public static A: string; private F: string = ''; + #F: string = ''; protected static B: string = ''; public D: string = ''; private static C: string = ''; + static #C: string = ''; protected E: string = ''; } `, @@ -727,9 +760,10 @@ class Foo { classes: [ 'public-method', 'protected-static-method', - 'private-static-method', + '#private-static-method', 'protected-instance-method', 'private-instance-method', + '#private-instance-method', 'constructor', 'signature', 'field', @@ -764,6 +798,31 @@ class Foo { }, { code: ` +class Foo { + private L() {} + private static I() {} + static #H() {} + static #B: string = ''; + public static G() {} + public J() {} + #K() {} + private static C: string = ''; + private F: string = ''; + #E: string = ''; + public static A: string; + public D: string = ''; + constructor() {} + [Z: string]: any; +} + `, + options: [ + { + classes: ['private-instance-method', 'protected-static-field'], + }, + ], + }, + { + code: ` class Foo { private L() {} private static I() {} @@ -1535,6 +1594,60 @@ class Foo { }, ], }, + { + name: 'with private identifier', + code: ` +// no accessibility === public +class Foo { + imPublic() {} + #imPrivate() {} +} + `, + options: [ + { + default: { + memberTypes: ['public-method', '#private-method'], + order: 'alphabetically-case-insensitive', + }, + }, + ], + }, + { + name: 'private and #private member order', + code: ` +// no accessibility === public +class Foo { + private imPrivate() {} + #imPrivate() {} +} + `, + options: [ + { + default: { + memberTypes: ['private-method', '#private-method'], + order: 'alphabetically-case-insensitive', + }, + }, + ], + }, + { + name: '#private and private member order', + code: ` +// no accessibility === public +class Foo { + #imPrivate() {} + private imPrivate() {} +} + `, + options: [ + { + default: { + memberTypes: ['#private-method', 'private-method'], + order: 'alphabetically-case-insensitive', + }, + }, + ], + }, ], invalid: [ { @@ -2356,16 +2469,20 @@ class Foo { public static A: string = ''; protected static B: string = ''; private static C: string = ''; + static #C: string = ''; public D: string = ''; protected E: string = ''; private F: string = ''; + #F: string = ''; constructor() {} public J() {} protected K() {} private L() {} + #L() {} public static G() {} protected static H() {} private static I() {} + static #I() {} } `, errors: [ @@ -2375,7 +2492,7 @@ class Foo { name: 'G', rank: 'public instance method', }, - line: 14, + line: 17, column: 3, }, { @@ -2384,7 +2501,7 @@ class Foo { name: 'H', rank: 'public instance method', }, - line: 15, + line: 18, column: 3, }, { @@ -2393,7 +2510,16 @@ class Foo { name: 'I', rank: 'public instance method', }, - line: 16, + line: 19, + column: 3, + }, + { + messageId: 'incorrectGroupOrder', + data: { + name: 'I', + rank: 'public instance method', + }, + line: 20, column: 3, }, ], @@ -2405,15 +2531,19 @@ class Foo { public static A: string = ''; protected static B: string = ''; private static C: string = ''; + static #C: string = ''; public D: string = ''; protected E: string = ''; private F: string = ''; + #F: string = ''; public J() {} protected K() {} private L() {} + #L() {} public static G() {} protected static H() {} private static I() {} + static #I() {} [Z: string]: any; } `, @@ -2449,7 +2579,7 @@ class Foo { { messageId: 'incorrectGroupOrder', data: { - name: 'D', + name: 'C', rank: 'constructor', }, line: 7, @@ -2458,7 +2588,7 @@ class Foo { { messageId: 'incorrectGroupOrder', data: { - name: 'E', + name: 'D', rank: 'constructor', }, line: 8, @@ -2467,12 +2597,30 @@ class Foo { { messageId: 'incorrectGroupOrder', data: { - name: 'F', + name: 'E', rank: 'constructor', }, line: 9, column: 3, }, + { + messageId: 'incorrectGroupOrder', + data: { + name: 'F', + rank: 'constructor', + }, + line: 10, + column: 3, + }, + { + messageId: 'incorrectGroupOrder', + data: { + name: 'F', + rank: 'constructor', + }, + line: 11, + column: 3, + }, ], }, { @@ -4175,6 +4323,93 @@ class Foo { }, ], }, + { + name: 'with private identifier', + code: ` +// no accessibility === public +class Foo { + #imPrivate() {} + imPublic() {} +} + `, + options: [ + { + default: { + memberTypes: ['public-method', '#private-method'], + order: 'alphabetically-case-insensitive', + }, + }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'imPublic', + rank: '#private method', + }, + line: 5, + column: 3, + }, + ], + }, + { + name: 'private and #private member order', + code: ` +// no accessibility === public +class Foo { + #imPrivate() {} + private imPrivate() {} +} + `, + options: [ + { + default: { + memberTypes: ['private-method', '#private-method'], + order: 'alphabetically-case-insensitive', + }, + }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'imPrivate', + rank: '#private method', + }, + line: 5, + column: 3, + }, + ], + }, + { + name: '#private and private member order', + code: ` +// no accessibility === public +class Foo { + private imPrivate() {} + #imPrivate() {} +} + `, + options: [ + { + default: { + memberTypes: ['#private-method', 'private-method'], + order: 'alphabetically-case-insensitive', + }, + }, + ], + errors: [ + { + messageId: 'incorrectGroupOrder', + data: { + name: 'imPrivate', + rank: 'private method', + }, + line: 5, + column: 3, + }, + ], + }, ], }; From 87a27367acde92c7ecddf24a9a201c7d9dc939ec Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 25 Nov 2022 01:35:23 -0500 Subject: [PATCH 12/18] test(website): add Playwright test for Playground linting (#6080) --- packages/website/playwright.config.ts | 1 + .../src/components/config/ConfigEditor.tsx | 8 ++- packages/website/tests/playground.spec.ts | 65 +++++++++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 packages/website/tests/playground.spec.ts diff --git a/packages/website/playwright.config.ts b/packages/website/playwright.config.ts index ba1f9df5617a..ad85c7391d99 100644 --- a/packages/website/playwright.config.ts +++ b/packages/website/playwright.config.ts @@ -22,6 +22,7 @@ const config: PlaywrightTestConfig = { webServer: { command: 'yarn start', port: 3000, + reuseExistingServer: !process.env.CI, }, workers: process.env.CI ? 1 : undefined, }; diff --git a/packages/website/src/components/config/ConfigEditor.tsx b/packages/website/src/components/config/ConfigEditor.tsx index 1d6e9346e0b1..0d4915d281b6 100644 --- a/packages/website/src/components/config/ConfigEditor.tsx +++ b/packages/website/src/components/config/ConfigEditor.tsx @@ -129,8 +129,12 @@ function ConfigEditor(props: ConfigEditorProps): JSX.Element {