1.0.3 • Published 4 years ago

front-linters-setup-test v1.0.3

Weekly downloads
1
License
MIT
Repository
gitlab
Last release
4 years ago

Front end linters setup

  • Installation:
yarn add husky lint-staged git+ssh://git@github.com:taptima/front-linters-setup --dev
  • Add following scripts to your package.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
"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:
"stylelint": {
  "extends": "./node_modules/front-linters-setup/configs/stylelint/baseConfig.json"
}
  • Provide eslint configuration (use reactConfig.json for React.js based projects):
"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.