Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix tsconfig-less check errors, fix
@types/eslint
incompatibil…
…ities, add tests (#8460)
- Loading branch information
1 parent
998ef9c
commit 18c3216
Showing
32 changed files
with
565 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/integration-tests/fixtures/flat-config-types/dirname.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// a hacky way to allow __dirname within ESM | ||
module.exports = __dirname; |
57 changes: 57 additions & 0 deletions
57
packages/integration-tests/fixtures/flat-config-types/eslint.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// @ts-check | ||
|
||
import { FlatCompat } from '@eslint/eslintrc'; | ||
import eslint from '@eslint/js'; | ||
import stylisticPlugin from '@stylistic/eslint-plugin'; | ||
import deprecationPlugin from 'eslint-plugin-deprecation'; | ||
import jestPlugin from 'eslint-plugin-jest'; | ||
import tseslint from 'typescript-eslint'; | ||
|
||
import __dirname from './dirname.cjs'; | ||
|
||
const compat = new FlatCompat({ | ||
baseDirectory: __dirname, | ||
recommendedConfig: {}, | ||
allConfig: {}, | ||
}); | ||
|
||
// this config is run through eslint as part of the integration test | ||
// so it needs to be a correct config | ||
export default tseslint.config( | ||
{ | ||
plugins: { | ||
['@typescript-eslint']: tseslint.plugin, | ||
['deprecation']: deprecationPlugin, | ||
['jest']: jestPlugin, | ||
}, | ||
}, | ||
eslint.configs.recommended, | ||
...tseslint.configs.recommended, | ||
stylisticPlugin.configs['recommended-flat'], | ||
); | ||
|
||
// these are just tests for the types and are not seen by eslint so they can be whatever | ||
tseslint.config({ | ||
plugins: { | ||
['@stylistic']: stylisticPlugin, | ||
['@typescript-eslint']: tseslint.plugin, | ||
['deprecation']: deprecationPlugin, | ||
['jest']: jestPlugin, | ||
}, | ||
}); | ||
tseslint.config( | ||
eslint.configs.recommended, | ||
...tseslint.configs.recommended, | ||
stylisticPlugin.configs['recommended-flat'], | ||
); | ||
tseslint.config( | ||
// @ts-expect-error | ||
compat.config(deprecationPlugin.configs.recommended), | ||
...compat.config(jestPlugin.configs.recommended), | ||
); | ||
tseslint.config( | ||
// @ts-expect-error | ||
deprecationPlugin.configs.recommended, | ||
// this should error but doesn't because there are no types exported from the jest plugin | ||
jestPlugin.configs.recommended, | ||
); |
14 changes: 14 additions & 0 deletions
14
packages/integration-tests/fixtures/flat-config-types/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"type": "module", | ||
"devDependencies": { | ||
"@types/eslint__eslintrc": "latest", | ||
"@eslint/eslintrc": "latest", | ||
"@types/eslint__js": "latest", | ||
"@eslint/js": "latest", | ||
"@types/eslint": "latest", | ||
"eslint": "latest", | ||
"@stylistic/eslint-plugin": "latest", | ||
"eslint-plugin-deprecation": "latest", | ||
"eslint-plugin-jest": "latest" | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/integration-tests/tests/__snapshots__/eslint-v8.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
packages/integration-tests/tests/__snapshots__/flat-config-types.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`flat-config-types eslint should work successfully 1`] = ` | ||
[ | ||
{ | ||
"errorCount": 2, | ||
"fatalErrorCount": 0, | ||
"filePath": "<root>/eslint.config.js", | ||
"fixableErrorCount": 0, | ||
"fixableWarningCount": 0, | ||
"messages": [ | ||
{ | ||
"column": 3, | ||
"endColumn": 22, | ||
"endLine": 48, | ||
"line": 48, | ||
"message": "Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 3 characters or longer.", | ||
"messageId": "tsDirectiveCommentRequiresDescription", | ||
"nodeType": "Line", | ||
"ruleId": "@typescript-eslint/ban-ts-comment", | ||
"severity": 2, | ||
}, | ||
{ | ||
"column": 3, | ||
"endColumn": 22, | ||
"endLine": 53, | ||
"line": 53, | ||
"message": "Include a description after the "@ts-expect-error" directive to explain why the @ts-expect-error is necessary. The description must be 3 characters or longer.", | ||
"messageId": "tsDirectiveCommentRequiresDescription", | ||
"nodeType": "Line", | ||
"ruleId": "@typescript-eslint/ban-ts-comment", | ||
"severity": 2, | ||
}, | ||
], | ||
"output": "// @ts-check | ||
import { FlatCompat } from '@eslint/eslintrc' | ||
import eslint from '@eslint/js' | ||
import stylisticPlugin from '@stylistic/eslint-plugin' | ||
import deprecationPlugin from 'eslint-plugin-deprecation' | ||
import jestPlugin from 'eslint-plugin-jest' | ||
import tseslint from 'typescript-eslint' | ||
import __dirname from './dirname.cjs' | ||
const compat = new FlatCompat({ | ||
baseDirectory: __dirname, | ||
recommendedConfig: {}, | ||
allConfig: {}, | ||
}) | ||
// this config is run through eslint as part of the integration test | ||
// so it needs to be a correct config | ||
export default tseslint.config( | ||
{ | ||
plugins: { | ||
['@typescript-eslint']: tseslint.plugin, | ||
['deprecation']: deprecationPlugin, | ||
['jest']: jestPlugin, | ||
}, | ||
}, | ||
eslint.configs.recommended, | ||
...tseslint.configs.recommended, | ||
stylisticPlugin.configs['recommended-flat'], | ||
) | ||
// these are just tests for the types and are not seen by eslint so they can be whatever | ||
tseslint.config({ | ||
plugins: { | ||
['@stylistic']: stylisticPlugin, | ||
['@typescript-eslint']: tseslint.plugin, | ||
['deprecation']: deprecationPlugin, | ||
['jest']: jestPlugin, | ||
}, | ||
}) | ||
tseslint.config( | ||
eslint.configs.recommended, | ||
...tseslint.configs.recommended, | ||
stylisticPlugin.configs['recommended-flat'], | ||
) | ||
tseslint.config( | ||
// @ts-expect-error | ||
compat.config(deprecationPlugin.configs.recommended), | ||
...compat.config(jestPlugin.configs.recommended), | ||
) | ||
tseslint.config( | ||
// @ts-expect-error | ||
deprecationPlugin.configs.recommended, | ||
// this should error but doesn't because there are no types exported from the jest plugin | ||
jestPlugin.configs.recommended, | ||
) | ||
", | ||
"suppressedMessages": [], | ||
"usedDeprecatedRules": [ | ||
{ | ||
"replacedBy": [], | ||
"ruleId": "no-extra-semi", | ||
}, | ||
{ | ||
"replacedBy": [], | ||
"ruleId": "no-mixed-spaces-and-tabs", | ||
}, | ||
], | ||
"warningCount": 0, | ||
}, | ||
] | ||
`; |
2 changes: 1 addition & 1 deletion
2
packages/integration-tests/tests/__snapshots__/markdown.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/integration-tests/tests/__snapshots__/recommended-does-not-require-program.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...integration-tests/tests/__snapshots__/typescript-and-tslint-plugins-together.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/integration-tests/tests/__snapshots__/vue-jsx.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/integration-tests/tests/__snapshots__/vue-sfc.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { integrationTest } from '../tools/integration-test-base'; | ||
import { eslintIntegrationTest } from '../tools/integration-test-base'; | ||
|
||
integrationTest(__filename, '*.ts'); | ||
eslintIntegrationTest(__filename, '*.ts'); |
37 changes: 37 additions & 0 deletions
37
packages/integration-tests/tests/flat-config-types.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { | ||
eslintIntegrationTest, | ||
typescriptIntegrationTest, | ||
} from '../tools/integration-test-base'; | ||
|
||
typescriptIntegrationTest( | ||
__filename, | ||
['--allowJs', '--esModuleInterop', 'eslint.config.js'], | ||
out => { | ||
const lines = out | ||
.split('\n') | ||
.filter( | ||
line => | ||
// error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher. | ||
// this is fine for us to ignore in this context | ||
!line.includes('error TS18028'), | ||
) | ||
.join('\n'); | ||
|
||
// The stylistic type errors: https://github.com/eslint-stylistic/eslint-stylistic/issues/276 | ||
expect(lines).toMatchInlineSnapshot(` | ||
"node_modules/@stylistic/eslint-plugin-plus/dts/index.d.ts(7,46): error TS2694: Namespace '"/<tmp_folder>/node_modules/@types/eslint/index".ESLint' has no exported member 'RuleModule'. | ||
node_modules/@stylistic/eslint-plugin/dist/dts/rule-options.d.ts(6,11): error TS2320: Interface 'UnprefixedRuleOptions' cannot simultaneously extend types 'UnprefixedRuleOptions' and 'UnprefixedRuleOptions'. | ||
Named property ''comma-dangle'' of types 'UnprefixedRuleOptions' and 'UnprefixedRuleOptions' are not identical. | ||
node_modules/@stylistic/eslint-plugin/dist/dts/rule-options.d.ts(6,11): error TS2320: Interface 'UnprefixedRuleOptions' cannot simultaneously extend types 'UnprefixedRuleOptions' and 'UnprefixedRuleOptions'. | ||
Named property ''keyword-spacing'' of types 'UnprefixedRuleOptions' and 'UnprefixedRuleOptions' are not identical. | ||
node_modules/@stylistic/eslint-plugin/dist/dts/rule-options.d.ts(6,11): error TS2320: Interface 'UnprefixedRuleOptions' cannot simultaneously extend types 'UnprefixedRuleOptions' and 'UnprefixedRuleOptions'. | ||
Named property ''lines-around-comment'' of types 'UnprefixedRuleOptions' and 'UnprefixedRuleOptions' are not identical. | ||
node_modules/@stylistic/eslint-plugin/dist/dts/rule-options.d.ts(6,11): error TS2320: Interface 'UnprefixedRuleOptions' cannot simultaneously extend types 'UnprefixedRuleOptions' and 'UnprefixedRuleOptions'. | ||
Named property ''lines-between-class-members'' of types 'UnprefixedRuleOptions' and 'UnprefixedRuleOptions' are not identical. | ||
node_modules/@stylistic/eslint-plugin/dist/dts/rule-options.d.ts(6,11): error TS2320: Interface 'UnprefixedRuleOptions' cannot simultaneously extend types 'UnprefixedRuleOptions' and 'UnprefixedRuleOptions'. | ||
Named property ''padding-line-between-statements'' of types 'UnprefixedRuleOptions' and 'UnprefixedRuleOptions' are not identical. | ||
" | ||
`); | ||
}, | ||
); | ||
eslintIntegrationTest(__filename, 'eslint.config.js', true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { integrationTest } from '../tools/integration-test-base'; | ||
import { eslintIntegrationTest } from '../tools/integration-test-base'; | ||
|
||
integrationTest(__filename, '*.md'); | ||
eslintIntegrationTest(__filename, '*.md'); |
4 changes: 2 additions & 2 deletions
4
packages/integration-tests/tests/recommended-does-not-require-program.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { integrationTest } from '../tools/integration-test-base'; | ||
import { eslintIntegrationTest } from '../tools/integration-test-base'; | ||
|
||
integrationTest(__filename, '*.ts'); | ||
eslintIntegrationTest(__filename, '*.ts'); |
4 changes: 2 additions & 2 deletions
4
packages/integration-tests/tests/typescript-and-tslint-plugins-together.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { integrationTest } from '../tools/integration-test-base'; | ||
import { eslintIntegrationTest } from '../tools/integration-test-base'; | ||
|
||
integrationTest(__filename, '*.ts'); | ||
eslintIntegrationTest(__filename, '*.ts'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { integrationTest } from '../tools/integration-test-base'; | ||
import { eslintIntegrationTest } from '../tools/integration-test-base'; | ||
|
||
integrationTest(__filename, '*.vue'); | ||
eslintIntegrationTest(__filename, '*.vue'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { integrationTest } from '../tools/integration-test-base'; | ||
import { eslintIntegrationTest } from '../tools/integration-test-base'; | ||
|
||
integrationTest(__filename, '*.vue'); | ||
eslintIntegrationTest(__filename, '*.vue'); |
Oops, something went wrong.