Skip to content

Commit 44303b0

Browse files
authored
Merge pull request #2 from jmgayosso/feature/eslint-config
Feature/eslint config
2 parents 47b6992 + 128ab4e commit 44303b0

11 files changed

+151
-36
lines changed

.eslintrc.js

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ module.exports = {
1414
browser: true
1515
},
1616
// Rules order is important, please avoid shuffling them
17-
extends: ["plugin:vue/vue3-essential", "prettier", "plugin:storybook/recommended"],
17+
extends: [
18+
"plugin:vue/vue3-essential",
19+
"prettier",
20+
"plugin:storybook/recommended"
21+
],
1822
plugins: [// https://eslint.vuejs.org/user-guide/#why-doesn-t-it-work-on-vue-file
1923
// required to lint *.vue files
2024
'vue' // https://github.com/typescript-eslint/typescript-eslint/issues/389#issuecomment-509292674
@@ -30,14 +34,41 @@ module.exports = {
3034
__QUASAR_SSR_SERVER__: 'readonly',
3135
__QUASAR_SSR_CLIENT__: 'readonly',
3236
__QUASAR_SSR_PWA__: 'readonly',
33-
process: 'readonly',
37+
process: true,
3438
Capacitor: 'readonly',
3539
chrome: 'readonly'
3640
},
3741
// add your custom rules here
3842
rules: {
43+
// allow async-await
44+
// 'generator-star-spacing': 'off',
45+
// allow paren-less arrow functions
46+
// 'arrow-parens': 'off',
47+
// 'one-var': 'off',
48+
49+
// 'import/first': 'off',
50+
// 'import/named': 'error',
51+
// 'import/namespace': 'error',
52+
// 'import/default': 'error',
53+
// 'import/export': 'error',
54+
// 'import/extensions': 'off',
55+
// 'import/no-unresolved': 'off',
56+
// 'import/no-extraneous-dependencies': 'off',
3957
'prefer-promise-reject-errors': 'off',
58+
// 'no-useless-escape': 'off',
4059
// allow debugger during development only
4160
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
42-
}
43-
};
61+
},
62+
"overrides": [
63+
{
64+
// or whatever matches stories specified in .storybook/main.js
65+
"files": ['*.stories.@(ts|tsx|js|jsx|mjs|cjs)'],
66+
"rules": {
67+
// example of overriding a rule
68+
'storybook/hierarchy-separator': 'error',
69+
// example of disabling a rule
70+
'storybook/default-exports': 'off',
71+
}
72+
}
73+
]
74+
};

.storybook/main.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1+
const webpackConfig = require('../webpack-config.js')
2+
const path = require('path');
13
module.exports = {
24
"stories": ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
35
"addons": ["@storybook/addon-links", "@storybook/addon-essentials"],
46
"framework": "@storybook/vue3",
57
core: {
68
builder: "webpack5"
9+
},
10+
"webpackFinal": async(cfg, {configType}) => {
11+
cfg.module.rules.push({
12+
test: /\.(styl|stylus)$/,
13+
use: ['style-loader', 'css-loader', 'stylus-loader'],
14+
});
15+
cfg = webpackConfig(cfg)
16+
// cfg.plugins.push(
17+
// new ESLintPlugin(options)
18+
// )
19+
// cfg.plugins.push(new ESLintPlugin({
20+
// extensions: [ 'js', 'vue' ],
21+
// fix: true,
22+
// formatter: 'stylish',
23+
// threads: false
24+
// }))
25+
return cfg;
726
}
8-
};
27+
};

.stylintrc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"blocks": "never",
3+
"brackets": "never",
4+
"colons": "never",
5+
"colors": "always",
6+
"commaSpace": "always",
7+
"commentSpace": "always",
8+
"cssLiteral": "never",
9+
"depthLimit": false,
10+
"duplicates": true,
11+
"efficient": "always",
12+
"extendPref": false,
13+
"globalDupe": true,
14+
"indentPref": 2,
15+
"leadingZero": "never",
16+
"maxErrors": false,
17+
"maxWarnings": false,
18+
"mixed": false,
19+
"namingConvention": false,
20+
"namingConventionStrict": false,
21+
"none": "never",
22+
"noImportant": false,
23+
"parenSpace": "never",
24+
"placeholder": false,
25+
"prefixVarsWithDollar": "always",
26+
"quotePref": "single",
27+
"semicolons": "never",
28+
"sortOrder": false,
29+
"stackedProperties": "never",
30+
"trailingWhitespace": "never",
31+
"universal": "never",
32+
"valid": true,
33+
"zeroUnits": "never",
34+
"zIndexNormalize": false
35+
}

generated-stories-entry.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict'
2+
3+
var _frameworkImportPath = require('@storybook/vue');
4+
5+
(0, _frameworkImportPath.configure)([require.context('./src', true, /^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.mdx)$/), require.context('./src', true, /^\.(?:(?:^|\/|(?:(?:(?!(?:^|\/)\.).)*?)\/)(?!\.)(?=.)[^/]*?\.stories\.(js|jsx|ts|tsx))$/)], module, false)

src/components/testingVue3.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
<script>
22
export default {
3-
name: 'testing-vue-3'
3+
name: 'TestingVue3',
4+
methods: {
5+
lorem(){
6+
const test = 'gola'
7+
return lorem
8+
}
9+
}
410
}
511
</script>
612

713
<template lang="pug">
814
div
9-
.text-bold.test.global-font.text-primary This is a test component
15+
.text-bold.test.global-font This is a test component
1016
</template>
1117

1218
<style lang="stylus">
1319
.test
14-
// color: $negative
15-
</style>
20+
color: green
21+
</style>

src/pages/Error404.vue

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,19 @@
1-
<template>
2-
<div class="fullscreen bg-blue text-white text-center q-pa-md flex flex-center">
3-
<div>
4-
<div style="font-size: 30vh">
5-
404
6-
</div>
7-
8-
<div class="text-h2" style="opacity:.4">
9-
Oops. Nothing here...
10-
</div>
11-
12-
<q-btn
13-
class="q-mt-xl"
14-
color="white"
15-
text-color="blue"
16-
unelevated
17-
to="/"
18-
label="Go Home"
19-
no-caps
20-
/>
21-
</div>
22-
</div>
1+
<template lang="pug">
2+
.fullscreen.bg-blue.text-white.text-center.q-pa-md.flex.flex-center
3+
div
4+
div(style="font-size: 30vh")
5+
| 404
6+
.text-h2(style="opacity:.4")
7+
| Oops. Nothing here...
8+
q-btn.q-mt-xl(color="white" text-color="blue" unelevated="" to="/" label="Go Home" no-caps="")
9+
TestingVue3
2310
</template>
2411

2512
<script>
2613
import { defineComponent } from 'vue'
27-
14+
import TestingVue3 from '~/components/testingVue3.vue'
2815
export default defineComponent({
29-
name: 'Error404'
16+
name: 'Error404',
17+
components: {TestingVue3}
3018
})
3119
</script>

src/stories/Button.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import './button.css';
77
import { reactive, computed } from 'vue';
88
99
export default {
10-
name: 'my-button',
10+
name: 'MyButton',
1111
1212
props: {
1313
label: {

src/stories/Header.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import './header.css';
3434
import MyButton from './Button.vue';
3535
3636
export default {
37-
name: 'my-header',
37+
name: 'MyHeader',
3838
3939
components: { MyButton },
4040

src/stories/Page.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import './page.css';
6363
import MyHeader from './Header.vue';
6464
6565
export default {
66-
name: 'my-page',
66+
name: 'MyPage',
6767
6868
components: { MyHeader },
6969

storybook-init-framework-entry.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@storybook/vue'

webpack-config.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const path = require('path')
2+
const ESLintPlugin = require('eslint-webpack-plugin')
3+
4+
const options = {
5+
extensions: [`js`, `vue`],
6+
exclude: [
7+
'node_modules/',
8+
'.storybook'
9+
],
10+
fix: true,
11+
formatter: 'stylish',
12+
threads: false
13+
}
14+
15+
module.exports = (cfg) => {
16+
cfg.module.rules.push({
17+
test: /\.pug$/,
18+
loader: 'pug-plain-loader'
19+
})
20+
cfg.resolve.alias = {
21+
...cfg.resolve.alias,
22+
'~': path.resolve(__dirname, 'src')
23+
}
24+
25+
cfg.plugins.push(
26+
new ESLintPlugin(options)
27+
)
28+
29+
return cfg
30+
}

0 commit comments

Comments
 (0)