Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
bradzacher merged 1 commit intomainfrombjz/flat-config-types-integration-test-v9
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
{
"type": "module",
"scripts": {
"// NOTE: @types/eslint has to be pinned until @stylistic/eslint-plugin latest works with latest": ""
},
"devDependencies": {
"@types/eslint__eslintrc": "latest",
"@eslint/eslintrc": "latest",
"@types/eslint__js": "latest",
"@eslint/js": "latest",
"@types/eslint": "^8.56.10",
"@types/eslint": "^8",
"eslint": "latest",
"@stylistic/eslint-plugin": "latest",
"eslint-plugin-deprecation": "latest",
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
// a hacky way to allow __dirname within ESM
module.exports = __dirname;
View file
Open in desktop
Original file line numberDiff line numberDiff 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'],
);
}
View file
Open in desktop
Original file line numberDiff line numberDiff 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"
}
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`flat-config-types eslint should work successfully 1`] = `
exports[`flat-config-types-@types__eslint-v8 eslint should work successfully 1`] = `
[
{
"errorCount": 3,
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff 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,
},
]
`;
View file
Open in desktop
Original file line numberDiff line numberDiff 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);
Loading

[8]ページ先頭

©2009-2025 Movatter.jp