Skip to content

Commit

Permalink
perf(ui/dev): bump eslint to version 9
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed Jun 8, 2024
1 parent 0e75457 commit 6579db5
Show file tree
Hide file tree
Showing 18 changed files with 1,471 additions and 941 deletions.
14 changes: 0 additions & 14 deletions .eslintignore

This file was deleted.

48 changes: 0 additions & 48 deletions .eslintrc.cjs

This file was deleted.

44 changes: 44 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,48 @@
{
// Enable the ESlint flat config support
"eslint.experimental.useFlatConfig": true,

// Disable the default formatter, use eslint instead
// "prettier.enable": false,
"editor.formatOnSave": false,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},

"eslint.runtime": "node",

// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off" },
{ "rule": "*-indent", "severity": "off" },
{ "rule": "*-spacing", "severity": "off" },
{ "rule": "*-spaces", "severity": "off" },
{ "rule": "*-order", "severity": "off" },
{ "rule": "*-dangle", "severity": "off" },
{ "rule": "*-newline", "severity": "off" },
{ "rule": "*quotes", "severity": "off" },
{ "rule": "*semi", "severity": "off" }
],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"jsonc",
"yaml",
"toml",
"xml"
],

"cSpell.words": [
"akismet",
"artalk",
Expand Down
18 changes: 0 additions & 18 deletions docs/landing/.eslintrc.cjs

This file was deleted.

5 changes: 0 additions & 5 deletions docs/landing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"update:readme": "npx tsx ./scripts/update-readme.ts"
},
Expand All @@ -25,11 +24,7 @@
"devDependencies": {
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"@vitejs/plugin-react-swc": "^3.6.0",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.6",
"sass": "^1.76.0",
"typescript": "^5.4.5",
"vite": "^5.2.11"
Expand Down
2 changes: 1 addition & 1 deletion docs/landing/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"include": ["src", "scripts"],
"references": [{ "path": "./tsconfig.node.json" }]
}
148 changes: 148 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
// @ts-check
import path from 'node:path'
import url from 'node:url'
import eslintTs from 'typescript-eslint'
import pluginTS from '@typescript-eslint/eslint-plugin'
import pluginVue from 'eslint-plugin-vue'
import vueParser from 'vue-eslint-parser'
import pluginFunctional from 'eslint-plugin-functional/flat'
import globals from 'globals'
import eslintJs from '@eslint/js'
import eslintConfigPrettier from 'eslint-config-prettier'
import { FlatCompat } from '@eslint/eslintrc'
import { fixupPluginRules } from '@eslint/compat'

const __dirname = path.dirname(url.fileURLToPath(import.meta.url))

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: eslintJs.configs.recommended,
})

function legacyPlugin(name, alias = name) {
const plugin = compat.plugins(name)[0]?.plugins?.[alias]

if (!plugin) {
throw new Error(`Unable to resolve plugin ${name} and/or alias ${alias}`)
}

return fixupPluginRules(plugin)
}

