open-index/open-npm huggingface dataset:
npm package: @johnpc/ts-style
Description: Set up a package using johnpc's coding style and commit conventions.
Latest version: 0.0.2

# @johnpc/ts-style

Set up a package using johnpc's coding style and commit conventions.

## What does it do?

`@johnpc/ts-style` sets up the following:

- [eslint]
- [prettier]
- [commitlint] w/
  [conventional commits](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional)
- [husky] - runs the above before a commit

Husky will run `prettier` and `eslint` on files that end with `.js`, `.jsx`,
`.ts`, `.tsx`. It will run only `prettier` on other files that `prettier`
supports.

It also configures a local commit template that explains conventional commits so
you don't forget!

## Getting Started

> If you already have any of these packages installed, you'll have to remove
> them _before_ installing `@johnpc/ts-style`, otherwise package-lock might pin
> them in a nested folder, and the commands won't be available to your IDE.
>
> ```sh
> npm remove prettier eslint husky @commitlint/cli @commitlint/config-conventional @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-config-prettier eslint-plugin-import eslint-plugin-unicorn lint-staged
> ```
>
> Also, as of right now, this may replace your existing eslint and prettier
> configs. You may want to back them up first.

First, install using npm:

```bash
npm install --save-dev @johnpc/ts-style
```

Next, initialize it in your package:

```bash
./node_modules/.bin/johnpc-ts-style init
```

That's it!

## Overriding / Extending

`@johnpc/ts-style` adds js configs that can be replaced/overridden.

### eslint

Modify the `.eslintrc.js` file - rules added here override rules from
`@johnpc/ts-style/eslint`.

```js
// .eslintrc.js
module.exports = {
  extends: ['./node_modules/@johnpc/ts-style/eslint'],
  rules: {
    // additional rules
  },
};
```

Note that the `extends` line must start with `./node_modules/`. This is because
eslint expects all shared config packages to start with `eslint-config-`.
Hopefully this will be less awkward once eslint finishes their
[config simplification](https://github.com/eslint/rfcs/blob/master/designs/2019-config-simplification/README.md).

### prettier

The `.prettierrc.js` file can be extended using the spread operator:

```js
// .prettierrc.js
const config = require('@johnpc/ts-style/prettier');

module.exports = {
  ...config,
  printWidth: 120,
};
```

[eslint]: https://eslint.org/
[prettier]: https://prettier.io/
[commitlint]: https://commitlint.js.org/
[conventional commits]:
  https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional
[husky]: https://github.com/typicode/husky