Skip to content

Commit a551f52

Browse files
committed
Added base stylelint configuration.
1 parent ecebce4 commit a551f52

File tree

10 files changed

+92
-28
lines changed

10 files changed

+92
-28
lines changed

docs/linter.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Linter Configuration
22

3-
This boilerplate uses [ESLint](http://eslint.org/) as the linter, and uses the [Standard](https://github.com/feross/standard/blob/master/RULES.md) preset with some small customizations.
3+
## ESLint
4+
This boilerplate uses [ESLint](http://eslint.org/) for JavaScript linting, and uses the [Standard](https://github.com/feross/standard/blob/master/RULES.md) preset with some small customizations.
45

56
If you are not happy with the default linting rules, you have several options:
67

@@ -13,3 +14,16 @@ If you are not happy with the default linting rules, you have several options:
1314
2. Pick a different ESLint preset when generating the project, for example [eslint-config-airbnb](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb).
1415

1516
3. Pick "none" for ESLint preset when generating the project and define your own rules. See [ESLint documentation](http://eslint.org/docs/rules/) for more details.
17+
18+
## stylelint
19+
This boilerplate uses [stylelint](http://stylint.io/) as for style linting, and uses the [Standard](https://github.com/stylelint/stylelint-config-standard) preset.
20+
21+
If you are not happy with the default linting rules, you have several options:
22+
23+
1. Overwrite individual rules in `.stylelint.js`. For example, you can add the following rule to enforce tabs.
24+
25+
``` js
26+
"indentation": "tab",
27+
```
28+
29+
2. Pick "none" for ESLint preset when generating the project and define your own rules. See [Stylelint documentation](http://stylelint.io/user-guide/rules/) for more details.

docs/structure.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
├── .babelrc # babel config
2929
├── .editorconfig.js # editor config
3030
├── .eslintrc.js # eslint config
31+
├── .stylelintrc.js # stylelint config
3132
├── index.html # index.html template
3233
└── package.json # build scripts and dependencies
3334
```

meta.json

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
"type": "string",
1616
"message": "Author"
1717
},
18-
"lint": {
18+
"eslint": {
1919
"type": "confirm",
2020
"message": "Use ESLint to lint your code?"
2121
},
22-
"lintConfig": {
23-
"when": "lint",
22+
"eslintConfig": {
23+
"when": "eslint",
2424
"type": "list",
2525
"message": "Pick an ESLint preset",
2626
"choices": [
@@ -41,6 +41,27 @@
4141
}
4242
]
4343
},
44+
"stylelint": {
45+
"type": "confirm",
46+
"message": "Use ESLint to lint your code?"
47+
},
48+
"stylelintConfig": {
49+
"when": "stylelint",
50+
"type": "list",
51+
"message": "Pick an ESLint preset",
52+
"choices": [
53+
{
54+
"name": "Standard (https://github.com/stylelint/stylelint-config-standard)",
55+
"value": "standard",
56+
"short": "Standard"
57+
},
58+
{
59+
"name": "none (configure it yourself)",
60+
"value": "none",
61+
"short": "none"
62+
}
63+
]
64+
},
4465
"unit": {
4566
"type": "confirm",
4667
"message": "Setup unit tests with Karma + Mocha?"
@@ -51,7 +72,8 @@
5172
}
5273
},
5374
"filters": {
54-
".eslintrc.js": "lint",
75+
".eslintrc.js": "eslint",
76+
".stylelint.js": "stylelint",
5577
"test/unit/**/*": "unit",
5678
"test/e2e/**/*": "e2e"
5779
},

template/.eslintrc.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module.exports = {
22
root: true,
3-
{{#if_eq lintConfig "standard"}}
3+
{{#if_eq eslintConfig "standard"}}
44
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
55
extends: 'standard',
66
{{/if_eq}}
7-
{{#if_eq lintConfig "airbnb"}}
7+
{{#if_eq eslintConfig "airbnb"}}
88
extends: 'airbnb-base',
99
{{/if_eq}}
1010
// required to lint *.vue files
@@ -13,11 +13,11 @@ module.exports = {
1313
],
1414
// add your custom rules here
1515
'rules': {
16-
{{#if_eq lintConfig "standard"}}
16+
{{#if_eq eslintConfig "standard"}}
1717
// allow paren-less arrow functions
1818
'arrow-parens': 0,
1919
{{/if_eq}}
20-
{{#if_eq lintConfig "airbnb"}}
20+
{{#if_eq eslintConfig "airbnb"}}
2121
'import/no-unresolved': 0,
2222
{{/if_eq}}
2323
// allow debugger during development

template/.stylelintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
{{#if_eq eslintConfig "standard"}}
3+
extends: 'stylelint-config-standard',
4+
{{/if_eq}}
5+
// add your custom rules here
6+
rules: {
7+
}
8+
};

template/build/webpack.dev.conf.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ module.exports = merge(baseWebpackConfig, {
2929
filename: 'index.html',
3030
template: 'index.html',
3131
inject: true
32+
}),
33+
// Stylelint for all imports
34+
// https://github.com/vieron/stylelint-webpack-plugin
35+
new StyleLintPlugin({
36+
configFile: path.resolve(__dirname, '../.stylelintrc.js'),
37+
context: 'inherits from webpack',
38+
files: '../src/**/*.@(?(s)?(a|c)ss|vue|html)',
39+
failOnError: false,
40+
extractStyleTagsFromHtml: true,
3241
})
3342
]
3443
})

template/package.json

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
{{#e2e}}
1414
"e2e": "node test/e2e/runner.js",
1515
{{/e2e}}
16-
"test": "{{#unit}}npm run unit{{/unit}}{{#unit}}{{#e2e}} && {{/e2e}}{{/unit}}{{#e2e}}npm run e2e{{/e2e}}"{{#lint}},
17-
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"{{/lint}}
16+
"lint": "{{#eslint}}npm run lint:eslint{{/eslint}}{{#eslint}}{{#stylelint}} && {{/eslint}}{{/stylelint}}{{#stylelint}}npm run lint:stylelint{{/stylelint}}",
17+
"test": "{{#unit}}npm run unit{{/unit}}{{#unit}}{{#e2e}} && {{/e2e}}{{/unit}}{{#e2e}}npm run e2e{{/e2e}}"{{#eslint}},
18+
{{#eslint}}
19+
"lint:eslint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"{{/eslint}}{{#stylelint}},
20+
"lint:stylelint": "stylelint 'src/**/*.@(?(s)?(a|c)ss|vue|html)' --config ./.stylelintrc.js --extract"{{/stylelint}}
1821
},
1922
"dependencies": {
2023
"vue": "^1.0.21",
@@ -28,21 +31,21 @@
2831
"babel-preset-stage-2": "^6.0.0",
2932
"connect-history-api-fallback": "^1.1.0",
3033
"css-loader": "^0.23.0",
31-
{{#lint}}
34+
{{#eslint}}
3235
"eslint": "^2.10.2",
3336
"eslint-friendly-formatter": "^2.0.5",
3437
"eslint-loader": "^1.3.0",
3538
"eslint-plugin-html": "^1.3.0",
36-
{{#if_eq lintConfig "standard"}}
39+
{{#if_eq eslintConfig "standard"}}
3740
"eslint-config-standard": "^5.1.0",
3841
"eslint-plugin-promise": "^1.0.8",
3942
"eslint-plugin-standard": "^1.3.2",
4043
{{/if_eq}}
41-
{{#if_eq lintConfig "airbnb"}}
44+
{{#if_eq eslintConfig "airbnb"}}
4245
"eslint-config-airbnb-base": "^3.0.1",
4346
"eslint-plugin-import": "^1.8.1",
4447
{{/if_eq}}
45-
{{/lint}}
48+
{{/eslint}}
4649
"eventsource-polyfill": "^0.9.6",
4750
"express": "^4.13.3",
4851
"extract-text-webpack-plugin": "^1.0.1",
@@ -77,6 +80,13 @@
7780
{{/e2e}}
7881
"ora": "^0.2.0",
7982
"shelljs": "^0.6.0",
83+
{{#stylelint}}
84+
"stylelint": "^6.5.0",
85+
"stylelint-webpack-plugin": "^0.2.0",
86+
{{#if_eq stylelintConfig "standard"}}
87+
"stylelint-config-standard": "^8.0.0",
88+
{{/if_eq}}
89+
{{/stylelint}}
8090
"url-loader": "^0.5.7",
8191
"vue-hot-reload-api": "^1.2.0",
8292
"vue-html-loader": "^1.0.0",

template/src/App.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
</template>
2424

2525
<script>
26-
import Hello from './components/Hello'{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
26+
import Hello from './components/Hello'{{#if_eq eslintConfig "airbnb"}};{{/if_eq}}
2727
2828
export default {
2929
components: {
30-
Hello{{#if_eq lintConfig "airbnb"}},{{/if_eq}}
31-
}{{#if_eq lintConfig "airbnb"}},{{/if_eq}}
32-
}{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
30+
Hello{{#if_eq eslintConfig "airbnb"}},{{/if_eq}}
31+
}{{#if_eq eslintConfig "airbnb"}},{{/if_eq}}
32+
}{{#if_eq eslintConfig "airbnb"}};{{/if_eq}}
3333
</script>
3434

3535
<style>
@@ -59,6 +59,6 @@ body {
5959
6060
.logo {
6161
width: 100px;
62-
height: 100px
62+
height: 100px;
6363
}
6464
</style>

template/src/components/Hello.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export default {
1212
// with hot-reload because the reloaded component
1313
// preserves its current state and we are modifying
1414
// its initial state.
15-
msg: 'Hello World!'{{#if_eq lintConfig "airbnb"}},{{/if_eq}}
16-
}{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
17-
}{{#if_eq lintConfig "airbnb"}},{{/if_eq}}
18-
}{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
15+
msg: 'Hello World!'{{#if_eq eslintConfig "airbnb"}},{{/if_eq}}
16+
}{{#if_eq eslintConfig "airbnb"}};{{/if_eq}}
17+
}{{#if_eq eslintConfig "airbnb"}},{{/if_eq}}
18+
}{{#if_eq eslintConfig "airbnb"}};{{/if_eq}}
1919
</script>
2020

2121
<!-- Add "scoped" attribute to limit CSS to this component only -->

template/src/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import Vue from 'vue'{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
2-
import App from './App'{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
1+
import Vue from 'vue'{{#if_eq eslintConfig "airbnb"}};{{/if_eq}}
2+
import App from './App'{{#if_eq eslintConfig "airbnb"}};{{/if_eq}}
33

44
/* eslint-disable no-new */
55
new Vue({
66
el: 'body',
7-
components: { App }{{#if_eq lintConfig "airbnb"}},{{/if_eq}}
8-
}){{#if_eq lintConfig "airbnb"}};{{/if_eq}}
7+
components: { App }{{#if_eq eslintConfig "airbnb"}},{{/if_eq}}
8+
}){{#if_eq eslintConfig "airbnb"}};{{/if_eq}}

0 commit comments

Comments
 (0)