@clearpeaks/code-linting-style
A TSLint and Prettier config for ClearPeaks
Last updated 2 months ago by clearpeaks .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @clearpeaks/code-linting-style 
SYNC missed versions from official npm registry.

Linters for standardize the code

This repo contains the different configuration files and dependencies for different linters.

Those files will be extended by the proper files of the projects, as is explained below.

Install

If you are using yarn

yarn add --dev @clearpeaks/code-linting-style

If you are using npm

npm install @clearpeaks/code-linting-style --save-dev

Git Hook

In package.json, at scripts level, add the following hook to run prettier and linter before each commit

{
  "scripts": {
    ...
  },
  "husky": {
    "hooks": {
      "pre-commit": "pretty-quick --staged && tslint -c ./tslint.json 'src/**/*.ts'"
    }
  }
}

Deprecarion warning. Upgrading from 0.14

With the version 0 the precommit hook was being declared inside of the scripts. Please change that logic on your projects.

{
  "scripts": {
    "precommit": "pretty-quick --staged && tslint -c ./tslint.json 'src/**/*.ts'"   // Before (BAD)
  },
  "husky": {
    "hooks": {
      "pre-commit": "pretty-quick --staged && tslint -c ./tslint.json 'src/**/*.ts'"    // Now (GOOD)
    }
  }
}

Note: Version 1 of husky require node version >=6, while Husky 2 require node>=8, so we are keeping husky 1 for compatibility.

Tslint

Create tslint config file

touch tslint.json

Add the following content to that file to extend from the clearpeaks package

{
  "defaultSeverity": "error",
  "extends": ["@clearpeaks/code-linting-style/tslint.js"],
  "jsRules": {
    "no-empty": true
  }
}

You can find more info about tslint rules here

Prettier

Create a prettier config file

touch .prettierrc.js

Add the following content to that file to extend from the clearpeaks package

const clearpeaksConfig = require('@clearpeaks/code-linting-style/prettier-conf');
module.exports = clearpeaksConfig;

You can find more info about prettier option/config rules here

More info about prettier configuration file here

ESLint

Create eslint config file

touch .eslintrc.js

Add the following content to that file to extend from the clearpeaks package

module.exports = {
  extends: [
    "./node_modules/@clearpeaks/code-linting-style/.eslintrc.js",
    "prettier"
    ]
}

You can find more info about eslint rules here

Tips

If you are using prettier in vscode, you can enable autoprettify on save, to prettify you files after saving them Add the following config to the User Settings.

To avoid unwanted behaviour with prettier and html, we recommend you to disable runing prettier on save for html files

"editor.formatOnSave": true,
"prettier.eslintIntegration": true,
"[html]": {
  "editor.formatOnSave": false
},

Deploy a new version of the package

Once the PR has been approved:

  1. Increase the semver npm version <patch|minor|major> // This creates a new commit
  2. Publish the package npm publish
  3. Push autogenerated commit git push
  • Note, maybe you will need to login the first time: npm login and use the credentials of ClearPeaks

BREAKING CHANGES 2.x -> 3.x

Upgrading to 3.x version, requires to have Node.js 10+

Current Tags

  • 2.1.12                                ...           latest (2 months ago)

23 Versions

  • 2.1.12                                ...           2 months ago
  • 2.1.11                                ...           2 months ago
  • 2.1.10                                ...           2 months ago
  • 2.1.9                                ...           2 months ago
  • 2.1.8                                ...           2 months ago
  • 2.1.7                                ...           3 months ago
  • 2.1.6                                ...           3 months ago
  • 2.1.5                                ...           9 months ago
  • 2.1.4                                ...           a year ago
  • 2.1.3                                ...           a year ago
  • 2.1.2                                ...           a year ago
  • 2.1.1                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 2.0.10                                ...           2 years ago
  • 2.0.9                                ...           2 years ago
  • 2.0.8                                ...           2 years ago
  • 2.0.7                                ...           2 years ago
  • 2.0.6                                ...           2 years ago
  • 2.0.5                                ...           2 years ago
  • 2.0.3                                ...           2 years ago
  • 2.0.2                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 29
Last Day 0
Last Week 24
Last Month 62
Dependencies (12)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |