Skip to content

Commit

Permalink
Merge branch 'antfu-config-2'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanobartoletti committed Nov 20, 2023
2 parents ddefbe3 + bfb5eb8 commit ae0048b
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 100 deletions.
6 changes: 2 additions & 4 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import stefanobartoletti from './index.js'
import { stefanobartoletti } from './index.js'

export default [
...stefanobartoletti,
]
export default stefanobartoletti()
51 changes: 15 additions & 36 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,19 @@
import antfu from '@antfu/eslint-config'
import antfuOptions from './rules/antfuOptions.js'
import sbConfigBase from './rules/sbConfigBase.js'
import sbConfigNuxt from './rules/sbConfigNuxt.js'

const stefanobartoletti = antfu({
stylistic: true,
vue: true,
typescript: true,
})
const stefanobartoletti = (...args) => {
return antfu(
antfuOptions, // This must be the first argument
sbConfigBase,
...args,
)
}

stefanobartoletti.push({
// Vue rules
files: ['**/*.vue'],
rules: {
'vue/max-attributes-per-line': ['error', {
singleline: { max: 10 },
multiline: { max: 1 },
}],
'vue/singleline-html-element-content-newline': 'off',
'vue/html-self-closing': ['warn', {
html: {
void: 'always',
normal: 'never',
},
}],
'vue/block-order': ['error', {
order: ['template', 'script', 'style'],
}],
},
})
const nuxt = sbConfigNuxt

stefanobartoletti.push({
// General rules
rules: {
'curly': ['error', 'all'],
'style/function-call-spacing': ['error', 'never'],
'node/prefer-global/process': 'off',
'antfu/top-level-function': 'off',
},
})

export default stefanobartoletti
export {
stefanobartoletti,
nuxt,
}
35 changes: 0 additions & 35 deletions nuxt.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"eslint": "^8.54.0"
},
"dependencies": {
"@antfu/eslint-config": "^1.2.1"
"@antfu/eslint-config": "^2.0.0"
},
"devDependencies": {
"@commitlint/cli": "^18.4.2",
Expand Down
48 changes: 24 additions & 24 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions rules/antfuOptions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const antfuOptions = {
stylistic: true,
vue: true,
typescript: true,
}

export default antfuOptions
35 changes: 35 additions & 0 deletions rules/sbConfigBase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const sbConfigBase = [

// Vue Rules
{
files: ['**/*.vue'],
rules: {
'vue/max-attributes-per-line': ['error', {
singleline: { max: 10 },
multiline: { max: 1 },
}],
'vue/singleline-html-element-content-newline': 'off',
'vue/html-self-closing': ['warn', {
html: {
void: 'always',
normal: 'never',
},
}],
'vue/block-order': ['error', {
order: ['template', 'script', 'style'],
}],
},
},

// General Rules
{
rules: {
'curly': ['error', 'all'],
'style/function-call-spacing': ['error', 'never'],
'node/prefer-global/process': 'off',
'antfu/top-level-function': 'off',
},
},
]

export default sbConfigBase
34 changes: 34 additions & 0 deletions rules/sbConfigNuxt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// https://github.com/nuxt/eslint-config/blob/main/packages/eslint-config/index.js

const sbConfigNuxt = [

// Components Rules
{
files: ['**/components/**/*.{js,ts,jsx,tsx,vue}'],
rules: {
// Components should have multiple word names.
// Pages, layouts, app.* and error.* not included as they can have single word names
'vue/multi-word-component-names': 'warn',
},
},

// Composables Rules
{
files: ['**/composables/**/*.{js,ts,jsx,tsx,vue}'],
rules: {
// Composables can use auto-imports, eslint should not throw an error for undefined
'no-undef': 'off',
},
},

// Pages and Layouts Rules
{
files: ['**/{pages,layouts}/**/*.{js,ts,jsx,tsx,vue}'],
rules: {
// Pages and layouts are required to have a single root element if transitions are enabled.
'vue/no-multiple-template-root': 'error',
},
},
]

export default sbConfigNuxt

0 comments on commit ae0048b

Please sign in to comment.