https://github.com/mearns/eslint-config-mearns
https://github.com/mearns/eslint-config-mearns
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mearns/eslint-config-mearns
- Owner: mearns
- License: mit
- Created: 2020-11-03T21:41:53.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-01-03T21:44:49.000Z (4 months ago)
- Last Synced: 2025-04-13T03:57:43.844Z (19 days ago)
- Language: JavaScript
- Size: 401 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-config-mearns
My [eslint](https://eslint.org/docs/user-guide/configuring) styling rules for NodeJS projects.
As of version 4.0.0 of this module, it's been updated as follows:
- Uses ESLint 9
- Uses ESLint flat config style
- Assumes all .js files are written in JS Modules (using `import` and `export`).## Use
```console
# > npm install --save-dev git+https://github.com/mearns/eslint-config-mearns.git
> npm install --save-dev @bmearns/eslint-config
> npm install --save-dev eslint@8
```Set your [eslint.config.js](https://eslint.org/docs/latest/use/configure/configuration-files) as follows:
```js
import bmearns from "@bmearns/eslint-config";export default [...bmearns.configs.recommended];
```Optionally, but recommended:
```console
> npm install --save-dev prettier pretty-quick husky
```And merge the following into your package.json:
```json
{
"scripts": {
"lint": "mearns-lint .",
"pretty": "pretty-quick --staged"
},
"husky": {
"hooks": {
"pre-commit": "npm run pretty -s"
}
}
}
```## Overview
Parses ECMA Version 12, rules based on ["JavaScript Standard Style"](https://standardjs.com/) and [Prettier (v3)](https://prettier.io/), but with semicolons.
The rules start with ["standard"](https://github.com/standard/eslint-config-standard) but we put semicolons back in because some people are really adverse to relying
on [ASI](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Automatic_semicolon_insertion). Our rules require the use of
[semicolons to terminate statements](https://eslint.org/docs/rules/semi), require a [space](https://eslint.org/docs/rules/semi-spacing) after a semicolon and
prohibit a space before a semicolon, and prohibit the use of [extra-semicolons](https://eslint.org/docs/rules/no-extra-semi) (semicolons that create empty statements).We also use the ["prettier/recommended"](https://github.com/prettier/eslint-plugin-prettier#recommended-configuration) configuration and specifically set all prettier rules
to "error" level (some default to "warning").Finally, we add a ["no-warning-comments"](https://eslint.org/docs/rules/no-warning-comments`) rule which will fail if any comment contains strings
"FIXME", "TODO", or "XXX" (case-insensitive in all cases). This isn't to imply you shouldn't use comments like this, these rules allow you to use them to
flag things that you need to fix before you merge or publish. However, these rules do imply that there shouldn't be any long-lived use of these comments: use
an issue tracker for that.## Variations
If you're using jest, you might want to extends "@bmearns/eslint-config/jest"; this will set appropriate overrides for files under the `test/` directory.
Or if you're using jest with your test files adjacent to the source files they test, use "@bmearns/eslint-config/jest-adjacent" instead. This assumes your
files are named like "_foobar_.test._ext_".If you're writing in typescript, you probably want to use "@bmearns/eslint-config/typescript", which will set appropriate overrides for typescript files
(based on ".ts" extension). Note that you'll want to have this _after_ the jest variant if you're using both.