-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
80 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,74 @@ | ||
# kyt ESLint Linter and JavaScript Style Guide | ||
|
||
This is an extension of the Airbnb [**JavaScript**](https://github.com/airbnb/javascript) and [**React**](https://github.com/airbnb/javascript/tree/master/react) style guides and [ESLint](http://eslint.org/) linter. | ||
|
||
## Install | ||
|
||
Note, setting up a `starter-kyt` will install this package automatically. | ||
|
||
1. Install `eslint-config-kyt` and its dependencies: | ||
```sh | ||
yarn add --dev [email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
eslint-config-kyt \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] | ||
``` | ||
```sh | ||
npm i --save-dev --save-exact [email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
eslint-config-kyt \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] | ||
``` | ||
2. Copy the following into an `.eslintrc.js` in your project: | ||
|
||
```js | ||
module.exports = { | ||
extends: ['eslint-config-kyt'], | ||
// shorthand: ['kyt'] | ||
rules: { | ||
/* If you must, override rules here :P */ | ||
}, | ||
}; | ||
### eslint-config-kyt | ||
|
||
## Installation | ||
|
||
#### yarn | ||
```sh | ||
yarn add --dev [email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
eslint-config-kyt \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] | ||
|
||
# or | ||
|
||
npm i --save-dev --save-exact [email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
eslint-config-kyt \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] \ | ||
[email protected] | ||
``` | ||
|
||
Add to the `extends` section of your ESLint configuration: | ||
|
||
`.eslintrc(.json)`: | ||
```json | ||
{ | ||
"extends": ["eslint-config-kyt"], | ||
"rules": {} | ||
} | ||
``` | ||
`.eslintrc.js`: | ||
```js | ||
module.exports = { | ||
extends: ['eslint-config-kyt'], | ||
// shorthand: ['kyt'] | ||
rules: { | ||
/* If you must, override rules here :P */ | ||
}, | ||
}; | ||
``` | ||
|
||
To add a subset of rules, you can specify one of the following: | ||
|
||
```js | ||
module.exports = { | ||
extends: [ | ||
// extends airbnb/base and contains all of our custom rules | ||
'kyt/base', | ||
// adds `jest` and `jest-formatting` plugins | ||
'kyt/jest', | ||
// adds Airbnb's React rules before our custom rules | ||
'kyt/react', | ||
// all rules | ||
'kyt' | ||
] | ||
} | ||
``` | ||
```js | ||
module.exports = { | ||
extends: [ | ||
// extends airbnb/base and contains all of our custom rules | ||
'kyt/base', | ||
// adds `jest` and `jest-formatting` plugins | ||
'kyt/jest', | ||
// adds Airbnb's React rules before our custom rules | ||
'kyt/react', | ||
// all rules | ||
'kyt' | ||
] | ||
} | ||
``` | ||
|
||
## Prettier Support | ||
|
||
|
@@ -72,13 +78,13 @@ npx eslint . --fix | |
|
||
Or add to your `package.json`: | ||
|
||
``` | ||
{ | ||
"scripts": { | ||
"lint": "eslint .", | ||
"lint-fix": "eslint . --fix" | ||
} | ||
```json | ||
{ | ||
"scripts": { | ||
"lint": "eslint .", | ||
"lint-fix": "eslint . --fix" | ||
} | ||
} | ||
``` | ||
|
||
To keep things formatted as you develop, install an editor package. See more [here](/docs/Recipes.md#editor-configuration). | ||
|
@@ -87,20 +93,20 @@ To keep things formatted as you develop, install an editor package. See more [he | |
|
||
A `kyt` app should work with any editor, but we recommend that you install and configure ESLint with one of the following editors: | ||
|
||
### VSCode | ||
#### VSCode | ||
|
||
1. go to View > Extensions | ||
1. Install `ESLint` | ||
1. Install `Prettier` | ||
1. Go to `Code > Preferences` | ||
1. Change the following preferences to `true`: | ||
|
||
``` | ||
"prettier.eslintIntegration": true, | ||
"editor.formatOnSave": true | ||
``` | ||
``` | ||
"prettier.eslintIntegration": true, | ||
"editor.formatOnSave": true | ||
``` | ||
|
||
### Atom | ||
#### Atom | ||
|
||
1. Go to `Preferences > Install` | ||
1. Install `linter` | ||
|