Skip to content

Commit 3a614fb

Browse files
authored
Merge pull request #61 from Jahia/BACKLOG-11991
BACKLOG-11991 : Add stylelint config
2 parents 1115263 + 8e62b9c commit 3a614fb

File tree

10 files changed

+605
-1
lines changed

10 files changed

+605
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ This project is composed of (click on the link for there documentation):
2121

2222
- [ui-extender - ⚗ - Allow Jahia module to extend Jahia UI](./packages/ui-extender)
2323

24-
- [eslint-config - 🔧 - Jahia eslint configuration](./packages/design-system-kit)
24+
- [eslint-config - 🔧 - Jahia eslint configuration](./packages/eslint-config)
25+
- [stylelint-config - 🔧 - Jahia stylelint configuration](./packages/stylelint-config)
2526
- [test-framework - 🔧 - Jest + Enzyme configuration for Jahia needs](./packages/test-framework)
2627
- [scripts - 🔧 - Jahia internal build script](./packages/scripts)
2728

packages/stylelint-config/.autorc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"owner": "Jahia",
3+
"repo": "javascript-components",
4+
"plugins": [
5+
"npm",
6+
[
7+
"../scripts/auto-include-plugin.js", { "paths": "packages/stylelint-config" }
8+
]
9+
]
10+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<h1 align="center">Welcome to @jahia/stylelint-config 👋</h1>
2+
<p>
3+
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" />
4+
<a href="../../LICENSE.txt" target="_blank">
5+
<img alt="License: JAHIA'S DUAL LICENSING" src="https://img.shields.io/badge/License-JAHIA'S DUAL LICENSING-yellow.svg" />
6+
</a>
7+
<a href="https://twitter.com/Jahia" target="_blank">
8+
<img alt="Twitter: Jahia" src="https://img.shields.io/twitter/follow/Jahia.svg?style=social" />
9+
</a>
10+
</p>
11+
12+
> Provide Jahia Stylelint shareable config to lint your style.
13+
14+
We extend this configurations :
15+
- [stylelint-config-standard](https://github.com/stylelint/stylelint-config-standard)
16+
- [stylelint-config-css-modules](https://github.com/pascalduez/stylelint-config-css-modules)
17+
18+
We use this plugins :
19+
- [stylelint-order](https://github.com/hudochenkov/stylelint-order) to check the order of content and properties within declaration blocks
20+
- [stylelint-scss](https://github.com/kristerkari/stylelint-scss) to check scss synthax
21+
22+
23+
## Install
24+
25+
Add `stylelint` and this package to the `devDependencies` of the project.
26+
This can be accomplished using `yarn` with the following command:
27+
28+
```sh
29+
yarn add -D stylelint @jahia/stylelint-config
30+
```
31+
32+
or using `npm` with the following one:
33+
34+
```sh
35+
npm i -D stylelint @jahia/eslint-config
36+
```
37+
38+
39+
## Configure
40+
41+
Create a file named `.stylelintrc.json` as a sibling of your `package.json`, with the following content:
42+
43+
```json
44+
{
45+
"extends": "@jahia/stylelint-config"
46+
}
47+
```
48+
49+
Update the scripts in your `package.json` to something like:
50+
51+
```json
52+
{
53+
"build": "yarn stylelint && yarn webpack",
54+
"stylelint": "stylelint './src/**/*.scss'",
55+
"stylelint:fix": "stylelint './src/**/*.scss' --fix ."
56+
}
57+
```
58+
59+
Additionally you may want to add a file `.stylelintignore` as a sibling of your `package.json`, with the following content:
60+
```
61+
node
62+
node_modules
63+
target
64+
build
65+
```
66+
67+
Also depending on your need your can override some rules in the `.stylelintrc.json` file by redefining them.
68+
69+
**IDE integrate stylelint configuration or has a stylelint plugin to do it, do not forget to activate it**
70+
71+
- For IntelliJ : [Activating and configuring Stylelint](https://www.jetbrains.com/help/idea/using-stylelint-code-quality-tool.html)
72+
- For Atom : [Install linter-stylelint](https://github.com/AtomLinter/linter-stylelint)
73+
- For VS Code : [Install vscode-stylelint](https://github.com/stylelint/vscode-stylelint)
74+
75+
76+
## Usage
77+
78+
If you added the scripts in your `package.json`, you can do:
79+
80+
```sh
81+
yarn stylelint
82+
```
83+
84+
or with *npm*:
85+
86+
```sh
87+
npm run stylelint
88+
```
89+
90+
## Author
91+
92+
👤 **Jahia**
93+
94+
* Website: https://www.jahia.com
95+
* Twitter: [@Jahia](https://twitter.com/Jahia)
96+
* Github: [@Jahia](https://github.com/Jahia)
97+
98+
## 🤝 Contributing
99+
100+
Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](https://jira.jahia.com).
101+
102+
## Show your support
103+
104+
Give a ⭐️ if this project helped you!
105+
106+
## 📝 License
107+
108+
Copyright © 2019 [Jahia](https://github.com/Jahia).<br />
109+
This project is [JAHIA'S DUAL LICENSING](../../LICENSE.txt) licensed.
110+
111+
***
112+
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_

packages/stylelint-config/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
const basicsRules = require('./rules/basicsRules.js');
4+
const orderTypes = require('./rules/orderTypes.js');
5+
const orderProperties = require('./rules/orderProperties.js');
6+
const scssRules = require('./rules/scssRules.js');
7+
8+
module.exports = {
9+
extends: ['stylelint-config-standard', 'stylelint-config-css-modules'],
10+
plugins: ['stylelint-scss', 'stylelint-order'],
11+
ignoreFiles: [
12+
'**/*.jsx'
13+
],
14+
rules: {
15+
...orderTypes,
16+
...orderProperties,
17+
...basicsRules,
18+
...scssRules
19+
}
20+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@jahia/stylelint-config",
3+
"version": "0.0.1",
4+
"scripts": {
5+
"publish-script": "jahia-publish"
6+
},
7+
"description": "Stylelint shareable config for Jahia projects",
8+
"main": "index.js",
9+
"license": "MIT",
10+
"peerDependencies": {
11+
"stylelint": "^12.0.0"
12+
},
13+
"dependencies": {
14+
"stylelint-config-css-modules": "^2.1.0",
15+
"stylelint-config-standard": "^19.0.0",
16+
"stylelint-order": "^3.1.1",
17+
"stylelint-scss": "^3.13.0"
18+
}
19+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module.exports = {
2+
indentation: 4,
3+
// Is Disabled to allow scss at-rules (@include, @if, @else ...)
4+
'at-rule-no-unknown': null,
5+
'at-rule-empty-line-before': [
6+
'always',
7+
{
8+
except: ['first-nested'],
9+
ignore: [
10+
'blockless-after-same-name-blockless',
11+
'after-comment'
12+
],
13+
ignoreAtRules: ['if', 'else']
14+
}
15+
],
16+
// Mandatory to be used with order/oder
17+
'declaration-empty-line-before': [
18+
'always',
19+
{
20+
except: ['first-nested'],
21+
ignore: [
22+
'after-comment',
23+
'after-declaration',
24+
'inside-single-line-block'
25+
]
26+
}
27+
],
28+
'font-family-name-quotes': 'always-unless-keyword',
29+
'function-name-case': 'lower',
30+
'function-url-quotes': 'always',
31+
'selector-pseudo-element-colon-notation': 'double',
32+
'shorthand-property-no-redundant-values': true,
33+
'declaration-block-no-duplicate-properties': true,
34+
'declaration-block-no-redundant-longhand-properties': true,
35+
'value-keyword-case': 'lower',
36+
'comment-empty-line-before': [
37+
'always',
38+
{
39+
except: ['first-nested'],
40+
ignore: ['after-comment', 'stylelint-commands']
41+
}
42+
],
43+
'max-nesting-depth': 3
44+
};

0 commit comments

Comments
 (0)