eslint-config-reverentgeek
Version:
ESLint rules that ReverentGeek likes :)
146 lines (106 loc) • 3.19 kB
Markdown
<!-- markdownlint-disable MD010 -->
# eslint-config-reverentgeek
This package is [ReverentGeek's](https://reverentgeek.com/about/) preferred configuration settings for [eslint](https://eslint.org/).
## Usage (eslint >= v9.0)
1. Install dependencies.
```sh
npm install --save-dev eslint eslint-config-reverentgeek
```
2. Create an `eslint.config.js` file.
3. Add the following to the config file.
```js
"use strict";
const defineConfig = require( "eslint/config" ).defineConfig; // eslint-disable-line n/no-unpublished-require
const rg = require( "eslint-config-reverentgeek" ); // eslint-disable-line n/no-extraneous-require
module.exports = defineConfig( [
{
extends: [ rg.configs.node ],
rules: {
}
}
] );
```
The _node_ config adds specific support for Node.js and CommonJS modules.
## Alternative Configs
The _node-esm_ config adds specific support for Node.js and ES modules (`import`/`export`).
```js
import { defineConfig } from "eslint/config"; // eslint-disable-line n/no-unpublished-import
import rg from "eslint-config-reverentgeek"; // eslint-disable-line n/no-extraneous-import
export default defineConfig( {
extends: [ rg.configs["node-esm"] ],
rules: {
}
} );
```
The _blog_ config changes the code style to two-spaced indentions, which is better for copying code samples to blog posts.
```js
import { defineConfig } from "eslint/config";
import rg from "eslint-config-reverentgeek";
export default defineConfig( {
extends: [ rg.configs.browser, rg.configs.blog ]
} );
```
The _react_ config adds specific support for React, browser, and ES modules (`import`/`export`).
```sh
npm install --save-dev eslint-plugin-react
```
```js
import { defineConfig } from "eslint/config";
import rg from "eslint-config-reverentgeek";
import react from "eslint-plugin-react";
export default defineConfig( {
extends: [ rg.configs.browser, rg.configs.react ],
plugins: {
react
},
rules: {
}
} );
```
The _browser_ config sets the `browser` environment and adds ES module support.
```js
import { defineConfig } from "eslint/config";
import rg from "eslint-config-reverentgeek";
export default defineConfig( {
extends: [ rg.configs.browser ]
} );
```
## Legacy .eslintrc.js support (eslint < v9.0)
1. Install dependencies.
```sh
npm install --save-dev eslint@8 eslint-config-reverentgeek@4
```
2. Create an `.eslintrc.js` file.
3. Add the following to the config file.
```js
module.exports = {
extends: [ "reverentgeek" ]
};
```
## Alternative Rule Sets
The _blog_ rule set changes to code style to two-spaced indentions, which is better for copying code samples to blog posts.
```js
module.exports = {
extends: [ "reverentgeek/blog" ]
};
```
The _node_ rule set adds specific support for Node.js and CommonJS modules.
```js
"use strict";
module.exports = {
extends: [ "reverentgeek/node" ]
};
```
The _node/module_ rule set adds specific support for Node.js and ES modules (`import`/`export`).
```js
"use strict";
module.exports = {
extends: [ "reverentgeek/node/module" ]
};
```
The _browser_ rule set the `browser` environment and adds ES module support.
```js
module.exports = {
extends: [ "reverentgeek/browser" ]
};
```