Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phoenix35/eslint-config
Complete ESLint shareable config for beginners
https://github.com/phoenix35/eslint-config
eslint eslint-config eslintconfig
Last synced: about 20 hours ago
JSON representation
Complete ESLint shareable config for beginners
- Host: GitHub
- URL: https://github.com/phoenix35/eslint-config
- Owner: Phoenix35
- License: mpl-2.0
- Created: 2020-06-06T09:43:24.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-22T18:36:04.000Z (7 months ago)
- Last Synced: 2024-05-23T04:26:48.693Z (6 months ago)
- Topics: eslint, eslint-config, eslintconfig
- Language: JavaScript
- Size: 184 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @phoenix35/eslint-config
Complete ESLint shareable config for beginners.
## Preliminary thoughts
What do you prefer?
```js
/* curly */
while (true) { // mandatory curly braces for multi-line
if (condition) // optional curly braces for single-line
doSomething();
else
doSomethingElse();
}
// or
while (true) { // mandatory curly braces for all blocks
if (condition) {
doSomething();
} else {
doSomethingElse();
}
}
```
```js
/* @stylistic/js/quotes */
"Hello, world!"; // double quotes
// or
'Hello, world!'; // single quotes
```
```js
/* @stylistic/js/nonblock-statement-body-position */
if (condition)
doStuff(); // statement below the control
// or
if (condition) doStuff(); // statement beside the control
```## How to use
Make sure your node version is up-to-date.
LTS version is `20.16.0` right now, this config will not work with anything below.Make an [`"engines"` field]() in the `package.json` of your project
```json
"engines": {
"node": ">= 20.16.0"
}
```
The version should be `>=` LTS or a later node.js version you use.Create a **`eslint.config.mjs`** file in the same directory as your `package.json`.
```js
// eslint.config.mjs
// import lineexport default [
...importedDefault,
{
rules: {
// curly braces for all blocks
/* "curly": [ "error", "all" ], /**/
// single quotes
/* "@stylistic/js/quotes": [ "error", "single", { avoidEscape: true } ], /**/
// statement beside the control
/* "@stylistic/js/nonblock-statement-body-position": [ "error", "beside" ], /**/
}
}
];
```Uncomment the line for each rule you want to follow, by removing the `/*` at the beginning of said line.
The exact content needs to be adapted to the type of project### - Browser project
You need to install the regular package
```shell
npm install -D eslint @phoenix35/eslint-config
```
```js
// eslint.config.mjs
import browserDefault from "@phoenix35/eslint-config/browser";export default [
...browserDefault,
{
rules: {
// your rules
}
}
];
```### - Node.js project
You need to install the full package with optional dependencies
```shell
npm install -D eslint
npm install -D --include=optional @phoenix35/eslint-config
```
```js
// eslint.config.mjs
import nodeDefault from "@phoenix35/eslint-config/node";export default [
...nodeDefault,
{
rules: {
// your rules
}
}
];
```### - Fullstack project
You need to install the package with optional dependencies (see [Node.js project](<#--nodejs-project>))Have a `eslint.config.mjs` file following "browser project" in the parent directory containing browser-specific code and another following "node project" next to your top-level `package.json`.
### - Userscript
Works for Greasemonkey and Violentmonkey
```shell
npm install -D eslint @phoenix35/eslint-config
```
```js
// eslint.config.mjs
import monkeyDefault from "@phoenix35/eslint-config/userscript";export default [
...monkeyDefault,
{
rules: {
// your rules
}
}
];
```### - WebExtension project
```shell
npm install -D eslint @phoenix35/eslint-config
```
```js
// eslint.config.mjs
import extensionDefault from "@phoenix35/eslint-config/webextensions";export default [
...extensionDefault,
{
rules: {
// your rules
}
}
];
```### - A Polymorphic library
```shell
npm install -D eslint @phoenix35/eslint-config
```
```js
// eslint.config.mjs
import baseDefault from "@phoenix35/eslint-config";export default [
...baseDefault,
{
rules: {
// your rules
}
}
];
```# Now what
Start coding. You're done here.