Skip to content

refactor: streamline eslint config #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
### 💿 Install

```bash
yarn add eslint-config-vuetify -D
# OR
npm install eslint-config-vuetify --save-dev
```
OR

```bash
yarn add eslint-config-vuetify -D
```
OR

```bash
pnpm add eslint-config-vuetify -D
```

### 🚀 Usage

Expand Down
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './index.ts.mjs'
85 changes: 46 additions & 39 deletions index.js.mjs
Original file line number Diff line number Diff line change
@@ -1,99 +1,106 @@
import pluginVue from 'eslint-plugin-vue'
import globals from 'globals'
import eslint from '@eslint/js'
import stylistic from '@stylistic/eslint-plugin'
import { defu } from 'defu'
import { loadAutoImports } from './utils/autoimports.mjs'

const autoImports = loadAutoImports()

export default [
eslint.configs.recommended,
...pluginVue.configs['flat/recommended'],
{
name: 'app/files-to-lint',
files: ['**/*.{js,mjs,jsx,ts,mts,tsx,vue}'],
languageOptions: {
plugins: {
'@stylistic': stylistic,
},
languageOptions: defu(autoImports, {
globals: {
...globals.node,
...globals.browser,
},
},
}),
rules: {
'array-bracket-spacing': ['error', 'never'],
// allow paren-less arrow functions
'arrow-parens': ['error', 'as-needed'],
complexity: ['error', 32],
'no-case-declarations': 'off',
'no-console': 'off',
'comma-dangle': ['error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'only-multiline',
}],
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-empty': 'error',
'no-return-assign': 'off',
'no-return-await': 'warn',
'object-shorthand': ['error', 'always'],
'no-extra-semi': 'error',
'no-case-declarations': 'off',
'no-prototype-builtins': 'off',
'no-return-assign': 'off',
'no-unused-vars': 'error',
'no-var': 'error',
'no-void': 'off',
'multiline-ternary': 'off',
'object-curly-spacing': ['error', 'always'],
'prefer-const': ['error', {
destructuring: 'all',
ignoreReadBeforeAssign: true,
}],
'object-shorthand': ['error', 'always'],
'prefer-const': ['error', {
destructuring: 'all',
ignoreReadBeforeAssign: true,
}],
quotes: ['error', 'single', {
avoidEscape: true,
allowTemplateLiterals: true,
}],

'sort-imports': ['warn', {
ignoreDeclarationSort: true,
ignoreCase: true,
ignoreDeclarationSort: true,
}],

// stylistic
'@stylistic/indent': ['error', 2],
'@stylistic/array-bracket-spacing': ['error', 'never'],
'@stylistic/arrow-parens': ['error', 'as-needed'],
'@stylistic/comma-dangle': ['error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'only-multiline',
}],
'space-before-function-paren': [
'@stylistic/eol-last': ['error', 'always'],
'@stylistic/multiline-ternary': 'off',
'@stylistic/no-extra-semi': 'error',
'@stylistic/no-multiple-empty-lines': ['error', { 'max': 2, 'maxEOF': 0 }],
'@stylistic/no-trailing-spaces': 'error',
'@stylistic/object-curly-spacing': ['error', 'always'],
'@stylistic/quotes': ['error', 'single', {
allowTemplateLiterals: true,
avoidEscape: true,
}],
'@stylistic/space-before-function-paren': [
'error',
{
anonymous: 'always',
named: 'always',
asyncArrow: 'always',
named: 'always',
},
],

// Not in override, these apply to non-.vue files too
// vue for non-vue files
'vue/attributes-order': ['error', {
alphabetical: true,
}],
'vue/custom-event-name-casing': ['error', 'kebab-case', { ignores: ['/^[a-z]+(?:-[a-z]+)*:[a-z]+(?:-[a-z]+)*$/u'] }],
'vue/one-component-per-file': 'off',
'vue/custom-event-name-casing': ['error', { ignores: ['/^[a-z]+(?:-[a-z]+)*:[a-z]+(?:-[a-z]+)*$/u'] }],
'vue/require-default-prop': 'off',
'vue/require-prop-types': 'off',
}
},
},

{
name: 'app/overrides',
files: ['**/*.vue'],
rules: {
indent: 'off',
'@stylistic/indent': 'off',
'vue/html-closing-bracket-newline': ['error', {
singleline: 'never',
multiline: 'always',
}],
'vue/html-closing-bracket-spacing': 'error',
'vue/no-v-html': 'off',
'vue/max-attributes-per-line': ['error', {
singleline: 4,
multiline: 1,
}],
'vue/multi-word-component-names': 'off',
'vue/multiline-html-element-content-newline': 'off',
'vue/no-v-html': 'off',
'vue/script-indent': ['error', 2, {
baseIndent: 1,
switchCase: 1,
Expand All @@ -102,6 +109,6 @@ export default [
'vue/singleline-html-element-content-newline': 'off',
'vue/valid-v-on': 'off', // This rule doesn't allow empty event listeners
'vue/valid-v-slot': ['error', { allowModifiers: true }],
}
}
},
},
]
11 changes: 7 additions & 4 deletions index.ts.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import vueTsEslintConfig from '@vue/eslint-config-typescript'
import config from './index.js.mjs'
import {
defineConfigWithVueTs,
vueTsConfigs,
} from '@vue/eslint-config-typescript'

export default [
...vueTsEslintConfig(),
export default defineConfigWithVueTs([
vueTsConfigs.recommended,
...config,
]
])
31 changes: 18 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
"description": "eslint config for vue.js projects",
"main": "index.js.mjs",
"module": "index.ts.mjs",
"types": "types.d.ts",
"type": "module",
"files": [
"index.js.mjs",
"index.ts.mjs",
"types.d.ts",
"utils"
],
"repository": {
"type": "git",
"url": "git+https://github.com/vuetifyjs/eslint-config-vuetify.git"
Expand All @@ -17,20 +24,18 @@
"author": "John Leider <[email protected]>",
"license": "MIT",
"peerDependencies": {
"eslint": "^9.14.0",
"eslint-plugin-n": "^17.12.0"
"eslint": "^9.23.0",
"vue": "^3.5.13",
"vuetify": "^3.7.19"
},
"dependencies": {
"eslint": "^9.14.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^7.1.0",
"eslint-plugin-vue": "^9.29.0",
"globals": "^15.12.0",
"vue": "^3.4.31",
"vuetify": "^3.7.4"
},
"devDependencies": {
"@vue/eslint-config-typescript": "^14.1.3"
"@eslint/js": "^9.23.0",
"@stylistic/eslint-plugin": "^4.2.0",
"@vue/eslint-config-typescript": "^14.5.0",
"defu": "^6.1.4",
"eslint-plugin-vue": "^10.0.0",
"exsolve": "^1.0.4",
"globals": "^16.0.0",
"jiti": "^2.4.2"
}
}
Loading