Skip to content

Commit

Permalink
^ Upgrade eslint 8 > 9 & config
Browse files Browse the repository at this point in the history
  • Loading branch information
PikachuEXE committed Oct 1, 2024
1 parent b3f92e3 commit 67c6345
Show file tree
Hide file tree
Showing 7 changed files with 324 additions and 221 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

127 changes: 0 additions & 127 deletions .eslintrc.js

This file was deleted.

122 changes: 122 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import eslintPluginVue from 'eslint-plugin-vue'
import vuejsAccessibility from 'eslint-plugin-vuejs-accessibility'
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
import eslintConfigPrettier from 'eslint-config-prettier'
import intlifyVueI18N from '@intlify/eslint-plugin-vue-i18n'
import globals from 'globals'
import vueEslintParser from 'vue-eslint-parser'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import js from '@eslint/js'
import { FlatCompat } from '@eslint/eslintrc'
import { fixupConfigRules } from '@eslint/compat'

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.config({
extends: ['standard']
})
),
js.configs.recommended,
eslintConfigPrettier,
...eslintPluginVue.configs['flat/recommended'],
...vuejsAccessibility.configs["flat/recommended"],
...intlifyVueI18N.configs['flat/recommended'],
{
files: [
'**/*.{js,vue}',
],
ignores: [
'**/node_modules',
'**/_scripts',
'**/dist',
],
plugins: {
unicorn: eslintPluginUnicorn,
},

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

parser: vueEslintParser,
ecmaVersion: 2022,
sourceType: 'module',
},

settings: {
'vue-i18n': {
localeDir: './static/locales/{en-US,en-GB,ar,bg,ca,cs,da,de-DE,el,es,es-AR,es-MX,et,eu,fa,fi,fr-FR,gl,he,hu,hr,id,is,it,ja,ko,lt,nb-NO,nl,nn,pl,pt,pt-BR,pt-PT,ro,ru,sk,sl,sr,sv,tr,uk,vi,zh-CN,zh-TW}.yaml',
messageSyntaxVersion: '^8.0.0',
},
},

rules: {
'space-before-function-paren': 'off',
'comma-dangle': ['error', 'only-multiline'],
'vue/no-v-html': 'off',

'no-console': ['error', {
allow: ['warn', 'error'],
}],

'no-unused-vars': 'warn',
'no-undef': 'warn',
'object-shorthand': 'off',
'vue/no-template-key': 'warn',
'vue/no-useless-template-attributes': 'off',
'vue/multi-word-component-names': 'off',
'vuejs-accessibility/no-onchange': 'off',

'vuejs-accessibility/label-has-for': ['error', {
required: {
some: ['nesting', 'id'],
},
}],

'vuejs-accessibility/no-static-element-interactions': 'off',
'n/no-callback-literal': 'warn',
'n/no-path-concat': 'warn',
'unicorn/better-regex': 'error',
'unicorn/no-array-push-push': 'error',
'unicorn/prefer-keyboard-event-key': 'error',
'unicorn/prefer-regexp-test': 'error',
'unicorn/prefer-string-replace-all': 'error',
'@intlify/vue-i18n/no-dynamic-keys': 'error',
'@intlify/vue-i18n/no-duplicate-keys-in-locale': 'error',

'@intlify/vue-i18n/no-raw-text': ['error', {
attributes: {
'/.+/': [
'title',
'aria-label',
'aria-placeholder',
'aria-roledescription',
'aria-valuetext',
'tooltip',
'message',
],

input: ['placeholder', 'value'],
img: ['alt'],
},

ignoreText: ['-', '•', '/', 'YouTube', 'Invidious', 'FreeTube'],
}],

'@intlify/vue-i18n/no-deprecated-tc': 'off',
'vue/require-explicit-emits': 'error',
'vue/no-unused-emit-declarations': 'error',
},
},
]
36 changes: 36 additions & 0 deletions eslint.json.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { FlatCompat } from '@eslint/eslintrc'
import js from '@eslint/js'
import jsoncEslintParser from 'jsonc-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 [
...compat.extends(
'plugin:jsonc/base',
).map(config => ({
...config,
files: ['**/*.json'],
ignores: [
'**/node_modules',
'**/_scripts',
'**/dist',
],

languageOptions: {
parser: jsoncEslintParser,
},

rules: {
'no-tabs': 'off',
'comma-spacing': 'off',
},
})),
]
35 changes: 35 additions & 0 deletions eslint.yaml.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { FlatCompat } from '@eslint/eslintrc'
import js from '@eslint/js'
import yamlEslintParser from 'yaml-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 [
...compat.extends(
'plugin:yml/recommended',
).map(config => ({
...config,
files: ['**/*.{yml,yaml}'],
ignores: [
'**/node_modules',
'**/_scripts',
'**/dist',
],

languageOptions: {
parser: yamlEslintParser,
},

rules: {
'yml/no-irregular-whitespace': 'off',
},
})),
]
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
"lint-all": "run-p lint lint-json",
"lint": "run-p eslint-lint lint-style",
"lint-fix": "run-p eslint-lint-fix lint-style-fix",
"eslint-lint": "eslint --ext .js,.vue ./",
"eslint-lint-fix": "eslint --fix --ext .js,.vue ./",
"lint-json": "eslint --ext .json ./",
"eslint-lint": "eslint --config eslint.config.mjs './src/**/*.js' './src/**/*.vue' './static/**/*.js'",
"eslint-lint-fix": "eslint --config eslint.config.mjs --fix './src/**/*.js' './src/**/*.vue' './static/**/*.js'",
"lint-json": "eslint --config eslint.json.config.mjs './**/*.json'",
"lint-style": "stylelint \"**/*.{css,scss}\"",
"lint-style-fix": "stylelint --fix \"**/*.{css,scss}\"",
"lint-yml": "eslint --ext .yml,.yaml ./",
"lint-yml": "eslint --config eslint.yaml.config.mjs './**/*.yml' './**/*.yaml'",
"pack": "run-p pack:main pack:renderer && node _scripts/injectAllowedPaths.mjs",
"pack:main": "webpack --mode=production --node-env=production --config _scripts/webpack.main.config.js",
"pack:renderer": "webpack --mode=production --node-env=production --config _scripts/webpack.renderer.config.js",
Expand Down Expand Up @@ -82,14 +82,17 @@
"@babel/plugin-transform-class-properties": "^7.25.4",
"@babel/preset-env": "^7.25.4",
"@double-great/stylelint-a11y": "^3.0.2",
"@eslint/compat": "^1.1.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.11.1",
"@intlify/eslint-plugin-vue-i18n": "^3.0.0",
"babel-loader": "^9.2.1",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"css-minimizer-webpack-plugin": "^7.0.0",
"electron": "^32.1.2",
"electron-builder": "^24.13.3",
"eslint": "^8.57.1",
"eslint": "^9.11.1",
"eslint-config-prettier": "^9.1.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.30.0",
Expand All @@ -101,6 +104,7 @@
"eslint-plugin-vue": "^9.28.0",
"eslint-plugin-vuejs-accessibility": "^2.4.1",
"eslint-plugin-yml": "^1.14.0",
"globals": "^15.9.0",
"html-webpack-plugin": "^5.6.0",
"js-yaml": "^4.1.0",
"json-minimizer-webpack-plugin": "^5.0.0",
Expand Down
Loading

0 comments on commit 67c6345

Please sign in to comment.