https://github.com/reload/eslint
A Reload opinionated way of making sure our JS code is up to snuff.
https://github.com/reload/eslint
Last synced: 2 months ago
JSON representation
A Reload opinionated way of making sure our JS code is up to snuff.
- Host: GitHub
- URL: https://github.com/reload/eslint
- Owner: reload
- Created: 2021-07-22T13:08:08.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-07-21T13:25:30.000Z (almost 2 years ago)
- Last Synced: 2025-02-19T08:04:11.909Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 295 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

# JavaScript the Reload way
A [Reload](https://reload.dk/) opinionated way of making sure our JS code is up to snuff.
## Usage
### Install
Install `eslint-plugin-reload`.
```sh
npm install eslint-plugin-reload --save-dev
```If using npm before v7, install the required peer dependecies. v7 and beyond auto
installs the peer dependencies.Create these two files alongside your `package.json` file.
### .prettierrc.json
```json
{}
```### .eslintrc.json
```json
{
"extends": ["plugin:reload/recommended"]
}
```Spin this badboy up and point eslint and prettier towards your JS files.
#### Lint
```sh
npx eslint "**/*.js" && npx prettier "**/*.js" --check
```#### Format
```sh
npx eslint "**/*.js" --fix && npx prettier "**/*.js" --write
```## Environment
Remember to define in your `.eslintrc.json` configuration which environments
your code is supposed to support.```json
"extends": ["plugin:reload/recommended"],
"env": {
"browser": true,
"node": true
}
```If not you will get a lot of [no-undef](https://eslint.org/docs/rules/no-undef)
errors on ex. `window` and `console` variables.## Additional rules
Wanting to add additional rules is straightforward.
### [.eslintrc.json](https://eslint.org/docs/rules/)
```json
{
"extends": ["plugin:reload/recommended"],
"rules": {
"no-console": 1
}
}
```If wanting to extend the `eslint-plugin-reload` we need to re-apply
the prettier `eslint-config-prettier` configuration that turns off all
eslint rules that is prettiers responsability.Imagine we wanted to apply the Github JS guidelines we would have to install
their config, extend from it and then make sure to append `eslint-config-prettier`.```sh
npm install eslint-plugin-github eslint-config-prettier --save-dev
``````json
{
"extends": [
"plugin:reload/recommended",
"plugin:github/recommended",
"eslint-config-prettier"
]
}
```## TypeScript
All of the above applies but instead of `recommended` we expose a specific
`reload/typescript` config that also includes everything from `reload/recommended`.```json
{
"extends": ["plugin:reload/typescript"]
}
```## Drupal
There is some globals you would want to include when doing Drupal development.
This is done via. adding `plugin:reload/drupal` at the end.```json
{
"extends": ["plugin:reload/recommended", "plugin:reload/drupal"]
}
```## Editor integration
The `editor_integration` directory is an example of smart editor integration
that will help you with code quality and code style on save.
The equivelant can be configured for additional editors.
PR's are encouraged to broaden the example support.