export default eslintTs.config(
eslintJs.configs.recommended,
...eslintTs.configs.recommended,

// @ts-expect-error the type of `pluginVue` is not compatible with the latest `eslint` v9 package yet
...pluginVue.configs['flat/recommended'],

...compat.extends('plugin:import/typescript'),
...compat.extends('plugin:react-hooks/recommended'),

// FIXME: TypeError SEE https://github.com/amilajack/eslint-plugin-compat/pull/609#issuecomment-2123734301
// ...compat.extends('plugin:compat/recommended'),

{
...pluginFunctional.configs.recommended,

// FIXME: https://github.com/eslint-functional/eslint-plugin-functional/issues/766#issuecomment-1904715609
rules: {
...pluginFunctional.configs.recommended.rules,
'functional/immutable-data': 'off',
'functional/no-return-void': 'off',
},
},

eslintConfigPrettier,
{
// `ignores` key must been defined in a separate object without any other keys
// see https://eslint.org/docs/latest/use/configure/ignore#ignoring-files
// and https://github.com/eslint/eslint/discussions/18304
ignores: [
'**/node_modules',
'**/dist',
'public',
'local',
'test',
'**/.vitepress/cache',
'**/*.config.js',
'**/*.config.ts',
'**/*.d.ts',
],
},
{
files: ['**/*.{ts,tsx,js,vue}'],
languageOptions: {
parser: vueParser,
parserOptions: {
parser: eslintTs.parser,
project: ['./ui/*/tsconfig.json', './docs/*/tsconfig.json'],
tsconfigRootDir: __dirname,
globals: {
...globals.browser,
},
ecmaFeatures: {
jsx: true,
},
sourceType: 'module',
extraFileExtensions: ['.vue'],
},
},
plugins: {
'@typescript-eslint': pluginTS,

// FIXME: eslint `import` plugin is not fully support eslint v9 yet
// see https://github.com/import-js/eslint-plugin-import/issues/2948#issuecomment-2148832701
import: legacyPlugin('eslint-plugin-import', 'import'),
},
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
},
settings: {
'import/resolver': {
typescript: {
project: ['ui/artalk/tsconfig.json'].map((p) => path.resolve(__dirname, p)),
},
},
polyfills: ['AbortController'],
},
},
{
files: ['**/*.vue'],
languageOptions: {
globals: {
// Auto Imports Support
// SEE https://eslint.vuejs.org/user-guide/#auto-imports-support
// SEE https://github.com/antfu/eslint-config/blob/e32301ac398896f20e1ec1f4f10a334687f8afc8/src/configs/vue.ts#L40-L55
computed: 'readonly',
defineEmits: 'readonly',
defineExpose: 'readonly',
defineProps: 'readonly',
onMounted: 'readonly',
onUnmounted: 'readonly',
reactive: 'readonly',
ref: 'readonly',
shallowReactive: 'readonly',
shallowRef: 'readonly',
toRef: 'readonly',
toRefs: 'readonly',
watch: 'readonly',
watchEffect: 'readonly',
onUpdated: 'readonly',
onBeforeMount: 'readonly',
onBeforeUnmount: 'readonly',
onBeforeUpdate: 'readonly',
useRoute: 'readonly',
useRouter: 'readonly',
useStore: 'readonly',
useI18n: 'readonly',
},
},
rules: {},
},
{
files: ['**/*.tsx'],
rules: {},
},
)
48 changes: 28 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,48 @@
"build:docs": "pnpm build && pnpm -F=docs-landing build && pnpm -F=docs-swagger swagger:build && pnpm -F=docs build:docs && pnpm patch:docs",
"patch:docs": "cp -rf docs/landing/dist/* docs/swagger/dist/* docs/docs/.vitepress/dist",
"lint": "pnpm lint:prettier && pnpm lint:eslint",
"lint:eslint": "eslint --fix --ext .ts,.tsx,.js,.jsx,.vue .",
"lint:eslint": "eslint -c eslint.config.mjs",
"lint:prettier": "prettier --check --write .",
"test": "pnpm -F artalk test"
},
"devDependencies": {
"@playwright/test": "^1.43.1",
"@eslint/compat": "^1.0.3",
"@eslint/js": "^9.4.0",
"@playwright/test": "^1.44.1",
"@rollup/plugin-dynamic-import-vars": "2.1.2",
"@types/node": "20.12.8",
"@typescript-eslint/eslint-plugin": "7.8.0",
"@typescript-eslint/parser": "7.8.0",
"@vitest/coverage-v8": "^1.5.3",
"@types/eslint__js": "^8.42.3",
"@types/node": "20.14.2",
"@typescript-eslint/eslint-plugin": "7.12.0",
"@vitest/coverage-v8": "^1.6.0",
"autoprefixer": "10.4.19",
"cross-env": "^7.0.3",
"eslint": "^8.56.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-airbnb-typescript": "18.0.0",
"eslint": "^9.4.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-compat": "4.2.0",
"eslint-plugin-compat": "^4.2.0",
"eslint-plugin-functional": "^6.5.1",
"eslint-plugin-import": "2.29.1",
"jsdom": "^24.0.0",
"eslint-plugin-react-hooks": "5.1.0-beta-26f2496093-20240514",
"eslint-plugin-vue": "^9.25.0",
"globals": "^15.4.0",
"jsdom": "^24.1.0",
"postcss": "8.4.38",
"prettier": "3.2.5",
"rollup": "4.17.2",
"sass": "1.76.0",
"stylelint": "^16.5.0",
"terser": "5.31.0",
"tsx": "^4.9.0",
"prettier": "3.3.1",
"rollup": "4.18.0",
"sass": "1.77.4",
"stylelint": "^16.6.1",
"terser": "5.31.1",
"tsx": "^4.13.3",
"typescript": "5.4.5",
"vite": "5.2.11",
"typescript-eslint": "^7.12.0",
"vite": "5.2.13",
"vite-plugin-checker": "0.6.4",
"vite-plugin-dts": "3.9.0",
"vite-plugin-dts": "3.9.1",
"vite-tsconfig-paths": "4.3.2",
"vitest": "^1.5.3"
"vitest": "^1.6.0",
"vue-eslint-parser": "^9.4.3"
},
"browserslist": [
"supports es6 and supports es6-class and supports es6-generators and supports es6-module-dynamic-import and supports es6-module and supports es6-number and supports es6-string-includes"
Expand Down
Loading

0 comments on commit 6579db5

Please sign in to comment.