Skip to content

Commit

Permalink
v1.0.3 - More fixable lint warnings, updates to README (#4)
Browse files Browse the repository at this point in the history
* stylistic rules all warn

* readme update wip

* add and update rules

* almost release ready

* update changelog.md
  • Loading branch information
nishkohli96 committed Jan 31, 2024
1 parent f0eecf8 commit a7283c3
Show file tree
Hide file tree
Showing 5 changed files with 2,026 additions and 124 deletions.
14 changes: 12 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# **What's changed?**

## 1.0.2
## [1.0.3](https://github.com/nishkohli96/eslint-config/tree/v1.0.3)

*Released 28 Jan, 2024*
**Released - 31 Jan, 2024**

"*More developer friendly, Yay*! 😃"

Approx 90% of the rules used now `warn` instead of throwing an error, so you can focus more on writing the logic, and not on formatting the code! Only the rules that throw an `error` and some exceptional `warn` rules like `'no-debugger'` must be fixed by the developer.

Also, added some cool new badges in [README.md](/README.md) thanks to [Shields.io](https://shields.io/) !

## [1.0.2](https://github.com/nishkohli96/eslint-config/tree/v1.0.2)

**Released - 28 Jan, 2024**

While using this package during my development, I felt that the status of the rules listed below needed to be changed from `error` to `warn` as they would cause my app to crash, prompting me to alter my code to keep eslint happy (and make me irritated instead 😡). These rules would automatically fix the code on running the `yarn lint` script.

Expand Down
209 changes: 126 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# @nish1896/eslint-config

![NPM Version](https://img.shields.io/npm/v/%40nish1896%2Feslint-config)
![NPM Downloads](https://img.shields.io/npm/dt/%40nish1896%2Feslint-config)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/%40nish1896%2Feslint-config)
![npm bundle size](https://img.shields.io/bundlephobia/min/%40nish1896%2Feslint-config)
![node-current](https://img.shields.io/node/v/%40nish1896%2Feslint-config?color=%23e86267)
![GitHub Release Date - Published_At](https://img.shields.io/github/release-date/nishkohli96/eslint-config)

**A set of developer-friendly [eslint](https://eslint.org/), [stylistic](https://eslint.style/), [typescript](https://www.typescriptlang.org/) and [accessibility](https://developer.mozilla.org/en-US/docs/Learn/Accessibility/What_is_accessibility) configuration rules to help you and fellow developers follow the industry-recommended coding practices for easier readability, maintenance and productivity !**

The usage of [eslint-stylistic](https://eslint.style/) over [prettier](https://prettier.io/) will give you additional options to format your code and hopefully avoid conflict of rules between `eslint` and `prettier` for which you additionally had to install [eslint-config-prettier](https://www.npmjs.com/package/eslint-config-prettier).

On running `eslint --fix`, some of the rules imported from this config will give you a warning ⚠️ indicating that the code issue may be ignored while the rules triggering an error ❌ will discourage you to avoid that coding practice. It's okay to have a few warnings when developing, but they should be taken care of when pushing your code for production.
On running `eslint .` some of the rules imported from this config will give you a warning ⚠️ indicating that the code issue may be ignored while the rules triggering an error ❌ will discourage you to avoid that coding practice. `eslint --fix .` should hopefully fix most of the warnings or errors in your code. It's okay to have a few warnings when developing, but they should be taken care of when pushing your code for production.

>[!WARNING]
>Ignored eslint warnings or errors in code will likely cause your app build to fail, unless resolved or specified eslint to ignore using the `eslint-ignore` syntax.
>
This config extends the following plugins -
- [eslint/recommended](https://eslint.org/docs/latest/rules/)
Expand Down Expand Up @@ -56,15 +67,28 @@ To add a new rule, turn off or modify the existing list of rules, append the `ru
}
}
```

To disable one or more rules throughout the file,
```
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any */
```

To disable one or more rules in the next line,

```
/* eslint-disable-next-line <rule1>, <rule2> */
```

fyi, `// eslint-disable-next-line <rule1>, <rule2> ` won't work.
> [!CAUTION]
> The syntax below won't work
> ```
> // eslint-disable-next-line <rule1>, <rule2>
> or
> /** eslint-disable-next-line @typescript-eslint/no-unused-vars */
> ```
>
Add *"lint"* command to your `package.json` file.
Add *"lint"* command to your `package.json` file.

```
npm pkg set scripts.lint="eslint --fix ."
Expand Down Expand Up @@ -103,92 +127,109 @@ View the complete list of rules
- [react](https://github.com/jsx-eslint/eslint-plugin-react/tree/master/docs/rules)
- [jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/tree/main/docs/rules)

⚠️ ***WARNING*** - avoid using this style of code.
***ERROR*** - your code is not as per industry standards.
🔧 ***FLEXIBLE*** - specified or overwritten default cases for rules.
⚠️ ***WARNING*** - write your code neatly please, hopefully, eslint will clean up the mess.
***ERROR*** - you should AVOID this coding practice.
🔧 ***CONFIGURE*** - specified or overwritten default case for a rule.

## **stylistic rules**

All rule names start with `@stylistic/` prefix.

|Rule Name|⚠️||🔧|
|-|-|-|-|
|[array-bracket-newline](https://eslint.style/rules/default/array-bracket-newline)||✔️| { multiline: true, minItems: 4 } |
|[arrow-parens](https://eslint.style/rules/default/arrow-parens)|✔️|| as-needed|
|[arrow-spacing](https://eslint.style/rules/default/arrow-spacing)||✔️||
|[block-spacing](https://eslint.style/rules/default/block-spacing)||✔️||
|[brace-style](https://eslint.style/rules/default/brace-style)||✔️||
|[comma-dangle](https://eslint.style/rules/default/comma-dangle)|✔️|| always-multiline |
|[comma-spacing](https://eslint.style/rules/default/comma-spacing)||✔️||
|[eol-last](https://eslint.style/rules/default/eol-last)|✔️|||
|[function-call-argument-newline](https://eslint.style/rules/default/function-call-argument-newline)||✔️| consistent |
|[function-paren-newline](https://eslint.style/rules/default/function-paren-newline)||✔️| consistent |
|[indent](https://eslint.style/rules/default/indent)||✔️| 2 |
|[jsx-closing-bracket-location](https://eslint.style/rules/default/jsx-closing-bracket-location)||✔️||
|[jsx-closing-tag-location](https://eslint.style/rules/default/jsx-closing-tag-location)||✔️||
|[jsx-curly-newline](https://eslint.style/rules/default/jsx-curly-newline)|✔️|| consistent |
|[jsx-curly-spacing](https://eslint.style/rules/default/jsx-curly-spacing)||✔️||
|[jsx-equals-spacing](https://eslint.style/rules/default/jsx-curly-spacing)||✔️||
|[jsx-first-prop-new-line](https://eslint.style/rules/default/jsx-first-prop-new-line)|✔️|| multiline-multiprop |
|[jsx-indent](https://eslint.style/rules/default/jsx-indent)||✔️| 2 |
|[jsx-indent-props](https://eslint.style/rules/default/jsx-indent-props)||✔️| 2 |
|[jsx-one-expression-per-line](https://eslint.style/rules/default/jsx-one-expression-per-line)|✔️|| { allow: 'literal' } |
|[jsx-props-no-multi-spaces](https://eslint.style/rules/default/jsx-props-no-multi-spaces)||✔️||
|[jsx-quotes](https://eslint.style/rules/default/jsx-quotes)|✔️|| prefer-double |
|[jsx-self-closing-comp](https://eslint.style/rules/default/jsx-self-closing-comp)||✔️||
|[jsx-wrap-multilines](https://eslint.style/rules/default/jsx-wrap-multilines)|✔️|| parens-new-line |
|[key-spacing](https://eslint.style/rules/default/key-spacing)||✔️||
|[linebreak-style](https://eslint.style/rules/default/linebreak-style)|✔️|||
|[lines-around-comment](https://eslint.style/rules/default/lines-around-comment)|✔️|||
|[no-extra-semi](https://eslint.style/rules/default/no-extra-semi)||✔️||
|[no-floating-decimal](https://eslint.style/rules/default/no-floating-decimal)||✔️||
|[no-mixed-operators](https://eslint.style/rules/default/no-mixed-operators)||✔️||
|[no-mixed-spaces-and-tabs](https://eslint.style/rules/default/no-mixed-spaces-and-tabs)|✔️|||
|[no-multi-spaces](https://eslint.style/rules/default/no-multi-spaces)||✔️||
|[no-multiple-empty-lines](https://eslint.style/rules/default/no-multiple-empty-lines)||✔️||
|[no-trailing-spaces](https://eslint.style/rules/default/no-trailing-spaces)|✔️|||
|[object-curly-newline](https://eslint.style/rules/default/object-curly-newline)||✔️| { multiline: true } |
|[object-curly-spacing](https://eslint.style/rules/default/object-curly-spacing)||✔️| always |
|[object-property-newline](https://eslint.style/rulesobject-property-newline)|✔️|||
|[operator-linebreak](https://eslint.style/rules/default/operator-linebreak)||✔️| before |
|[quotes](https://eslint.style/rules/default/quotes)||✔️| single |
|[semi-spacing](https://eslint.style/rules/default/semi-spacing)|✔️|||
|[spaced-comment](https://eslint.style/rules/default/spaced-comment)|✔️|||
|[switch-colon-spacing](https://eslint.style/rules/default/switch-colon-spacing)|✔️|||
|[template-curly-spacing](https://eslint.style/rules/default/template-curly-spacing)||✔️||
|[type-annotation-spacing](https://eslint.style/rules/default/type-annotation-spacing)|✔️|||
|[type-generic-spacing](https://eslint.style/rules/default/type-generic-spacing)||✔️||
|[type-named-tuple-spacing](https://eslint.style/rules/default/type-named-tuple-spacing)||✔️||
|[wrap-regex](https://eslint.style/rules/default/wrap-regex)||✔️||
>[!NOTE]
> Starting `v1.0.3` almost all of the `stylistic` rules will default to warn. These can be easily fixed by running linting and do not require the attention of the developer.
>
|Rule Name|🔧|
|-|-|
|[array-bracket-newline](https://eslint.style/rules/default/array-bracket-newline)| { multiline: true, minItems: 4 } |
|[array-bracket-spacing](https://eslint.style/rules/default/array-bracket-spacing)||
|[arrow-parens](https://eslint.style/rules/default/arrow-parens)| as-needed |
|[arrow-spacing](https://eslint.style/rules/default/arrow-spacing)||
|[block-spacing](https://eslint.style/rules/default/block-spacing)||
|[brace-style](https://eslint.style/rules/default/brace-style)||
|[comma-dangle](https://eslint.style/rules/default/comma-dangle)|| always-multiline |
|[comma-spacing](https://eslint.style/rules/default/comma-spacing)||
|[eol-last](https://eslint.style/rules/default/eol-last)||
|[function-call-argument-newline](https://eslint.style/rules/default/function-call-argument-newline)| consistent |
|[function-paren-newline](https://eslint.style/rules/default/function-paren-newline)|| consistent |
|[indent](https://eslint.style/rules/default/indent)|| 2 |
|[indent-binary-ops](https://eslint.style/rules/default/indent-binary-ops)| 2 |
|[jsx-closing-bracket-location](https://eslint.style/rules/default/jsx-closing-bracket-location)||
|[jsx-closing-tag-location](https://eslint.style/rules/default/jsx-closing-tag-location)||
|[jsx-curly-newline](https://eslint.style/rules/default/jsx-curly-newline)|consistent |
|[jsx-curly-spacing](https://eslint.style/rules/default/jsx-curly-spacing)||
|[jsx-equals-spacing](https://eslint.style/rules/default/jsx-curly-spacing)||
|[jsx-first-prop-new-line](https://eslint.style/rules/default/jsx-first-prop-new-line)| multiline-multiprop |
|[jsx-indent](https://eslint.style/rules/default/jsx-indent)| 2 |
|[jsx-indent-props](https://eslint.style/rules/default/jsx-indent-props)| 2 |
|[jsx-one-expression-per-line](https://eslint.style/rules/default/jsx-one-expression-per-line)| { allow: 'literal' } |
|[jsx-props-no-multi-spaces](https://eslint.style/rules/default/jsx-props-no-multi-spaces)||
|[jsx-quotes](https://eslint.style/rules/default/jsx-quotes)| prefer-double |
|[jsx-self-closing-comp](https://eslint.style/rules/default/jsx-self-closing-comp)||
|[jsx-wrap-multilines](https://eslint.style/rules/default/jsx-wrap-multilines)| parens-new-line |
|[key-spacing](https://eslint.style/rules/default/key-spacing)||
|[linebreak-style](https://eslint.style/rules/default/linebreak-style)||
|[no-extra-semi](https://eslint.style/rules/default/no-extra-semi)||
|[no-floating-decimal](https://eslint.style/rules/default/no-floating-decimal)||
|[no-mixed-spaces-and-tabs](https://eslint.style/rules/default/no-mixed-spaces-and-tabs)||
|[no-multi-spaces](https://eslint.style/rules/default/no-multi-spaces)||
|[no-multiple-empty-lines](https://eslint.style/rules/default/no-multiple-empty-lines)||
|[no-trailing-spaces](https://eslint.style/rules/default/no-trailing-spaces)||
|[object-curly-newline](https://eslint.style/rules/default/object-curly-newline)| { multiline: true } |
|[object-curly-spacing](https://eslint.style/rules/default/object-curly-spacing)| always |
|[object-property-newline](https://eslint.style/rulesobject-property-newline)||
|[operator-linebreak](https://eslint.style/rules/default/operator-linebreak)| before |
|[quotes](https://eslint.style/rules/default/quotes)| single |
|[rest-spread-spacing](https://eslint.style/rules/default/rest-spread-spacing)||
|[space-unary-ops](https://eslint.style/rules/default/sace-unary-ops)||
|[semi-spacing](https://eslint.style/rules/default/semi-spacing)||
|[spaced-comment](https://eslint.style/rules/default/spaced-comment)||
|[switch-colon-spacing](https://eslint.style/rules/default/switch-colon-spacing)||
|[template-curly-spacing](https://eslint.style/rules/default/template-curly-spacing)||
|[type-annotation-spacing](https://eslint.style/rules/default/type-annotation-spacing)||
|[type-generic-spacing](https://eslint.style/rules/default/type-generic-spacing)||
|[type-named-tuple-spacing](https://eslint.style/rules/default/type-named-tuple-spacing)||
|[wrap-regex](https://eslint.style/rules/default/wrap-regex)||

Only the stylistic rule(s) listed below will give an error and will have to be manually fixed.

| Rule Name |
|-|
|[no-mixed-operators](https://eslint.style/rules/default/no-mixed-operators)|


## **eslint rules**

|Rule Name|⚠️||🔧|
|-|-|-|-|
|[array-callback-return](https://eslint.org/docs/latest/rules/array-callback-return)|✔️|||
|[arrow-body-style](https://eslint.org/docs/latest/rules/arrow-body-style)|✔️|| as-needed |
|[curly](https://eslint.org/docs/latest/rules/curly)|✔️|||
|[default-case](https://eslint.org/docs/latest/rules/default-case)|✔️|||
|[default-param-last](https://eslint.org/docs/latest/rules/default-param-last)|✔️|||
|[dot-notation](https://eslint.org/docs/latest/rules/dot-notation)||✔️||
|[eqeqeq](https://eslint.org/docs/latest/rules/eqeqeq)||✔️||
|[func-names](https://eslint.org/docs/latest/rules/)|✔️|| as-needed |
|[no-await-in-loop](https://eslint.org/docs/latest/rules/no-await-in-loop)|✔️|||
|[no-debugger](https://eslint.org/docs/latest/rules/no-debugger)|✔️|||
|[no-eq-null](https://eslint.org/docs/latest/rules/no-eq-null)||✔️||
|[no-inline-comments](https://eslint.org/docs/latest/rules/no-inline-comments)|✔️|||
|[no-plusplus](https://eslint.org/docs/latest/rules/no-plusplus)|✔️|||
|[no-unreachable](https://eslint.org/docs/latest/rules/no-unreachable)|✔️|||
|[no-use-before-define](https://eslint.org/docs/latest/rules/no-use-before-define)||✔️||
|[no-var](https://eslint.org/docs/latest/rules/no-var)|✔️|||
|[object-shorthand](https://eslint.org/docs/latest/rules/object-shorthand)||✔️||
|[prefer-const](https://eslint.org/docs/latest/rules/prefer-const)||✔️||
|[prefer-exponentiation-operator](https://eslint.org/docs/latest/rules/prefer-exponentiation-operator)|✔️|||
|[prefer-promise-reject-errors](https://eslint.org/docs/latest/rules/prefer-promise-reject-errors)|✔️|||
|[prefer-rest-params](https://eslint.org/docs/latest/rules/prefer-rest-params)||✔️||
|[require-await](https://eslint.org/docs/latest/rules/require-await)||✔️||
|[semi](https://eslint.org/docs/latest/rules/semi)||✔️||
|[use-isnan](https://eslint.org/docs/latest/rules/use-isnan)|✔️|||
|Rule Name|🔧|
|-|-|
|[array-callback-return](https://eslint.org/docs/latest/rules/array-callback-return)||
|[arrow-body-style](https://eslint.org/docs/latest/rules/arrow-body-style)|| as-needed |
|[curly](https://eslint.org/docs/latest/rules/curly)||
|[dot-notation](https://eslint.org/docs/latest/rules/dot-notation)||
|[func-names](https://eslint.org/docs/latest/rules/)| as-needed |
|[no-debugger](https://eslint.org/docs/latest/rules/no-debugger)||
|[no-inline-comments](https://eslint.org/docs/latest/rules/no-inline-comments)||
|[no-plusplus](https://eslint.org/docs/latest/rules/no-plusplus)||
|[no-unreachable](https://eslint.org/docs/latest/rules/no-unreachable)||
|[no-var](https://eslint.org/docs/latest/rules/no-var)||
|[object-shorthand](https://eslint.org/docs/latest/rules/object-shorthand)||
|[prefer-const](https://eslint.org/docs/latest/rules/prefer-const)||
|[prefer-exponentiation-operator](https://eslint.org/docs/latest/rules/prefer-exponentiation-operator)||
|[prefer-promise-reject-errors](https://eslint.org/docs/latest/rules/prefer-promise-reject-errors)||
|[semi](https://eslint.org/docs/latest/rules/semi)||
|[use-isnan](https://eslint.org/docs/latest/rules/use-isnan)||

Only the eslint rule(s) listed below will give an error and will have to be manually fixed.

| Rule Name |
|-|
|[eqeqeq](https://eslint.org/docs/latest/rules/eqeqeq)|
|[no-await-in-loop](https://eslint.org/docs/latest/rules/no-await-in-loop)|
|[no-eq-null](https://eslint.org/docs/latest/rules/no-eq-null)|
|[no-use-before-define](https://eslint.org/docs/latest/rules/no-use-before-define)|
|[default-case](https://eslint.org/docs/latest/rules/default-case)|
|[prefer-rest-params](https://eslint.org/docs/latest/rules/prefer-rest-params)|
|[require-await](https://eslint.org/docs/latest/rules/require-await)|

## **typescript-eslint rules**

Expand Down Expand Up @@ -216,13 +257,15 @@ Enabled below rules that are not enabled by default in the `jsx-a11y/recommended

You will need to manually add them in the `rules` of your .eslintrc, if needed.

| Rule Name | reason |
| Rule Name | Reason |
|-|-|
|[@stylistic/lines-around-comment](https://eslint.style/rules/default/lines-around-comment)| Sometimes reqd, when writing block comments above functions, but don't need when writing block comment between 2 lines of code |
|[@typescript-eslint/no-this-alias](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/no-this-alias.md) | sometimes `this` is reqd in fn context. eg. MongooseSchema.pre() |
|[default-param-last](https://eslint.org/docs/latest/rules/default-param-last)| personal preference of the dev |
|[id-denylist](https://eslint.org/docs/latest/rules/id-denylist) | use if required. eg. "id-denylist": ["warn", "e", "cb", 'callback']|
[id-length](https://eslint.org/docs/latest/rules/id-length)| warning when using `_` for unused vars |
|[multiline-comment-style](https://eslint.org/docs/latest/rules/multiline-comment-style)| the default setting `starred-block` read commented code as a comment itself, which made it difficult to uncomment the code
|[no-shadow](https://eslint.org/docs/latest/rules/no-shadow) | gave unwanted warnings when using enums |
|[no-this-alias](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/n-this-alias.md) | sometimes `this` is reqd in fn context. eg. MongooseSchema.pre() |
|[no-unused-vars](https://eslint.org/docs/latest/rules/no-unused-vars) | `@typescript-eslint/no-unused-vars` does it better |
|[react/react-in-jsx-scope](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md) | react v17+ doesn't require `import React from react` |
|[sort-keys](https://eslint.org/docs/latest/rules/sort-keys)| sometimes more crucial object keys should come first |
Expand Down
Loading

0 comments on commit a7283c3

Please sign in to comment.