diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index cfde1d36937..00000000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -*.d.ts -out diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 17ee2e39d4e..00000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,59 +0,0 @@ -module.exports = { - root: true, - parser: "@typescript-eslint/parser", - plugins: [ - "@typescript-eslint", - '@stylistic', - ], - extends: [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "plugin:prettier/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking", - ], - parserOptions: { - project: ["./packages/*/tsconfig.json"], - }, - rules: { - "@typescript-eslint/no-require-imports": "off", - semi: "off", - "prettier/prettier": "warn", - "@typescript-eslint/prefer-promise-reject-errors": "off", - "@stylistic/member-delimiter-style": [ - "error", - { - multiline: { - delimiter: "none", - }, - }, - ], - "@typescript-eslint/ban-ts-comment": "off", - "@typescript-eslint/explicit-module-boundary-types": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/restrict-template-expressions": "off", - "@typescript-eslint/no-unsafe-return": "off", - "@typescript-eslint/no-unsafe-argument": "off", - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-non-null-assertion": "off", - "no-constant-condition": "off", - "@typescript-eslint/no-unused-vars": [ - "warn", // or "error" - { - "argsIgnorePattern": "^_", - "varsIgnorePattern": "^_", - "caughtErrorsIgnorePattern": "^_" - } - ], - "@typescript-eslint/no-var-requires": "off", - "@typescript-eslint/explicit-function-return-type": [ - "off", - { - // "allowExpressions": false, - }, - ], - "@typescript-eslint/no-redundant-type-constituents": "off", - }, -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000000..8b02553eb11 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,82 @@ +import typescriptEslint from "@typescript-eslint/eslint-plugin"; +import stylistic from "@stylistic/eslint-plugin"; +import tsParser from "@typescript-eslint/parser"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import js from "@eslint/js"; +import { FlatCompat } from "@eslint/eslintrc"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default [{ + ignores: [ + "**/*.d.ts", + "**/out", + // used for CLI + "**/main.js", + "packages/electron-builder/cli.js", + "packages/electron-builder/install-app-deps.js" + ], +}, ...compat.extends( + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", +), { + plugins: { + "@typescript-eslint": typescriptEslint, + "@stylistic": stylistic, + }, + + languageOptions: { + parser: tsParser, + ecmaVersion: 5, + sourceType: "script", + + parserOptions: { + project: ["./packages/*/tsconfig.json"], + }, + }, + + rules: { + "@typescript-eslint/no-require-imports": "off", + semi: "off", + "prettier/prettier": "warn", + "@typescript-eslint/prefer-promise-reject-errors": "off", + + "@stylistic/member-delimiter-style": ["error", { + multiline: { + delimiter: "none", + }, + }], + + "@typescript-eslint/ban-ts-comment": "off", + "@typescript-eslint/explicit-module-boundary-types": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/no-unsafe-return": "off", + "@typescript-eslint/no-unsafe-argument": "off", + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-non-null-assertion": "off", + "no-constant-condition": "off", + + "@typescript-eslint/no-unused-vars": ["warn", { + argsIgnorePattern: "^_", + varsIgnorePattern: "^_", + caughtErrorsIgnorePattern: "^_", + }], + + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/explicit-function-return-type": ["off", {}], + "@typescript-eslint/no-redundant-type-constituents": "off", + }, +}]; \ No newline at end of file diff --git a/package.json b/package.json index eb6f3cafcf3..19195d2fdbb 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "scripts": { "//": "do not wrap into single quotes - windows doesn't unwrap arg in this case", "compile": "tsc --build", - "lint": "eslint packages --ext .ts", + "lint": "eslint packages", "lint-staged": "lint-staged", "lint-deps": "node ./test/out/helpers/checkDeps.js", "pretest": "pnpm lint-deps && pnpm lint", @@ -54,7 +54,7 @@ "@typescript-eslint/eslint-plugin": "^8.7.0", "@typescript-eslint/parser": "^8.7.0", "conventional-changelog-cli": "5.0.0", - "eslint": "^8.57.1", + "eslint": "^9.0.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.2.1", "fs-extra": "10.1.0", diff --git a/packages/app-builder-lib/src/ProtonFramework.ts b/packages/app-builder-lib/src/ProtonFramework.ts index 7458c16f205..6f42b43df2a 100644 --- a/packages/app-builder-lib/src/ProtonFramework.ts +++ b/packages/app-builder-lib/src/ProtonFramework.ts @@ -30,7 +30,7 @@ export class ProtonFramework extends LibUiFramework { const babelOptions: any = { ast: false, sourceMaps: "inline" } if (process.env.TEST_SET_BABEL_PRESET === "true") { babel = require("@babel/core") - // eslint-disable-next-line @typescript-eslint/no-use-before-define + babel = testOnlyBabel(babel, babelOptions, this.version) } else { try { diff --git a/packages/app-builder-lib/src/asar/asarUtil.ts b/packages/app-builder-lib/src/asar/asarUtil.ts index 83e8f692047..eccbb4c18a1 100644 --- a/packages/app-builder-lib/src/asar/asarUtil.ts +++ b/packages/app-builder-lib/src/asar/asarUtil.ts @@ -11,7 +11,6 @@ import { AsarFilesystem, Node } from "./asar" import { hashFile, hashFileContents } from "./integrity" import { detectUnpackedDirs } from "./unpackDetector" -// eslint-disable-next-line @typescript-eslint/no-var-requires const pickle = require("chromium-pickle-js") /** @internal */ diff --git a/packages/app-builder-lib/src/codeSign/macCodeSign.ts b/packages/app-builder-lib/src/codeSign/macCodeSign.ts index b408a930d46..0fe651c7ef8 100644 --- a/packages/app-builder-lib/src/codeSign/macCodeSign.ts +++ b/packages/app-builder-lib/src/codeSign/macCodeSign.ts @@ -167,7 +167,7 @@ export async function createKeychain({ tmpDir, cscLink, cscKeyPassword, cscILink // use constant file const keychainFile = path.join(process.env.APP_BUILDER_TMP_DIR || tmpdir(), `${createHash("sha256").update(currentDir).update("app-builder").digest("hex")}.keychain`) // noinspection JSUnusedLocalSymbols - // eslint-disable-next-line @typescript-eslint/no-unused-vars + await removeKeychain(keychainFile, false).catch(_ => { /* ignore*/ }) diff --git a/packages/app-builder-lib/src/macPackager.ts b/packages/app-builder-lib/src/macPackager.ts index 56695903732..f2a49cd8548 100644 --- a/packages/app-builder-lib/src/macPackager.ts +++ b/packages/app-builder-lib/src/macPackager.ts @@ -86,7 +86,6 @@ export class MacPackager extends PlatformPackager { break case "dmg": { - // eslint-disable-next-line @typescript-eslint/no-var-requires const { DmgTarget } = require("dmg-builder") mapper(name, outDir => new DmgTarget(this, outDir)) break diff --git a/packages/app-builder-lib/src/publish/KeygenPublisher.ts b/packages/app-builder-lib/src/publish/KeygenPublisher.ts index dbb5dd4b806..7fe58f25170 100644 --- a/packages/app-builder-lib/src/publish/KeygenPublisher.ts +++ b/packages/app-builder-lib/src/publish/KeygenPublisher.ts @@ -105,7 +105,6 @@ export class KeygenPublisher extends HttpPublisher { _arch: Arch, dataLength: number, requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void, - // eslint-disable-next-line @typescript-eslint/no-unused-vars _file: string ): Promise { return HttpExecutor.retryOnServerError(async () => { diff --git a/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts b/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts index d1abbe7ffaa..27f26b42285 100644 --- a/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts +++ b/packages/app-builder-lib/src/targets/nsis/NsisTarget.ts @@ -396,7 +396,6 @@ export class NsisTarget extends Target { let i = 0 while (!(await exists(uninstallerPath)) && i++ < 100) { // noinspection JSUnusedLocalSymbols - // eslint-disable-next-line @typescript-eslint/no-unused-vars await new Promise((resolve, _reject) => setTimeout(resolve, 300)) } } diff --git a/packages/app-builder-lib/src/util/config/config.ts b/packages/app-builder-lib/src/util/config/config.ts index 0efebe50e63..2aadb917ba1 100644 --- a/packages/app-builder-lib/src/util/config/config.ts +++ b/packages/app-builder-lib/src/util/config/config.ts @@ -7,7 +7,6 @@ import { Configuration } from "../../configuration" import { FileSet } from "../../options/PlatformSpecificBuildOptions" import { reactCra } from "../../presets/rectCra" import { PACKAGE_VERSION } from "../../version" -// eslint-disable-next-line @typescript-eslint/no-var-requires const validateSchema = require("@develar/schema-utils") // https://github.com/electron-userland/electron-builder/issues/1847 diff --git a/packages/app-builder-lib/src/vm/ParallelsVm.ts b/packages/app-builder-lib/src/vm/ParallelsVm.ts index 6734219b887..e0f29a6c7ca 100644 --- a/packages/app-builder-lib/src/vm/ParallelsVm.ts +++ b/packages/app-builder-lib/src/vm/ParallelsVm.ts @@ -80,7 +80,6 @@ export class ParallelsVmManager extends VmManager { if (!this.isExitHookAdded) { this.isExitHookAdded = true - // eslint-disable-next-line @typescript-eslint/no-var-requires require("async-exit-hook")((callback: (() => void) | null) => { const stopArgs = ["suspend", vmId] if (callback == null) { diff --git a/packages/builder-util/src/asyncTaskManager.ts b/packages/builder-util/src/asyncTaskManager.ts index 992fb5a7cdd..f27ca28b8d7 100644 --- a/packages/builder-util/src/asyncTaskManager.ts +++ b/packages/builder-util/src/asyncTaskManager.ts @@ -73,7 +73,6 @@ export class AsyncTaskManager { return [] } - // eslint-disable-next-line @typescript-eslint/no-floating-promises list = tasks.slice() tasks.length = 0 } diff --git a/packages/electron-updater/src/AppUpdater.ts b/packages/electron-updater/src/AppUpdater.ts index 6d2ecaddd08..0f972a2777f 100644 --- a/packages/electron-updater/src/AppUpdater.ts +++ b/packages/electron-updater/src/AppUpdater.ts @@ -438,7 +438,6 @@ export abstract class AppUpdater extends (EventEmitter as new () => TypedEmitter } } - // eslint-disable-next-line @typescript-eslint/explicit-function-return-type private createProviderRuntimeOptions() { return { isUseMultipleRangeRequest: true, diff --git a/packages/electron-updater/src/differentialDownloader/downloadPlanBuilder.ts b/packages/electron-updater/src/differentialDownloader/downloadPlanBuilder.ts index c4d6f178596..f836a63f69c 100644 --- a/packages/electron-updater/src/differentialDownloader/downloadPlanBuilder.ts +++ b/packages/electron-updater/src/differentialDownloader/downloadPlanBuilder.ts @@ -104,7 +104,6 @@ function validateAndAdd(operation: Operation, operations: Array, chec operations.push(operation) } -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type function buildChecksumMap(file: BlockMapFile, fileOffset: number, logger: Logger) { const checksumToOffset = new Map() const checksumToSize = new Map() diff --git a/packages/electron-updater/src/providers/PrivateGitHubProvider.ts b/packages/electron-updater/src/providers/PrivateGitHubProvider.ts index 94558de95be..872c8c4dc05 100644 --- a/packages/electron-updater/src/providers/PrivateGitHubProvider.ts +++ b/packages/electron-updater/src/providers/PrivateGitHubProvider.ts @@ -59,7 +59,6 @@ export class PrivateGitHubProvider extends BaseGitHubProvider([ "@babel/plugin-transform-modules-commonjs", // Not sure what this is used for, but keeping just in case (for now) "@changesets/changelog-github", // Used in package.json CI/CD logic "typedoc-plugin-markdown", // Used in typedoc config + // Eslint config doesn't get scanned by + "@stylistic/eslint-plugin", + "@typescript-eslint/eslint-plugin", + "@typescript-eslint/parser", + "eslint-config-prettier", + "eslint-plugin-prettier" ]) const knownMissedDependencies = new Set(["babel-core", "babel-preset-env", "babel-preset-stage-0", "babel-preset-react"])