Skip to content

Commit

Permalink
chore: Update dependencies
Browse files Browse the repository at this point in the history
- Update to @babel/eslint-parser and @babel/eslint-plugin. eslint-plugin-babel will be deprecated (see https://babel.dev/blog/2020/07/13/the-state-of-babel-eslint).
- Add parsers as regular dependencies. They don't need to be installed by the project according to the ESLint docs (see https://eslint.org/docs/developer-guide/shareable-configs)
- Add dependencies for TypeScript projects as default dependencies. Since most of our projects are written in TypeScript, this seems to be a reasonable default

BREAKING CHANGE: You should have @babel/core as your project dependency now, see https://babel.dev/blog/2020/07/13/the-state-of-babel-eslint#the-present

BREAKING CHANGE: You can remove TypeScript-specific ESLint dependencies, especially @typescript-eslint/parser. They should ship with the config.
  • Loading branch information
jhnns committed Jan 31, 2021
1 parent c95c58d commit a957c21
Show file tree
Hide file tree
Showing 9 changed files with 354 additions and 322 deletions.
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ There are presets for the most common setups:
### Prettier + TypeScript

```
npm i eslint eslint-config-peerigon @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-prefer-arrow --save-dev
npm i eslint eslint-config-peerigon --save-dev
```

```js
Expand All @@ -70,7 +70,7 @@ npm i eslint eslint-config-peerigon @typescript-eslint/eslint-plugin @typescript
### Prettier + TypeScript + React

```
npm i eslint eslint-config-peerigon @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-prefer-arrow eslint-plugin-react eslint-plugin-jsx-a11y eslint-plugin-react-hooks --save-dev
npm i eslint eslint-config-peerigon eslint-plugin-react eslint-plugin-jsx-a11y eslint-plugin-react-hooks --save-dev
```

```js
Expand All @@ -95,7 +95,7 @@ npm i eslint eslint-config-peerigon @typescript-eslint/eslint-plugin @typescript
### Prettier + TypeScript + Node

```
npm i eslint eslint-config-peerigon @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-prefer-arrow eslint-plugin-node --save-dev
npm i eslint eslint-config-peerigon eslint-plugin-node --save-dev
```

```js
Expand Down Expand Up @@ -248,7 +248,7 @@ module.exports = {
/* ... */
rules: {
// The API uses snake_case as properties
"babel/camelcase": ["warn", {
"camelcase": ["warn", {
...options["camelcase"],
properties: "never"
}]
Expand Down Expand Up @@ -361,12 +361,6 @@ These rules are also applicable in other JSX environments, like [Preact](https:/

### [`peerigon/typescript`](typescript.js)

**Important: Requires [`@typescript-eslint/eslint-plugin`](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin) and [`@typescript-eslint/parser`](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/parser) as project dependency.**

```
npm i @typescript-eslint/eslint-plugin @typescript-eslint/parser --save-dev
```

Rules for [TypeScript](https://www.typescriptlang.org/).

**⚠️ Attention:** These rules require your `tsconfig.json`. Specify the path in `parserOptions.project` (see also [here](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/README.md#parseroptionsproject) for more information). *The path should be relative to the folder where `eslint` is executed.*
Expand Down
32 changes: 13 additions & 19 deletions base.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const tests = require("./tests.js");
const {allow, ...camelcase} = options["camelcase"];

module.exports = {
parser: "babel-eslint",
parser: "@babel/eslint-parser",
env: {
es6: true,
},
Expand All @@ -19,10 +19,10 @@ module.exports = {
ecmaVersion: 2020
},
plugins: [
"@babel",
"import",
"optimize-regex",
"promise",
"babel",
"no-unsafe-regex"
],
extends: [
Expand All @@ -34,6 +34,14 @@ module.exports = {
reportUnusedDisableDirectives: true,
rules: {
/* eslint-enable sort-keys */
"@babel/new-cap": "warn",
"@babel/no-invalid-this": "warn",
"@babel/no-unused-expressions": [
"warn",
options["no-unused-expressions"],
],
"@babel/object-curly-spacing": ["warn", "never"],
"@babel/semi": "warn",
"accessor-pairs": [
"off",
{
Expand All @@ -59,17 +67,6 @@ module.exports = {
},
], // http://eslint.org/docs/rules/arrow-spacing
// https://github.com/babel/eslint-plugin-babel
"babel/camelcase": ["warn", camelcase],
"babel/new-cap": "warn",
"babel/no-invalid-this": "warn",
"babel/no-unused-expressions": [
"warn",
options["no-unused-expressions"],
],
"babel/object-curly-spacing": ["warn", "never"],
"babel/quotes": ["warn", "double", options.quotes],
"babel/semi": "warn",
"babel/valid-typeof": "error",
"block-scoped-var": "error", // http://eslint.org/docs/rules/block-scoped-var
"block-spacing": "warn", // http://eslint.org/docs/rules/block-spacing
"brace-style": [
Expand All @@ -79,8 +76,7 @@ module.exports = {
"allowSingleLine": false,
},
], // http://eslint.org/docs/rules/brace-style
// Handled by babel/camelcase
"camelcase": "off", // http://eslint.org/docs/rules/camelcase
"camelcase": ["warn", camelcase], // http://eslint.org/docs/rules/camelcase
"capitalized-comments": ["off"], // http://eslint.org/docs/rules/capitalized-comments
"class-methods-use-this": ["off"], // http://eslint.org/docs/rules/class-methods-use-this
"comma-dangle": [
Expand Down Expand Up @@ -526,8 +522,7 @@ module.exports = {
"promise/prefer-await-to-then": "off", // https://github.com/xjamundx/eslint-plugin-promise/blob/master/docs/rules/prefer-await-to-then.md
"promise/valid-params": "warn", // https://github.com/xjamundx/eslint-plugin-promise/blob/master/docs/rules/valid-params.md
"quote-props": ["warn", "as-needed"], // http://eslint.org/docs/rules/quote-props
// Handled by babel/quotes
"quotes": ["off", "double", options.quotes], // http://eslint.org/docs/rules/quotes
"quotes": ["warn", "double", options.quotes],// http://eslint.org/docs/rules/quotes
"radix": "off", // http://eslint.org/docs/rules/radix
// This rule would be nice but there are too many false positives :(
"require-atomic-updates": "off", // https://eslint.org/docs/rules/require-atomic-updates
Expand Down Expand Up @@ -579,8 +574,7 @@ module.exports = {
"template-curly-spacing": ["warn", "never"], // http://eslint.org/docs/rules/template-curly-spacing
"template-tag-spacing": ["warn", "never"], // http://eslint.org/docs/rules/template-tag-spacing
"unicode-bom": ["warn", "never"], // http://eslint.org/docs/rules/unicode-bom
// Handled by babel/valid-typeof
"valid-typeof": "off", // http://eslint.org/docs/rules/valid-typeof
"valid-typeof": "error", // http://eslint.org/docs/rules/valid-typeof
"vars-on-top": "warn", // http://eslint.org/docs/rules/vars-on-top
"wrap-iife": "off", // http://eslint.org/docs/rules/wrap-iife
"wrap-regex": "off", // http://eslint.org/docs/rules/wrap-regex
Expand Down
2 changes: 1 addition & 1 deletion flowtype.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable sort-keys */

module.exports = {
parser: "babel-eslint",
parser: "@babel/eslint-parser",
plugins: [
"flowtype"
],
Expand Down
5 changes: 5 additions & 0 deletions node.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ module.exports = {
env: {
node: true
},
parserOptions: {
// Most Node projects don't use Babel to preprocess JS files
// Requiring them would be annoying
requireConfigFile: false,
},
rules: {
/* eslint-enable sort-keys */
"node/callback-return": "warn", // https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/callback-return.md
Expand Down
Loading

0 comments on commit a957c21

Please sign in to comment.