Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
test: add integration test against @types/eslint v9#9622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
5 changes: 1 addition & 4 deletions...s/fixtures/flat-config-types/package.json → ...nfig-types-@types__eslint-v8/package.json
This file contains hidden or 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 deletionspackages/integration-tests/fixtures/flat-config-types-@types__eslint-v9/dirname.cjs
This file contains hidden or 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; |
67 changes: 67 additions & 0 deletionspackages/integration-tests/fixtures/flat-config-types-@types__eslint-v9/eslint.config.js
This file contains hidden or 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,67 @@ | ||
// @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( | ||
{ | ||
// config with just ignores is the replacement for `.eslintignore` | ||
ignores: ['**/build/**', '**/dist/**', 'src/some/file/to/ignore.ts'], | ||
}, | ||
{ | ||
plugins: { | ||
['@typescript-eslint']: tseslint.plugin, | ||
['deprecation']: deprecationPlugin, | ||
['jest']: jestPlugin, | ||
}, | ||
}, | ||
eslint.configs.recommended, | ||
...tseslint.configs.recommended, | ||
stylisticPlugin.configs['recommended-flat'], | ||
); | ||
// wrapped in a function so they aren't executed at lint time | ||
function _otherCases() { | ||
// 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'], | ||
jestPlugin.configs['flat/recommended'], | ||
); | ||
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, | ||
// this should error but doesn't because there are no types exported from the jest plugin | ||
...jestPlugin.configs['flat/recommended'], | ||
); | ||
} |
14 changes: 14 additions & 0 deletionspackages/integration-tests/fixtures/flat-config-types-@types__eslint-v9/package.json
This file contains hidden or 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": "^9", | ||
"eslint": "latest", | ||
"@stylistic/eslint-plugin": "latest", | ||
"eslint-plugin-deprecation": "latest", | ||
"eslint-plugin-jest": "latest" | ||
} | ||
} |
2 changes: 1 addition & 1 deletion...napshots__/flat-config-types.test.ts.snap → ...nfig-types-@types__eslint-v8.test.ts.snap
This file contains hidden or 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
119 changes: 119 additions & 0 deletions...es/integration-tests/tests/__snapshots__/flat-config-types-@types__eslint-v9.test.ts.snap
This file contains hidden or 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,119 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
exports[`flat-config-types-@types__eslint-v9 eslint should work successfully 1`] = ` | ||
[ | ||
{ | ||
"errorCount": 3, | ||
"fatalErrorCount": 0, | ||
"filePath": "<root>/eslint.config.js", | ||
"fixableErrorCount": 0, | ||
"fixableWarningCount": 0, | ||
"messages": [ | ||
{ | ||
"column": 10, | ||
"endColumn": 21, | ||
"endLine": 38, | ||
"line": 38, | ||
"message": "'_otherCases' is defined but never used.", | ||
"messageId": "unusedVar", | ||
"nodeType": null, | ||
"ruleId": "@typescript-eslint/no-unused-vars", | ||
"severity": 2, | ||
}, | ||
{ | ||
"column": 5, | ||
"endColumn": 24, | ||
"endLine": 55, | ||
"line": 55, | ||
"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": 5, | ||
"endColumn": 24, | ||
"endLine": 60, | ||
"line": 60, | ||
"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( | ||
{ | ||
// config with just ignores is the replacement for \`.eslintignore\` | ||
ignores: ['**/build/**', '**/dist/**', 'src/some/file/to/ignore.ts'], | ||
}, | ||
{ | ||
plugins: { | ||
['@typescript-eslint']: tseslint.plugin, | ||
['deprecation']: deprecationPlugin, | ||
['jest']: jestPlugin, | ||
}, | ||
}, | ||
eslint.configs.recommended, | ||
...tseslint.configs.recommended, | ||
stylisticPlugin.configs['recommended-flat'], | ||
) | ||
// wrapped in a function so they aren't executed at lint time | ||
function _otherCases() { | ||
// 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'], | ||
jestPlugin.configs['flat/recommended'], | ||
) | ||
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, | ||
// this should error but doesn't because there are no types exported from the jest plugin | ||
...jestPlugin.configs['flat/recommended'], | ||
) | ||
} | ||
", | ||
"suppressedMessages": [], | ||
"usedDeprecatedRules": [], | ||
"warningCount": 0, | ||
}, | ||
] | ||
`; |
File renamed without changes.
31 changes: 31 additions & 0 deletionspackages/integration-tests/tests/flat-config-types-@types__eslint-v9.test.ts
This file contains hidden or 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,31 @@ | ||
import { | ||
eslintIntegrationTest, | ||
typescriptIntegrationTest, | ||
} from '../tools/integration-test-base'; | ||
for (const additionalFlags of [ | ||
[], | ||
['--strictNullChecks'], | ||
['--strictNullChecks', '--exactOptionalPropertyTypes'], | ||
]) { | ||
typescriptIntegrationTest( | ||
`typescript${additionalFlags.length ? ` with ${additionalFlags.join(', ')}` : ''}`, | ||
__filename, | ||
['--allowJs', '--esModuleInterop', ...additionalFlags, 'eslint.config.js'], | ||
out => { | ||
const lines = out.split('\n').filter( | ||
line => | ||
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') && | ||
// currently expected errors from @stylistic/eslint-plugin as it doesn't support ESLint v9 types yet | ||
!line.startsWith('node_modules/@stylistic/eslint-plugin/'), | ||
); | ||
// The types should not error (e.g. https://github.com/eslint-stylistic/eslint-stylistic/issues/276) | ||
expect(lines).toHaveLength(0); | ||
}, | ||
); | ||
} | ||
eslintIntegrationTest(__filename, 'eslint.config.js', true); |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.