Skip to content

Commit

Permalink
Bump to ESLint 9+ and adopt @antfu/eslint-config
Browse files Browse the repository at this point in the history
  • Loading branch information
xatier committed Feb 3, 2025
1 parent 14372a2 commit 5ab0510
Show file tree
Hide file tree
Showing 28 changed files with 7,198 additions and 2,492 deletions.
28 changes: 15 additions & 13 deletions .bin/download-electron.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/usr/bin/env node
// modified from node_modules/electron/install.js
const { version } = require('../node_modules/electron/package')

const fs = require('fs')
const os = require('os')
const path = require('path')
const extract = require('extract-zip')

const { downloadArtifact } = require('@electron/get')
const extract = require('extract-zip')

const { version } = require('../node_modules/electron/package')

const arch = process.env.ELECTRON_ARCH || process.arch
const platform = process.env.ELECTRON_PLATFORM || os.platform()
Expand Down Expand Up @@ -50,16 +52,16 @@ function extractFile(zipPath) {

function getPlatformPath() {
switch (platform) {
case 'mas':
case 'darwin':
return 'Electron.app/Contents/MacOS/Electron'
case 'freebsd':
case 'openbsd':
case 'linux':
return 'electron'
case 'win32':
return 'electron.exe'
default:
throw new Error('Electron builds are not available on platform: ' + platform)
case 'mas':
case 'darwin':
return 'Electron.app/Contents/MacOS/Electron'
case 'freebsd':
case 'openbsd':
case 'linux':
return 'electron'
case 'win32':
return 'electron.exe'
default:
throw new Error('Electron builds are not available on platform: ' + platform)
}
}
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

108 changes: 0 additions & 108 deletions .eslintrc.yaml

This file was deleted.

130 changes: 130 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import path from "node:path"
import { fileURLToPath } from "node:url"

import { fixupConfigRules, fixupPluginRules } from "@eslint/compat"
import { FlatCompat } from "@eslint/eslintrc"
import js from "@eslint/js"
import typescriptEslint from "@typescript-eslint/eslint-plugin"
import _import from "eslint-plugin-import"
import tsdoc from "eslint-plugin-tsdoc"
import vue from "eslint-plugin-vue"
import globals from "globals"
import parser from "vue-eslint-parser"

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 [ ...fixupConfigRules(compat.extends(
"plugin:@typescript-eslint/eslint-recommended",
"plugin:vue/vue3-essential",
"prettier",
)), {
plugins: {
vue: fixupPluginRules(vue),
"@typescript-eslint": fixupPluginRules(typescriptEslint),
tsdoc,
import: fixupPluginRules(_import),
},

languageOptions: {
globals: {
...globals.browser,
},

parser: parser,
ecmaVersion: 12,
sourceType: "module",

parserOptions: {
parser: "@typescript-eslint/parser",

parserOptions: {
project: "./tsconfig.json",
},
},
},

settings: {
"import/core-modules": [ "electron" ],
"import/internal-regex": "^@/",

"import/resolver": {
node: {
extensions: [ ".js", ".ts", ".vue" ],
moduleDirectory: [ "node_modules", "src" ],
},

alias: {
extensions: [ ".ts", ".js", ".vue" ],
map: [ [ "@", "./src" ], [ "einstein", "./src/api" ] ],
},
},
},

rules: {
"no-unused-vars": "off",

"@typescript-eslint/no-unused-vars": [ "error", {
argsIgnorePattern: "^_",
} ],

"import/order": [ "error", {
groups: [ "builtin", "external", "internal" ],

pathGroups: [ {
pattern: "einstein",
group: "external",
} ],

"newlines-between": "always",

alphabetize: {
order: "asc",
caseInsensitive: true,
},
} ],

"no-restricted-imports": [ "error", {
paths: [ {
name: "@/api",
message: "Please import from 'einstein' instead.",
} ],

patterns: [ "@/api/*" ],
} ],

"array-bracket-spacing": [ "warn", "always" ],
"class-methods-use-this": "off",

"import/extensions": [ "error", "never", {
ignorePackages: true,

pattern: {
vue: "always",
},
} ],

"import/newline-after-import": "off",
"import/prefer-default-export": "off",
indent: [ "warn", "tab" ],
"max-classes-per-file": "off",
"no-tabs": "off",

semi: [ "error", "never", {
beforeStatementContinuationChars: "always",
} ],

"semi-style": [ "error", "first" ],
"tsdoc/syntax": "warn",
"arrow-body-style": "off",
},
}, {
files: [ "**/*.vue", " src/**", "plugins/**" ],
},{
ignores: [ "dist/", "node_modules/", "webpack/", "webpack.config.js" ],
} ]
Loading

0 comments on commit 5ab0510

Please sign in to comment.