Skip to content

Commit

Permalink
Merge pull request #139 from leukeleu/refactor-configs
Browse files Browse the repository at this point in the history
Make separate config for each type of project
  • Loading branch information
Sabir el Yahiaoui authored Feb 1, 2024
2 parents 282d941 + 3b8a8fe commit 5d62a2f
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 32 deletions.
21 changes: 0 additions & 21 deletions configs/_vue-generic.js

This file was deleted.

10 changes: 5 additions & 5 deletions configs/javascript.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* The configuration for basic JS files without the use of a framework.
* Just has the recommended eslint and prettier rules
**/

module.exports = {
root: true,
env: {
browser: true,
node: true,
},
extends: ['eslint:recommended', 'prettier'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
'no-undefined': 'error',
'no-console': 'error',
Expand Down
39 changes: 38 additions & 1 deletion configs/nuxt2.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,46 @@
module.exports = {
extends: ['plugin:nuxt/recommended', require.resolve('./vue2')],
env: {
browser: true,
node: true,
},
extends: [
// Standard JS rules
'eslint:recommended',
'prettier',

// Vue2 rules
'plugin:vue/recommended',
'plugin:vuejs-accessibility/recommended',

// Nuxt rules
'plugin:nuxt/recommended',
],
// We don't need to include the vue-eslint-parser here because it's included in the nuxt/recommended config.

// We need the babel eslint-parser on top of the Vue parser to use certain JS features (like dynamic imports).
// This is covered by Typescript in the Nuxt3 config.
parserOptions: {
parser: '@babel/eslint-parser',
requireConfigFile: false,
},
rules: {
// Our base custom rules
'no-undefined': 'error',
'no-console': 'error',

// Our Vue custom rules
'vue/html-self-closing': [
'error',
{
html: {
void: 'always',
},
},
],
'vue/html-closing-bracket-spacing': 'error',
'vue/no-empty-component-block': 'error',
'vue/html-button-has-type': 'warn',
},
overrides: [
{
// These file names are part of the file based routing in Nuxt
Expand Down
46 changes: 45 additions & 1 deletion configs/nuxt3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
module.exports = {
extends: [require.resolve('./vue3')],
env: {
browser: true,
node: true,
},
extends: [
// Standard JS rules
'eslint:recommended',
'prettier',

// Vue3 rules
'plugin:vue/vue3-recommended',
'plugin:vuejs-accessibility/recommended',

// Typescript rules
'plugin:@typescript-eslint/recommended',

// Nuxt rules
'plugin:nuxt/recommended',
],

// We don't need to include the vue-eslint-parser here because it's included in the nuxt/recommended settings

// TS parser settings
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaVersion: 'latest',
sourceType: 'module',
// Needed so TS doesn't complain about usage of browser APIs and newer JS features
lib: ['DOM', 'ESNext'],
},
rules: {
'no-undefined': 'error',
'no-console': 'error',
'vue/html-self-closing': [
'error',
{
html: {
void: 'always',
},
},
],
'vue/html-closing-bracket-spacing': 'error',
'vue/no-empty-component-block': 'error',
'vue/html-button-has-type': 'warn',
},
overrides: [
{
// These file names are part of the file based routing in Nuxt
Expand Down
32 changes: 31 additions & 1 deletion configs/vue2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
module.exports = {
extends: ['plugin:vue/recommended', require.resolve('./_vue-generic')],
env: {
browser: true,
node: true,
},
extends: [
// Standard JS rules
'eslint:recommended',
'prettier',

// Vue2 rules
'plugin:vue/recommended',
'plugin:vuejs-accessibility/recommended',
],
parser: 'vue-eslint-parser',
rules: {
// Our base custom rules
'no-undefined': 'error',
'no-console': 'error',

// Our Vue custom rules
'vue/html-self-closing': [
'error',
{
html: {
void: 'always',
},
},
],
'vue/html-closing-bracket-spacing': 'error',
'vue/no-empty-component-block': 'error',
'vue/html-button-has-type': 'warn',
},
}
37 changes: 34 additions & 3 deletions configs/vue3.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,45 @@
module.exports = {
env: {
browser: true,
node: true,
},
extends: [
'plugin:@typescript-eslint/recommended',
// Standard JS rules
'eslint:recommended',
'prettier',
// Vue3 rules
'plugin:vue/vue3-recommended',
require.resolve('./_vue-generic'),
'plugin:vuejs-accessibility/recommended',
// Typescript rules
'plugin:@typescript-eslint/recommended',
],
parser: 'vue-eslint-parser',

// TS parser settings
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaVersion: 'latest',
sourceType: 'module',
// Needed so TS doesn't complain about usage of browser APIs and newer JS features
lib: ['DOM', 'ESNext'],
},
plugins: ['@typescript-eslint'],
rules: {
// Our base custom rules
'no-undefined': 'error',
'no-console': 'error',

// Our Vue custom rules
'vue/html-self-closing': [
'error',
{
html: {
void: 'always',
},
},
],
'vue/html-closing-bracket-spacing': 'error',
'vue/no-empty-component-block': 'error',
'vue/html-button-has-type': 'warn',
'vue/component-tags-order': [
'error',
{
Expand Down

0 comments on commit 5d62a2f

Please sign in to comment.