-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stylelint-config): Implement Stylelint Common Rule set (#364)
* feat(stylelint-config): Implement Stylelint Common Rule set * update keywords * update readme * add release.config * update readme * update snapshot
- Loading branch information
Showing
20 changed files
with
4,703 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# @moneyforward/stylelint-config | ||
|
||
The Stylelint rules of Money Forward, Inc as an extensible shared config. | ||
|
||
## Usage | ||
|
||
### 1. Install dependencies (and peer dependencies) | ||
|
||
```bash | ||
npm install --save-dev stylelint @moneyforward/stylelint-config | ||
``` | ||
|
||
### 2. Configure Stylelint | ||
|
||
Within your Stylelint config file (`stylelint.config.js` or `.stylelintrc.js`): | ||
|
||
```js | ||
export default { | ||
extends: ['@moneyforward/stylelint-config/essentials'], | ||
}; | ||
``` | ||
|
||
If you need CSS Modules support: | ||
|
||
```diff | ||
export default { | ||
- extends: ['@moneyforward/stylelint-config/essentials'], | ||
+ extends: ['@moneyforward/stylelint-config/essentials', '@moneyforward/stylelint-config/css-modules'], | ||
}; | ||
``` | ||
|
||
Must be added after `essentials`. | ||
|
||
We also provide various other rule sets that you can configure to suit your project. | ||
|
||
```json | ||
{ | ||
"extends": [ | ||
"@moneyforward/stylelint-config/essentials", | ||
"@moneyforward/stylelint-config/css-modules", | ||
"@moneyforward/stylelint-config/scss" | ||
] | ||
} | ||
``` | ||
|
||
| Rule set | Summary | Dependencies | | ||
| ------------: | :------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `essentials` | Contains standard, and recess-order configs | [`standard`](https://github.com/stylelint/stylelint-config-standard) <br> [`recess-order`](https://github.com/stormwarning/stylelint-config-recess-order) | | ||
| `css-modules` | Contains [CSS Modules](https://github.com/css-modules/css-modules) config | - | | ||
| `scss` | Contains SCSS config | [`scss`](https://github.com/stylelint-scss/stylelint-config-standard-scss) | | ||
|
||
Must be added after `essentials`. | ||
|
||
We also provide various other rule sets that you can configure to suit your project. | ||
|
||
If the value of a rule does not suit you, specify that rule in the "rules" section with the value you want: | ||
|
||
```diff | ||
export default { | ||
extends: ['@moneyforward/stylelint-config/essentials'], | ||
+ rules: { | ||
+ value-keyword-case': null, | ||
+ }, | ||
}; | ||
``` | ||
|
||
## Migrate from an existing configuration | ||
|
||
@moneyforward/stylelint-config contains various plugins related to different rule sets. Therefore, users don't need to install them separately. If you have installed them in your existing configuration, we recommend uninstalling them. | ||
|
||
```bash | ||
npm uninstall stylelint-config-standard \ | ||
stylelint-config-recess-order \ | ||
stylelint-config-standard-scss \ | ||
``` | ||
|
||
## Versioning | ||
|
||
- Increment major version: Changed **error** rules. | ||
- Increment minor version: Changed **warn** rules. | ||
- Increment patch version: Not changed **error** and **warn** rules. | ||
|
||
## License | ||
|
||
Open source [licensed as MIT](https://github.com/moneyforward/dummy). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export default { | ||
rules: { | ||
// https://stylelint.io/user-guide/rules/function-no-unknown/ | ||
'function-no-unknown': [ | ||
true, | ||
{ | ||
// cf. https://github.com/css-modules/css-modules/blob/master/docs/composition.md#exceptions | ||
ignoreFunctions: ['global'], | ||
}, | ||
], | ||
|
||
// https://stylelint.io/user-guide/rules/property-no-unknown/ | ||
'property-no-unknown': [ | ||
true, | ||
{ | ||
// cf. https://github.com/css-modules/css-modules/blob/master/docs/composition.md | ||
ignoreProperties: ['composes'], | ||
}, | ||
], | ||
|
||
// https://stylelint.io/user-guide/rules/selector-pseudo-class-no-unknown/ | ||
'selector-pseudo-class-no-unknown': [ | ||
true, | ||
{ | ||
// cf. https://github.com/css-modules/css-modules/blob/master/docs/composition.md#exceptions | ||
ignorePseudoClasses: ['global', 'local'], | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export default { | ||
extends: ['stylelint-config-standard', 'stylelint-config-recess-order'], | ||
|
||
rules: { | ||
// https://stylelint.io/user-guide/rules/declaration-block-no-redundant-longhand-properties/ | ||
'declaration-block-no-redundant-longhand-properties': [ | ||
true, | ||
{ | ||
// Exclude `grid-template` to be able to use `grid-template-areas`. | ||
ignoreShorthands: ['grid-template'], | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default { | ||
extends: ["stylelint-config-standard-scss"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { essentials, node, typescript } from 'eslint-config-moneyforward/flat'; | ||
|
||
export default [ | ||
{ | ||
files: ['**/*.js'], | ||
}, | ||
|
||
...essentials, | ||
{ | ||
rules: { | ||
'import/no-default-export': ['off'], | ||
'unicorn/filename-case': ['off'], | ||
}, | ||
}, | ||
{ | ||
files: ['**/*.config.@(js|ts)'], | ||
rules: { | ||
'no-restricted-exports': ['off'], | ||
'import/no-extraneous-dependencies': ['off'], | ||
}, | ||
}, | ||
|
||
...node, | ||
|
||
...typescript, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"name": "@moneyforward/stylelint-config", | ||
"version": "0.1.0", | ||
"description": "Money Forward's Stylelint rules as an extensible shared config.", | ||
"type": "module", | ||
"exports": { | ||
"./*": "./configs/*" | ||
}, | ||
"engines": { | ||
"node": ">=18.12.0" | ||
}, | ||
"files": [ | ||
"configs" | ||
], | ||
"scripts": { | ||
"lint": "eslint './**/*.@(js|ts)'", | ||
"test": "vitest", | ||
"release": "semantic-release" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/moneyforward/frontend-tools.git", | ||
"directory": "packages/stylelint-config" | ||
}, | ||
"keywords": [ | ||
"stylelint", | ||
"stylelint-config", | ||
"style best practices", | ||
"css modules", | ||
"scss" | ||
], | ||
"author": "Money Forward Engineers", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/moneyforward/frontend-tools/issues" | ||
}, | ||
"homepage": "https://github.com/moneyforward/frontend-tools/tree/main/packages/stylelint-config#readme", | ||
"dependencies": { | ||
"stylelint-config-recess-order": "^6.0.0", | ||
"stylelint-config-standard": "^37.0.0", | ||
"stylelint-config-standard-scss": "^14.0.0" | ||
}, | ||
"devDependencies": { | ||
"@frontend-tools/release-config": "workspace:*", | ||
"@types/node": "22.10.2", | ||
"eslint": "9.20.0", | ||
"eslint-config-moneyforward": "workspace:*", | ||
"stylelint": "16.13.0", | ||
"typescript": "5.7.3", | ||
"vitest": "3.0.5" | ||
}, | ||
"peerDependencies": { | ||
"stylelint": "^16.13.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from '@frontend-tools/release-config'; |
Oops, something went wrong.