Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/taptima/front-linters-setup
https://github.com/taptima/front-linters-setup
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/taptima/front-linters-setup
- Owner: taptima
- Created: 2020-03-31T00:21:54.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T10:42:47.000Z (almost 2 years ago)
- Last Synced: 2023-03-06T21:37:13.554Z (over 1 year ago)
- Language: JavaScript
- Size: 702 KB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
# Front end linters setup
* NPM update:
Caution! You should manually update package in npm after making changes in repo.* Installation:
```
yarn add husky lint-staged @taptima/front-linters-setup --dev
```* Add following scripts to your **package.json**:
```json
"scripts": {
"format": "prettier \"**/*.{js,jsx,json,css,scss}\" --write --config node_modules/front-linters-setup/configs/prettier/config.json --ignore-path node_modules/front-linters-setup/configs/.ignore",
"lint-styles": "stylelint \"**/*.{css,scss}\" --fix --config node_modules/front-linters-setup/configs/stylelint/formatConfig.json --ignore-path node_modules/front-linters-setup/configs/.ignore",
"lint-js": "eslint \"**/*.{js,jsx}\" --fix --ignore-path node_modules/front-linters-setup/configs/.ignore"
}
```* Also add these lines to your **package.json** to enable pre-commit hooks
```json
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,jsx}": [
"yarn run lint-js",
"yarn run format"
],
"*.{css,scss}": [
"yarn run lint-styles",
"yarn run format"
],
".json": "yarn run format"
}
```* Provide stylelint configuration for your editor:
```json
"stylelint": {
"extends": "./node_modules/front-linters-setup/configs/stylelint/baseConfig.json"
}
```* Provide eslint configuration (use `reactConfig.json` for React.js based projects):
```json
"eslintConfig": {
"extends": "./node_modules/front-linters-setup/configs/eslint/baseConfig.json"
}
```Now you have configured linting & formatting of staged .css, .scss, .js, .jsx & .json files on pre-commit hook.
You can also format & lint all project .css, .scss, .js, .jsx & .json files using commands `yarn format`,
`yarn lint-styles` & `yarn lint-js`.