Skip to content

Commit

Permalink
feat: typescript-eslint v8 has supported eslint v9 (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add authored Aug 4, 2024
1 parent 4cf77fa commit f8d9c30
Show file tree
Hide file tree
Showing 37 changed files with 37 additions and 80 deletions.
27 changes: 1 addition & 26 deletions lib/config-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
import process from "node:process";
import path from "node:path";
import fs from "node:fs/promises";
import { spawnSync } from "node:child_process";
import { writeFile } from "node:fs/promises";
import enquirer from "enquirer";
Expand All @@ -29,7 +28,7 @@ export class ConfigGenerator {
this.packageJsonPath = options.packageJsonPath || findPackageJson(this.cwd);
this.answers = options.answers || {};
this.result = {
devDependencies: ["eslint@9.x"],
devDependencies: ["eslint"],
configFilename: "eslint.config.js",
configContent: "",
installFlags: ["-D"]
Expand Down Expand Up @@ -157,7 +156,6 @@ const compat = new FlatCompat({baseDirectory: __dirname, recommendedConfig: plug
if (this.answers.language === "typescript") {
extensions.push("ts");
this.result.devDependencies.push("typescript-eslint");
this.result.installFlags.push("--force"); // tseslint does not support eslint 9.x yet
importContent += "import tseslint from \"typescript-eslint\";\n";
exportContent += " ...tseslint.configs.recommended,\n";
}
Expand Down Expand Up @@ -265,17 +263,6 @@ export default [\n${exportContent}];`;
const configPath = path.join(this.cwd, this.result.configFilename);

if (executeInstallation === true) {

// removing `--force` when:
// 1. yarn v2+ -- it does not support it.
if (packageManager === "yarn") {
const index = this.result.installFlags.indexOf("--force");

if (index !== -1) {
this.result.installFlags.splice(index, 1);
}
}

log.info("☕️Installing...");
installSyncSaveDev(this.result.devDependencies, packageManager, this.result.installFlags);
await writeFile(configPath, this.result.configContent);
Expand All @@ -296,17 +283,5 @@ export default [\n${exportContent}];`;
log.info(`Successfully created ${configPath} file.`);
log.warn("You will need to install the dependencies yourself.");
}

if (this.result.installFlags.includes("--force")) {
let message = "Note that some plugins currently do not support ESLint v9 yet.\nYou may need to use '--force' when installing";

if (packageManager === "npm") {
const pkg = JSON.parse(await fs.readFile(this.packageJsonPath, "utf8"));

message += `, or add the following to your package.json: \n"overrides": { "eslint": "${pkg.devDependencies.eslint}" } `;
}

log.warn(message);
}
}
}
2 changes: 1 addition & 1 deletion tests/__snapshots__/problems-commonjs-none-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
],
Expand Down
3 changes: 1 addition & 2 deletions tests/__snapshots__/problems-commonjs-none-typescript
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
"typescript-eslint",
],
"installFlags": [
"-D",
"--force",
],
}
2 changes: 1 addition & 1 deletion tests/__snapshots__/problems-commonjs-react-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
"eslint-plugin-react",
Expand Down
3 changes: 1 addition & 2 deletions tests/__snapshots__/problems-commonjs-react-typescript
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
"typescript-eslint",
"eslint-plugin-react",
],
"installFlags": [
"-D",
"--force",
],
}
2 changes: 1 addition & 1 deletion tests/__snapshots__/problems-commonjs-vue-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
"eslint-plugin-vue",
Expand Down
3 changes: 1 addition & 2 deletions tests/__snapshots__/problems-commonjs-vue-typescript
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
"typescript-eslint",
"eslint-plugin-vue",
],
"installFlags": [
"-D",
"--force",
],
}
2 changes: 1 addition & 1 deletion tests/__snapshots__/problems-esm-none-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
],
Expand Down
3 changes: 1 addition & 2 deletions tests/__snapshots__/problems-esm-none-typescript
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
"typescript-eslint",
],
"installFlags": [
"-D",
"--force",
],
}
2 changes: 1 addition & 1 deletion tests/__snapshots__/problems-esm-react-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
"eslint-plugin-react",
Expand Down
3 changes: 1 addition & 2 deletions tests/__snapshots__/problems-esm-react-typescript
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
"typescript-eslint",
"eslint-plugin-react",
],
"installFlags": [
"-D",
"--force",
],
}
2 changes: 1 addition & 1 deletion tests/__snapshots__/problems-esm-vue-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
"eslint-plugin-vue",
Expand Down
3 changes: 1 addition & 2 deletions tests/__snapshots__/problems-esm-vue-typescript
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
"typescript-eslint",
"eslint-plugin-vue",
],
"installFlags": [
"-D",
"--force",
],
}
2 changes: 1 addition & 1 deletion tests/__snapshots__/problems-script-none-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
],
Expand Down
3 changes: 1 addition & 2 deletions tests/__snapshots__/problems-script-none-typescript
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
"typescript-eslint",
],
"installFlags": [
"-D",
"--force",
],
}
2 changes: 1 addition & 1 deletion tests/__snapshots__/problems-script-react-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
"eslint-plugin-react",
Expand Down
3 changes: 1 addition & 2 deletions tests/__snapshots__/problems-script-react-typescript
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
"typescript-eslint",
"eslint-plugin-react",
],
"installFlags": [
"-D",
"--force",
],
}
2 changes: 1 addition & 1 deletion tests/__snapshots__/problems-script-vue-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
"eslint-plugin-vue",
Expand Down
3 changes: 1 addition & 2 deletions tests/__snapshots__/problems-script-vue-typescript
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"@eslint/js",
"typescript-eslint",
"eslint-plugin-vue",
],
"installFlags": [
"-D",
"--force",
],
}
2 changes: 1 addition & 1 deletion tests/__snapshots__/syntax-commonjs-none-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
],
"installFlags": [
Expand Down
3 changes: 1 addition & 2 deletions tests/__snapshots__/syntax-commonjs-none-typescript
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"typescript-eslint",
],
"installFlags": [
"-D",
"--force",
],
}
2 changes: 1 addition & 1 deletion tests/__snapshots__/syntax-commonjs-react-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"eslint-plugin-react",
],
Expand Down
3 changes: 1 addition & 2 deletions tests/__snapshots__/syntax-commonjs-react-typescript
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"typescript-eslint",
"eslint-plugin-react",
],
"installFlags": [
"-D",
"--force",
],
}
2 changes: 1 addition & 1 deletion tests/__snapshots__/syntax-commonjs-vue-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"eslint-plugin-vue",
],
Expand Down
3 changes: 1 addition & 2 deletions tests/__snapshots__/syntax-commonjs-vue-typescript
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"typescript-eslint",
"eslint-plugin-vue",
],
"installFlags": [
"-D",
"--force",
],
}
2 changes: 1 addition & 1 deletion tests/__snapshots__/syntax-esm-none-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
],
"installFlags": [
Expand Down
3 changes: 1 addition & 2 deletions tests/__snapshots__/syntax-esm-none-typescript
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"typescript-eslint",
],
"installFlags": [
"-D",
"--force",
],
}
2 changes: 1 addition & 1 deletion tests/__snapshots__/syntax-esm-react-javascript
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default [
];",
"configFilename": "eslint.config.js",
"devDependencies": [
"eslint@9.x",
"eslint",
"globals",
"eslint-plugin-react",
],
Expand Down
Loading

0 comments on commit f8d9c30

Please sign in to comment.