Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to typescript-eslint v8 #1082

Merged
merged 16 commits into from
Oct 22, 2024
6 changes: 6 additions & 0 deletions .changeset/lemon-cats-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@definitelytyped/eslint-plugin": patch
"@definitelytyped/dtslint": patch
---

Update to typescript-eslint v8
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"@types/jest": "^29.5.11",
"@types/node": "^18.19.7",
"@types/yargs": "^17.0.32",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"@typescript-eslint/eslint-plugin": "^8.10.0",
"@typescript-eslint/parser": "^8.10.0",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^48.0.2",
Expand Down
10 changes: 5 additions & 5 deletions packages/dtslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
"@definitelytyped/typescript-packages": "workspace:*",
"@definitelytyped/typescript-versions": "workspace:*",
"@definitelytyped/utils": "workspace:*",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"@typescript-eslint/types": "^7.14.1",
"@typescript-eslint/typescript-estree": "^7.14.1",
"@typescript-eslint/utils": "^7.14.1",
"@typescript-eslint/eslint-plugin": "^8.10.0",
"@typescript-eslint/parser": "^8.10.0",
"@typescript-eslint/types": "^8.10.0",
"@typescript-eslint/typescript-estree": "^8.10.0",
"@typescript-eslint/utils": "^8.10.0",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"semver": "^7.5.4",
Expand Down
12 changes: 6 additions & 6 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
},
"scripts": {
"build": "tsc -b .",
"test": "../../node_modules/.bin/jest --config ../../jest.config.js packages/dtslint"
"test": "../../node_modules/.bin/jest --config ../../jest.config.js packages/eslint-plugin"
},
"dependencies": {
"@definitelytyped/utils": "workspace:*",
"@typescript-eslint/types": "^7.14.1",
"@typescript-eslint/utils": "^7.14.1",
"@typescript-eslint/types": "^8.10.0",
"@typescript-eslint/utils": "^8.10.0",
"semver": "^7.5.4"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"eslint": "^8.40.0",
"@typescript-eslint/eslint-plugin": "^8.10.0",
"@typescript-eslint/parser": "^8.10.0",
"eslint": "^8.57.0",
"eslint-plugin-jsdoc": "^44.0.0",
"typescript": ">= 3.0.0-dev || >= 3.1.0-dev || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.7.0-dev || >= 3.8.0-dev || >= 3.9.0-dev || >= 4.0.0-dev || >=5.0.0-dev"
},
Expand Down
9 changes: 2 additions & 7 deletions packages/eslint-plugin/src/configs/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,8 @@ export const all: Linter.BaseConfig = {
},
],
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/ban-types": [
"error",
{
types: { "{}": false },
extendDefaults: true,
},
],
"@typescript-eslint/no-wrapper-object-types": "error",
"@typescript-eslint/no-unsafe-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/triple-slash-reference": ["error", { types: "prefer-import", path: "always" }],
"@typescript-eslint/no-empty-interface": "error",
Expand Down
6 changes: 5 additions & 1 deletion packages/eslint-plugin/src/rules/no-type-only-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ const rule = createRule({
let hasNonEmptyFile = false;

function isOutsidePackage(fileName: string): boolean {
return fileName.includes("node_modules") || path.relative(pkg!.dir, fileName).startsWith("..");
if (fileName.includes("node_modules") || path.relative(pkg!.dir, fileName).startsWith("..")) {
return true;
}
const other = findTypesPackage(fileName);
return !other || other.dir !== pkg!.dir;
Comment on lines +38 to +39
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that this test explicitly includes files from other packages (including versioned subdirs) to test the rule, but we weren't actually checking this here. It's not clear to me why this wasn't breaking before, though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's technically not the best to not cache this result, but since linting can be in an editor, we don't want to store a global cache or something. It shouldn't really cost that much.

}

for (const sourceFile of program.getSourceFiles()) {
Expand Down
11 changes: 2 additions & 9 deletions packages/eslint-plugin/test/__snapshots__/plugin.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ exports[`plugin should have the expected exports 1`] = `
"ts-nocheck": true,
},
],
"@typescript-eslint/ban-types": [
"error",
{
"extendDefaults": true,
"types": {
"{}": false,
},
},
],
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/explicit-member-accessibility": [
"error",
Expand Down Expand Up @@ -84,6 +75,8 @@ exports[`plugin should have the expected exports 1`] = `
},
],
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-unsafe-function-type": "error",
"@typescript-eslint/no-wrapper-object-types": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/triple-slash-reference": [
"error",
Expand Down
18 changes: 5 additions & 13 deletions packages/eslint-plugin/test/eslint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,15 @@ function getAllExpectedLintSnapshots() {
return new Set(allFixtures.map(getLintSnapshotPath));
}

let eslint: ESLint;

beforeAll(() => {
eslint = new ESLint({
cwd: fixtureRoot,
plugins: { [plugin.meta.name]: plugin },
});
});

afterAll(() => {
eslint = undefined as any;
});

// Force one test per fixture so we can see when a file has no errors.
for (const fixture of allFixtures) {
describe(`fixture ${fixture}`, () => {
it("should lint", async () => {
const eslint = new ESLint({
cwd: fixtureRoot,
plugins: { [plugin.meta.name]: plugin },
});

const results = await eslint.lintFiles([fixture]);
for (const result of results) {
result.filePath = path.relative(fixtureRoot, result.filePath);
Expand Down
Loading
Loading