# @johnpc/ts-style

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

Latest version **0.0.2** (published 2020-12-24) · 0 weekly downloads

## Install

```sh
npm install @johnpc/ts-style
pnpm add @johnpc/ts-style
yarn add @johnpc/ts-style
bun add @johnpc/ts-style
```

Provides the command `johnpc-ts-style`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2020-12-24 |
| First published | 2020-12-02 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 16 |
| Unpacked size | 243.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | johnpc |

## Links

- npm: https://www.npmjs.com/package/@johnpc/ts-style
- npm.io page: https://npm.io/package/@johnpc/ts-style

## Dependencies (16)

- [execa](https://npm.io/package/execa.md) ^5.0.0
- [husky](https://npm.io/package/husky.md) ^4.3.6
- [eslint](https://npm.io/package/eslint.md) ^7.15.0
- [prettier](https://npm.io/package/prettier.md) ^2.2.1
- [commander](https://npm.io/package/commander.md) ^6.2.1
- [lint-staged](https://npm.io/package/lint-staged.md) ^10.5.3
- [@commitlint/cli](https://npm.io/package/@commitlint/cli.md) ^11.0.0
- [eslint-plugin-react](https://npm.io/package/eslint-plugin-react.md) ^7.21.5
- [eslint-plugin-import](https://npm.io/package/eslint-plugin-import.md) ^2.22.1
- [eslint-plugin-unicorn](https://npm.io/package/eslint-plugin-unicorn.md) ^23.0.0
- [eslint-config-prettier](https://npm.io/package/eslint-config-prettier.md) ^7.0.0
- [eslint-plugin-jsx-a11y](https://npm.io/package/eslint-plugin-jsx-a11y.md) ^6.4.1
- [@typescript-eslint/parser](https://npm.io/package/@typescript-eslint/parser.md) ^4.9.1
- [eslint-plugin-react-hooks](https://npm.io/package/eslint-plugin-react-hooks.md) ^4.2.0
- [@commitlint/config-conventional](https://npm.io/package/@commitlint/config-conventional.md) ^11.0.0
- [@typescript-eslint/eslint-plugin](https://npm.io/package/@typescript-eslint/eslint-plugin.md) ^4.9.1

## Recent versions

- 0.0.2 (latest) — 2020-12-24
- 0.0.1 — 2020-12-02

## README

# @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

---
_Source: https://npm.io/package/@johnpc/ts-style · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
