包详细信息

eslint-config-peerigon

peerigon12.2kUnlicense不推荐使用40.0.0

This package has been replaced by @peerigon/configs

Peerigon coding rules as eslint config

eslint, peerigon, coding, rules

自述文件

eslint-config-peerigon

Peerigon coding rules as ESLint config.

Version on NPM Semantically released Monthly downloads on NPM
License

Linting and formatting rules are always a balance between

  • ease of reading
  • ease of refactoring
  • ease of writing.

We think that

  • code is read more often than refactored
  • and refactored more often than written from scratch.

Our linting rules have been designed with these assumptions in mind.

Table of contents

Quick start

Recommended configuration in your package.json:

{
    "scripts": {
        "test:lint": "eslint --max-warnings 0 --cache --ext js,jsx,cjs,mjs,ts,tsx --ignore-path .gitignore .",
        "posttest": "npm run test:lint"
    }
}

We also offer a Prettier config that matches our ESLint config. Create a .prettierrc.json in your project with the following content:

"eslint-config-peerigon/prettier.config.js"

There are presets for the most common setups:

TypeScript

npm i eslint eslint-config-peerigon --save-dev
{
    "extends": [
        "peerigon/presets/typescript.js"
    ],
    "env": {
        "node": true
    },
    "root": true
}

TypeScript + React

npm i eslint eslint-config-peerigon eslint-plugin-react eslint-plugin-jsx-a11y eslint-plugin-react-hooks --save-dev
{
    "extends": [
        "peerigon/presets/typescript-react.js"
    ],
    "env": {
        "node": true,
        "browser": true
    },
    "root": true
}

TypeScript + Node

npm i eslint eslint-config-peerigon eslint-plugin-n --save-dev
{
    "extends": [
        "peerigon/presets/typescript-node.js"
    ],
    "root": true
}

Practical guide

Disabling rules

Try to disable as less rules as possible. In most cases it's best to just write

// eslint-disable-next-line [rule-code]

where [rule-code] is the code that is displayed along the error message. Disabling the next line is usually better because it resists Prettier reformatting.

Sometimes it makes sense to disable a rule within a specifc file. In that case you can put the following snippet at the beginning of the file:

/* eslint-disable [rule-code] */

If you don't agree with a rule, please do not just disable the rule. Often there are good reasons and the current setting is the result of years of experience. It's better to create an issue here to start a discussion about the pros and cons of a rule.

Different styles

We acknowledge that there are certain rules where there are no actual pros and cons or where there is no clear winner. You just have to decide for one style and stick with it. We also know that some rules make sense in one project, but don't make sense in another project. That's why we also provide a list of accepted custom styles (see also this discussion) which you can pick.

VSCode

This is our recommended VSCode configuration using the Prettier extension. Adjust it to the needs of your particular project:

{
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
    }
}

Experimental syntax using Babel

If you're using Babel you should set requireConfigFile: true in your ESLint config. ESLint will then use your babel.config.json.

{
    "parserOptions": { "requireConfigFile": true },
}

Naming conventions for properties

Sometimes we're not in full control over the naming conventions in our codebase, for instance if data is coming from a foreign API. While it often is preferable to transform property names into camelCase, it might not be practical. In these situations you can disable the check for properties like this:

const options = require("eslint-config-peerigon/options.js");

module.exports = {
    /* ... */
    rules: {
        // The API uses snake_case as properties
        camelcase: [
            "warn",
            {
                ...options["camelcase"],
                properties: "never",
            },
        ],
    },
};

In TypeScript projects:

const options = require("eslint-config-peerigon/options.js");

module.exports = {
    /* ... */
    rules: {
        // The API uses snake_case as properties
        "@typescript-eslint/naming-convention": [
            "warn",
            options["@typescript-eslint/naming-convention"].ignoreProperties,
            ...options["@typescript-eslint/naming-convention"].defaultRules,
        ],
    },
};

Provided configs

peerigon

Base rules for every project. You should always add these rules.

npm i eslint eslint-config-peerigon --save-dev

These rules assume a modern project with full ES2015 support, including ES modules. For specific environments like Node.js or old JS engines, see below. The base rules do not define an env, so you might want to do that for yourself to enable specific globals.

Add an .eslintrc.json to the project's root folder:

{
    "extends": [
        // Base rules for every project
        "peerigon"
    ],
    // Do not search for further eslint configs in upper directories
    "root": true,
    // If you're using Babel, you should set requireConfigFile: true
    // ESLint will then use your babel.config.json.
    // "parserOptions": { "requireConfigFile": true },
}

The base rules use the eslint-plugin-import to resolve imports. Although it's possible to define custom resolvers, it's highly discouraged to deviate from the common Node.js resolving algorithm. Other tools like linters and intellisense don't work reliably when you change the resolver.

peerigon/typescript

Rules for TypeScript.

{
    "extends": [
        "peerigon",
        "peerigon/typescript",
        // Arrow functions are preferred with TypeScript
        // See https://github.com/peerigon/eslint-config-peerigon/issues/23#issuecomment-472614432
        "peerigon/styles/prefer-arrow"
    ],
    "root": true,
}

You need to add --ext js,jsx,cjs,mjs,ts,tsx to the test:lint script:

{
    "scripts": {
        "test:lint": "eslint --max-warnings 0 --cache --ext js,jsx,cjs,mjs,ts,tsx --ignore-path .gitignore ."
    }
}

We recommend using peerigon/styles/prefer-arrow because arrow functions (or function expressions in general) can leverage TypeScript's contextual typing.

peerigon/node

Important: Requires eslint-plugin-n.

npm i eslint-plugin-n --save-dev
{
    "extends": [
        "peerigon",
        "peerigon/node"
    ],
    // Setting env.node = true is not necessary, this is already done by peerigon/node
    "root": true
}

peerigon/react

Important: Requires eslint-plugin-react, eslint-plugin-jsx-a11y and eslint-plugin-react-hooks as project dependency.

npm i eslint-plugin-react eslint-plugin-jsx-a11y eslint-plugin-react-hooks --save-dev

Rules for React development, including accessibility rules. These rules are also applicable in other JSX environments, like Preact:

{
    "extends": [
        "peerigon",
        "peerigon/react"
    ],
    "root": true
}

We recommend using peerigon/styles/react-jsx-no-literals if you're using i18n in your project. You can use peerigon/styles/react-jsx-no-bind if you're using memo and shouldComponentUpdate a lot.

peerigon/jsdoc

Important: Requires eslint-plugin-jsdoc as project dependency.

npm i eslint-plugin-jsdoc --save-dev

Makes sure that JSDoc annotations are written in a standard-compliant and uniform way.

{
    "extends": [
        "peerigon",
        "peerigon/jsdoc"
    ],
    "root": true
}

Styles

The following rules enable specific writing styles. Use them as you prefer.

peerigon/styles/prefer-arrow

Enforces arrow function expressions instead of function declarations (see #23). Regular functions are still allowed as methods in objects or classes.

    "extends": [
        "peerigon",
        "peerigon/styles/prefer-arrow"
    ],

peerigon/styles/no-default-export

Forbids usage of export default. When using default exports, it becomes harder to name classes or functions consistently throughout the codebase since every module can pick its own name for the imported thing. Nicholas C. Zakas, the creator of ESLint, wrote an article with more compelling arguments why he stopped using export default.

    "extends": [
        "peerigon",
        "peerigon/styles/no-default-export"
    ],

Please note: This rule is disabled in .jsx and .tsx files because React components are usually exported via export default. React.lazy even expects the lazy loaded component to be exported as default.

peerigon/styles/no-null

Important: Requires eslint-plugin-no-null as project dependency.

npm i eslint-plugin-no-null --save-dev

Forbids the usage of null. In a codebase it's often better to use a single non-value to represent the absence of a value. With the rise of default parameters and destructuring defaults, JavaScript developed a clear tendency towards undefined. This issue summarizes the arguments (and trade-offs) of null vs. undefined.

    "extends": [
        "peerigon",
        "peerigon/styles/no-null"
    ],

Please note: If you use this rule, you will probably still need a single null value which you can refer to whenever you need to use null because of third-party code:

// eslint-disable-next-line no-null/no-null
export const NULL = null;

peerigon/styles/prefer-interface

Important: Use it in combination with peerigon/typescript.

Prefer interface over type.

    "extends": [
        "peerigon",
        "peerigon/typescript",
        "peerigon/styles/prefer-interface"
    ],

peerigon/styles/react-jsx-no-bind

Important: Use it in combination with peerigon/react.

Depending on the way you write your components, it might be not ok to create functions during render(). Use it if you're using things like React.memo() or shouldComponentUpdate a lot.

    "extends": [
        "peerigon",
        "peerigon/react",
        "peerigon/styles/react-jsx-no-bind"
    ],

peerigon/styles/react-jsx-no-literals

Important: Use it in combination with peerigon/react.

Use this style if you're using i18n. It prevents people from putting raw strings in components.

    "extends": [
        "peerigon",
        "peerigon/react",
        "peerigon/styles/react-jsx-no-literals"
    ],

It disallows this:

const Hello = <div>test</div>;

As an escape hatch, this is still allowed:

const Hello = <div>{"test"}</div>;

peerigon/styles/prefer-array-shorthand

Important: Use it in combination with peerigon/typescript.

Enforces typescript arrays to use the shorthand array-style instead of the generic style.

    "extends": [
        "peerigon",
        "peerigon/typescript",
        "peerigon/styles/prefer-array-shorthand"
    ],

It enforces this:

const foo: string[] = [];

instead of

const foo: Array<string> = [];

License

Unlicense

Sponsors

更新日志

40.0.0 (2024-09-13)

Features

BREAKING CHANGES

  • Updated the prettier config to also sort imports.

39.2.0 (2024-07-20)

Features

39.1.0 (2024-07-09)

Features

39.0.1 (2024-04-29)

Bug Fixes

  • Disable @trivago/prettier-plugin-sort-imports temporarily (#142) (501c74e)

39.0.0 (2024-03-22)

Features

  • Replace deprecated eslint-plugin-node with eslint-plugin-n (#119) (f0d0521)

BREAKING CHANGES

  • Since we switched from eslint-plugin-node to eslint-plugin-n, this may introduce new ESLint errors in Node projects.

38.0.0 (2024-03-22)

chore

  • Update dependencies to latest versions (#116) (20ac5cb)

BREAKING CHANGES

  • Update @typescript-eslint/eslint-plugin and @typescript-eslint/parser from 6.x to 7.x

37.2.0 (2024-03-22)

Features

  • Add shared Prettier config for import sorting (cb1ba16)

37.1.0 (2024-01-17)

Features

37.0.2 (2023-11-08)

Bug Fixes

  • Relax logical-assignment-operators rule again (38c984f)

37.0.1 (2023-11-08)

Bug Fixes

  • Relax logical-assignment-operators rule (25fe184)

37.0.0 (2023-11-06)

Features

BREAKING CHANGES

  • Some new base rules have been introduced which might produce linting errors.
  • The prettier- prefix has been removed from all preset files: peerigon/presets/prettier-typescript.js becomes peerigon/presets/typescript.js, peerigon/presets/prettier-typescript-react.js becomes peerigon/presets/typescript-react.js and peerigon/presets/prettier-typescript-node.js becomes peerigon/presets/typescript-node.js
  • All formatting rules have been removed as they have been deprecated by ESLint (see eslint.org/blog/2023/10/deprecating-formatting-rules). We won't switch to @stylistic/eslint-plugin-js as code formatting should be done by Prettier nowadays.

37.0.0-beta.4 (2023-11-06)

Features

37.0.0-beta.3 (2023-11-06)

Features

BREAKING CHANGES

  • Some new base rules have been introduced which might produce linting errors.

37.0.0-beta.2 (2023-11-06)

Features

  • Remove special handling for Prettier (#104) (068b731)

BREAKING CHANGES

  • The prettier- prefix has been removed from all preset files: peerigon/presets/prettier-typescript.js becomes peerigon/presets/typescript.js, peerigon/presets/prettier-typescript-react.js becomes peerigon/presets/typescript-react.js and peerigon/presets/prettier-typescript-node.js becomes peerigon/presets/typescript-node.js

37.0.0-beta.1 (2023-11-06)

Features

BREAKING CHANGES

  • All formatting rules have been removed as they have been deprecated by ESLint (see eslint.org/blog/2023/10/deprecating-formatting-rules). We won't switch to @stylistic/eslint-plugin-js as code formatting should be done by Prettier nowadays.

36.0.0 (2023-10-27)

chore

BREAKING CHANGES

  • Major version bumps of transitive dependencies @typescript-eslint/eslint-plugin, @typescript-eslint/parser and eslint-config-prettier

35.0.0 (2023-09-06)

Features

  • TypeScript: Change parserOptions defaults for resolving tsconfig.json (21aa03c)

BREAKING CHANGES

34.0.0 (2023-05-28)

Features

BREAKING CHANGES

  • We've removed official Node 14 and 16 support. We don't know of any breaking change though, so it may still work with older Node versions.
  • Removed old ES5 rules as they aren't used by any current projects anymore.
  • We've removed all rules related to FlowType as they haven't been maintained for quite a while.

33.3.0 (2022-05-04)

Features

  • Relax lint rules in tests (52e3f2e)

33.2.5 (2022-04-02)

Bug Fixes

  • TypeScript: Relax @typescript-eslint/naming-convention (36e61df)

33.2.4 (2022-01-23)

Bug Fixes

33.2.3 (2022-01-23)

Bug Fixes

  • Relax TypeScript rules for d.ts files (ebbd53d)

33.2.2 (2021-12-24)

Bug Fixes

  • TypeScript: Disable import/no-default-export for d.ts files (f6f0a2a)

33.2.1 (2021-12-22)

Bug Fixes

  • TypeScript: Disable "@typescript-eslint/no-unsafe-argument" (8022f7e)

33.2.0 (2021-12-14)

Features

33.1.0 (2021-12-14)

Features

  • Disable import/no-anonymous-default-export in config files (e5f05c1)

33.0.1 (2021-12-06)

Bug Fixes

33.0.0 (2021-11-12)

Features

  • react: Add support for new JSX transformer (07c01a0)
  • typescript: Simplify typescript setup (763644a)

BREAKING CHANGES

  • typescript: The tsconfig.json path is not relative to the CWD now, but to your package.json. In most cases you don't need to change anything. If your tsconfig.json is not next to your package.json, you need to specify parserOptions.project as described in the README.
  • react: This assumes that you're using at least React 17. In React 16, things will break if you omit the React import. See also https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html

32.0.1 (2021-11-12)

Bug Fixes

  • Switch parser ecmaVersion to "latest" (a08dde8)

32.0.0 (2021-11-05)

Features

BREAKING CHANGES

  • ESLint >= 8.1.0 and Node >= 14.0.0 is required now

31.0.3 (2021-09-16)

Bug Fixes

31.0.2 (2021-08-22)

Bug Fixes

  • typescript: Disable "@babel/new-cap" for TypeScript projects (aa363af)

31.0.1 (2021-08-02)

Bug Fixes

  • TypeScript: Disable @typescript-eslint/method-signature-style for d.ts files (87e915b)

31.0.0 (2021-07-28)

Features

  • Enable import/no-import-module-exports (d4be1ce)
  • Enable import/no-relative-packages (b44fd1c)

BREAKING CHANGES

30.2.0 (2021-07-28)

Bug Fixes

  • styles/prefer-arrow: Allow class methods again (6c7b1b8)

Features

  • typescript: Relax "@typescript-eslint/no-unused-vars" in d.ts files (561b939)

30.1.0 (2021-05-07)

Features

  • Relax "no-constant-condition" for loops (7337bb7)

30.0.2 (2021-03-05)

Bug Fixes

  • Problem with prettier/react (dcbd28f)

30.0.1 (2021-03-05)

Bug Fixes

  • Problem with updated eslint-config-prettier (3108084)

30.0.0 (2021-01-31)

chore

BREAKING CHANGES

30.0.0-beta.1 (2021-01-31)

chore

BREAKING CHANGES

29.0.0 (2021-01-31)

Bug Fixes

  • JavaScript: Remove deprecated rules (eb52883)

chore

Features

  • Add prettier-typescript-node preset (1464581)
  • JavaScript: Add "no-loss-of-precision" rule as warning (5fd2828)
  • JavaScript: Add "no-nonoctal-decimal-escape" rule as warning (92e7aa9)
  • JavaScript: Add "no-promise-executor-return" rule as warning (a679f6b)
  • JavaScript: Add "no-restricted-exports" rule as warning (c1f3852)
  • JavaScript: Add "no-unreachable-loop" rule as warning (5757b4b)
  • JavaScript: Add "no-unsafe-optional-chaining" rule as warning (eb77e91)
  • JavaScript: Add "no-useless-backreference" rule as warning (1653191)
  • node: Use eslint-plugin-node (75c2ffe)
  • TypeScript: Add new TypeScript rules (199a393)

BREAKING CHANGES

  • node: We switched to eslint-plugin-node and their recommended rules
  • Change eslint peer dependency to ^7.15.0
  • Update eslint-config-prettier to ^7.2.0

29.0.0-beta.1 (2021-01-31)

Bug Fixes

  • JavaScript: Remove deprecated rules (eb52883)

chore

Features

  • Add prettier-typescript-node preset (1464581)
  • JavaScript: Add "no-loss-of-precision" rule as warning (5fd2828)
  • JavaScript: Add "no-nonoctal-decimal-escape" rule as warning (92e7aa9)
  • JavaScript: Add "no-promise-executor-return" rule as warning (a679f6b)
  • JavaScript: Add "no-restricted-exports" rule as warning (c1f3852)
  • JavaScript: Add "no-unreachable-loop" rule as warning (5757b4b)
  • JavaScript: Add "no-unsafe-optional-chaining" rule as warning (eb77e91)
  • JavaScript: Add "no-useless-backreference" rule as warning (1653191)
  • node: Use eslint-plugin-node (75c2ffe)
  • TypeScript: Add new TypeScript rules (199a393)

BREAKING CHANGES

  • node: We switched to eslint-plugin-node and their recommended rules
  • Change eslint peer dependency to ^7.15.0
  • Update eslint-config-prettier to ^7.2.0

28.1.5 (2020-11-30)

Bug Fixes

  • TypeScript: Disable @typescript-eslint/no-throw-literal (1b8aa70)

28.1.4 (2020-07-16)

Bug Fixes

  • typescript: Disable @typescript-eslint/consistent-type-assertions in tests (938a733)
  • typescript: Disable @typescript-eslint/no-unsafe-call (60fd344)

28.1.3 (2020-07-09)

Bug Fixes

  • base: Disable accessor-pairs (e9ca31d)

28.1.2 (2020-07-09)

Bug Fixes

  • Missing preset files in published package (0b79df1)

28.1.1 (2020-07-09)

Bug Fixes

  • base: Disable import/no-unassigned-import (3ccf48a)
  • typescript: Disable @typescript-eslint/no-unsafe-return in tests (4ef74ab)

28.1.0 (2020-07-09)

Bug Fixes

  • typescript: Relax rules that forbid the reassignment of 'any' (93bc5ca)
  • typescript: Remove additional @typescript-eslint/no-unnecessary-condition options (033011a)
  • typescript: Remove deprecated rules (d4f0048)

Features

  • Add presets for a quick start (326052d)
  • typescript: Allow ts-expect-error with description (b80c6a5)
  • typescript: Disable @typescript-eslint/no-explicit-any (5332eb1)
  • typescript: Disable @typescript-eslint/no-non-null-assertion (94b79dd)

28.0.0 (2020-05-16)

Features

  • Remove Prettier configuration (e6c0d39)

BREAKING CHANGES

27.8.0 (2020-05-16)

Features

  • Move jsdoc rules to separate config (c810d1f), closes #87

27.7.0 (2020-05-16)

Features

  • Increase eslint peerDependency to 7.0.0 (45d5003)

27.6.1 (2020-05-13)

Bug Fixes

  • Disable class-methods-use-this in react rules (a0fe36b)

27.6.0 (2020-03-23)

Features

  • typescript: Disable @typescript-eslint/prefer-regexp-exec (f170b8a)

27.5.2 (2020-03-23)

Bug Fixes

  • Fix security issues found by npm audit (6501094)

27.5.1 (2020-03-23)

Bug Fixes

  • base: Disable no-eq-null (df9922f)

27.5.0 (2020-03-09)

Features

  • typescript: Improve @typescript-eslint/naming-convention (#85) (86299ff)

27.4.0 (2020-03-09)

Features

  • Disable "class-methods-use-this" (f8f03c0)

27.3.0 (2020-03-09)

Features

  • Disable "no-warning-comments" (460f385)

27.2.0 (2020-03-05)

Bug Fixes

  • Disable "no-anonymous-default-exports" rule in tests (#82) (01f4cd4)

Features

  • Add prefer array shorthand style option (#81) (fb9f50a)

27.1.3 (2020-02-13)

Bug Fixes

  • base: Relax some promise rules (8b357e1)
  • react: Fix minor issue when using styles/react-jsx-no-literals (049cac6)
  • typescript: Disable @typescript-eslint/restrict-template-expressions (efbb8b3)

27.1.2 (2020-02-13)

Bug Fixes

  • typescript: Disable @typescript-eslint/require-array-sort-compare (e6ac2e1)

27.1.1 (2020-02-13)

Bug Fixes

  • react: Fix problem with escape hatch in styles/react-jsx-no-literals (993568b)

27.1.0 (2020-02-13)

Features

  • typescript: Disable no-extraneous-class (c4f49eb)
  • Allow exceptions for naming conventions in TypeScript projects (89de83b)

27.0.1 (2020-02-12)

Bug Fixes

  • Add new example .editorconfig (5891b4c)

27.0.0 (2020-02-12)

Bug Fixes

  • typescript: Do not set tsconfig.json by default (6b35fd4)

BREAKING CHANGES

  • typescript: We don't set the tsconfig.json now by default. Every project needs to specify it explicitly. This prevents some bugs that would be otherwise hard to understand. We also added a note to the README which should help people to set it up.

26.0.0 (2020-02-12)

Bug Fixes

  • Remove impractical rules (56c62a2)
  • base: Disable require-atomic-updates (38cd859)
  • base: Improve padding-line-between-statements (4b3c394)
  • base: Increase soft limit of complexity rule (a78a702)
  • base: Temporarily disable require-unicode-regexp (b248df7)
  • typescript: Allow _ parameter names (c0b3779)
  • typescript: Only require return await inside try-catch (709751f)
  • typescript: Switch to regular camelCase and PascalCase naming convention (182c295)
  • Disable no-return-await (14db3eb)
  • Fine-tune soft limits of max-lines and max-dependencies (a123f41)

chore

  • Refactor glob-patterns module (1db1f22)
  • Remove support for Node<10 (6c45b41)
  • Update dependencies (b52305e)

Features

  • react: Allow functions created during render (8c80148)
  • Lower severity of opinionated rules (c0bea51)
  • typescript: Add new TypeScript rules (9e77b24)
  • typescript: Disable @typescript-eslint/explicit-module-boundary-types again (a88a683)
  • typescript: Enforce naming convention (1fb0844)
  • typescript: Improve TypeScript support in base ESLint rules (6763671)
  • Add @typescript-eslint/explicit-module-boundary-types (3f106a0)
  • Add bunch of JSDoc rules (680550e)
  • Add styles/no-default-export (d8b0242)
  • Add styles/no-null (a30511b)
  • Disable some jsdoc rules when using TypeScript (82220fa)
  • Improve jsdoc rules (0a6694d)
  • Improve prettier support (1cd6537)
  • base: Add no-dupe-else-if (0ee8136)
  • base: Add prefer-exponentiation-operator (fd41a01)
  • base: Add prefer-regex-literals (01599bd)
  • base: Add require-atomic-updates (69f2c36)
  • base: Add require-unicode-regexp (0b44ba5)
  • base: Disallow assignments of imports (0e6af86)
  • base: Disallow return in constructors (f9edbbc)
  • base: Disallow return in setters (f3f574c)
  • base: Require grouping of setters and getters (94792f2)

BREAKING CHANGES

  • react: The default style now is to allow functions created during render. The style peerigon/styles/react-jsx-allow-bind has been removed and replaced by its opposite peerigon/styles/react-jsx-no-bind for applications that use memo a lot.

The motivation behind this is that it's more convenient for a lot of people to create functions during render. The performance downside is usually not an issue and can be mitigated by better usage of useState().

26.0.0-beta.3 (2020-02-06)

Features

  • Disable some jsdoc rules when using TypeScript (82220fa)

26.0.0-beta.2 (2020-02-06)

Features

BREAKING CHANGES

  • Use param instead of arg and argument.

26.0.0-beta.1 (2020-02-06)

Bug Fixes

  • base: Increase soft limit of complexity rule (a78a702)
  • Fine-tune soft limits of max-lines and max-dependencies (a123f41)
  • typescript: Do not "fix" 'any' to 'unknown' (154a42b)

chore

  • Refactor glob-patterns module (1db1f22)
  • Remove support for Node<10 (6c45b41)
  • Update dependencies (b52305e)

Features

  • Add styles/no-default-export (d8b0242)
  • Add styles/no-null (a30511b)
  • Improve prettier support (1cd6537)
  • base: Add no-dupe-else-if (0ee8136)
  • base: Add prefer-exponentiation-operator (fd41a01)
  • base: Add prefer-regex-literals (01599bd)
  • base: Add require-atomic-updates (69f2c36)
  • base: Add require-unicode-regexp (0b44ba5)
  • base: Disallow assignments of imports (0e6af86)
  • base: Disallow return in constructors (f9edbbc)
  • base: Disallow return in setters (f3f574c)
  • base: Require grouping of setters and getters (94792f2)
  • Add bunch of JSDoc rules (680550e)

BREAKING CHANGES

  • The prettier config now uses tabs instead of spaces. This is not actually breaking since Prettier will just format your code in a different way, but it will produce a lot of noise.
  • globPatterns.js has been renamed to glob-patterns.js
  • base: Require u flag in all regexes. The u flag adds unicode support and reports invalid regex patterns.
  • base: ESLint now reports a potential unsafe use of +=,-=,*=,/= in combination with async await
  • base: Regex literals are now preferred over new RegExp() if the regex is not dynamic.
  • base: The exponentiation operator is now preferred over Math.pow()
  • Support for Node versions below 10 has been removed.
  • base: Setters can't return values. This is enforced with a linting rule now. See https://eslint.org/docs/rules/no-setter-return
  • base: Assignments of imports are now disallowed. They throw a runtime error anyway. See https://eslint.org/docs/rules/no-import-assign
  • base: Certain If-else usages that were an error anyway are now a linting error. See ttps://eslint.org/docs/rules/no-dupe-else-if
  • base: Returning values from constructors is not allowed anymore. See https://eslint.org/docs/rules/no-constructor-return
  • base: Setters and getters now need to be grouped together. See https://eslint.org/docs/rules/grouped-accessor-pairs
  • Remove official ESLint 5 support

25.3.0 (2020-02-01)

Bug Fixes

  • base: Allow finally() as a replacement for catch() (0d2b2df)

Features

  • base: Relax eqeqeq (e8f9cd6)
  • react: Relax react/require-default-props rule (8be6c52)
  • typescript: Relax @typescript-eslint/strict-boolean-expressions rule (524c462)

25.2.0 (2020-01-23)

Features

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

25.1.1 (2020-01-13)

Bug Fixes

  • Turn off no-empty-function for TypeScript (1c8c5ac)

25.1.0 (2020-01-10)

Bug Fixes

  • Disable import/extensions for tsx files (b13c7f6)

Features

  • Allow ESLint 6 as peer dependency (e474e5e)

25.0.1 (2019-12-25)

Bug Fixes

  • Allow template literals for Jest inline snapshots (2b9c4e5)

25.0.0 (2019-12-23)

Bug Fixes

  • Allow non-null assertions in test files (240beec)
  • Do not require .ts extensions in TypeScript files (e40ffbe)
  • Turn off consistent-type-definitions in d.ts files (1c00846)

Features

  • Don't allow loose equality checks (8e065bf)

BREAKING CHANGES

  • Loose equality checks are not allowed anymore.

24.0.0 (2019-08-23)

Features

  • Update TypeScript rules (31fbf88)

BREAKING CHANGES

  • You need to update @typescript-eslint/eslint-plugin@^2.0.0 if you're using the TypeScript rules. The recommended rules changed a little bit and there have been some breaking rule changes like @typescript-eslint/consistent-type-assertions, @typescript-eslint/no-unnecessary-type-arguments and @typescript-eslint/strict-boolean-expressions

23.2.0 (2019-08-02)

Bug Fixes

  • Disable react/jsx-no-literals in tests (ed93deb)

Features

  • Disable react/jsx-one-expression-per-line (136a945)

23.1.0 (2019-08-01)

Features

  • Disable react/jsx-wrap-multilines (2eb57e2)

23.0.0 (2019-08-01)

Bug Fixes

  • Add additional check for tsconfig.json resolving (dd53d16)

Features

  • Enable @typescript-eslint/explicit-member-accessibility rule (f036659)
  • Relax import/order rule (ae8d12a)

BREAKING CHANGES

  • The @typescript-eslint/explicit-member-accessibility rule will now reports errors when someone uses the public keyword in TypeScript classes where it is not necessary.

22.1.0 (2019-07-31)

Features

  • Add Prettier config (4d5e84e)
  • Disable id-length (a8c791b)
  • Relax @typescript-eslint/no-floating-promises (ce7bf3e)

22.0.0 (2019-07-15)

Bug Fixes

  • Change @typescript-eslint/member-delimiter-style (e8dda25)
  • Turn of react/prop-types for TypeScript files (afe4ef5)

Features

  • Enable test rules by glob pattern (63c023c)
  • Recognize @testing-library/jest-dom/extend-expect as module with side-effects (3ff10a2)
  • Relax some import rules (6efa5a3)
  • Relax typescript rules in tests (c73ee22)

BREAKING CHANGES

  • Change back to @typescript-eslint/member-delimiter-style "semi" because we want to stay consistent with classes. Sorry for the noise :(

21.2.0 (2019-07-09)

Features

21.1.0 (2019-07-09)

Features

  • Introduce peerigon/styles/react-jsx-no-literals (8c0425f)

21.0.0 (2019-07-09)

Features

  • Add eslint-plugin-react-hooks (6c0d0a3)
  • Add styles/react-jsx-allow-bind (a8e4326)
  • Disable promise/prefer-await-to-then and promise/prefer-await-to-callbacks (b715e44)
  • Relax import/max-dependencies and max-lines (f692e4b)
  • Relax max-lines in tests (cd1e294)
  • Relax react/jsx-no-bind (89873c3)
  • Switch off react/no-multi-comp (366636a)

BREAKING CHANGES

  • There are linting rules for React hooks now.

20.0.1 (2019-07-08)

Bug Fixes

20.0.0 (2019-07-08)

Bug Fixes

  • Add note on @typescript-eslint/parser in README (898abe3)
  • Disable import rules that are slow (41edcb2)
  • Improve options for import/no-extraneous-dependencies (5fe07e6)
  • Reuse no-unused-vars option in TypeScript (44464ac)

Features

  • Ignore long comments in max-len rule (4a8d39d)
  • Increase import/max-dependencies to 20 (f5d6c9d)
  • Refactor TypeScript rules (302d840)
  • Update dependencies (32914ef)

BREAKING CHANGES

  • Added and changed a lot of TypeScript rules. This change was necessary because a lot of new rules have been added to @typescript-eslint. Also adds some performance improvements.
  • eslint-plugin-jsdoc received a major version bump
  • The pattern for devDependencies checked by import/no-extraneous-dependencies has changed

19.0.0 (2019-05-29)

Bug Fixes

  • Activate TypeScript rules only for *.tsx? files (338d98f)
  • Remove JS file overrides in typescript rules (68fc6df)

chore

Features

  • Add lines-between-class-members rule (b0ce663)
  • Disable arrow-body-style and arrow-parens rule (c50a7b4)

BREAKING CHANGES

  • eslint-plugin-jsdoc received a major version update.
  • It's now required to add a new line between multiline class members.
  • Remove sourceType = script parser option for JS files in TypeScript projects. This override made the wrong assumption that all JS files should be scripts in a TypeScript project which is certainly not correct.

18.0.0 (2019-05-29)

Bug Fixes

  • Remove JS file overrides in typescript rules (ef27f23)

BREAKING CHANGES

  • Remove sourceType = script parser option for JS files in TypeScript projects. This override made the wrong assumption that all JS files should be scripts in a TypeScript project which is certainly not correct.

17.1.0 (2019-02-22)

Features

  • Add prefer-interface style for TypeScript apps (#58) (529503f)

17.0.0 (2019-02-21)

Features

BREAKING CHANGES

    • "optimize-regex/optimize-regex": "error"

16.0.0 (2019-02-21)

Features

BREAKING CHANGES

  • This commit adds and changes a bunch of TypeScript rules because the original plugin was deprecated.

However, there were also notable changes to the base rules:

15.0.2 (2018-08-31)

Bug Fixes

15.0.1 (2018-08-30)

Bug Fixes

  • Disable no-empty rule in tests config (#48) (a1a1431)

15.0.0 (2018-08-29)

Bug Fixes

Features

BREAKING CHANGES

14.0.0 (2018-08-27)

Bug Fixes

Features

BREAKING CHANGES

    • Switch back to jsx and tsx extension
  • Switch to multiline-multiprop in react/jsx-first-prop-new-line
  • Arrow functions shouldn't have parenthesis around a single argument
  • The new rule can break tests
  • jsdoc/no-undefined-types and jsdoc/valid-types are errors now. This could break tests.
  • Update peer dependency on eslint to ^5.4.0

13.0.0 (2018-04-27)

Features

  • Add eslint-plugin-flowtype-errors (fc15db3)
  • Add eslint-plugin-jsx-a11y to react rules (7d8dbdc)
  • Add useful eslint plugins to base rules (caf6088)
  • Allow nested ternaries (15107ac)
  • Allow possibly undefined variables in typeof checks (1e657c3)
  • Configure new rules (273e139)
  • Enforce multiline ternary for long expressions (92031d2)
  • Make file extensions mandatory in imports (6ea3964)
  • Refactor import rules (53f41d4)
  • Refactor node rules (8a4e2b5)
  • Refactor react rules (9994d2b)
  • Refactor react/jsx-wrap-multilines rules (efe8ebd)
  • Refactor tests rules (820124f)
  • Remove curly and bracket spacings (4ff321c)
  • Remove eslint-plugin-flowtype-error again (13bbca7)
  • Remove fp rules (34543bc)
  • Switch back to babel-eslint again (f3ba862)
  • Switch back to eslint default parser (#18) (5ab10a8)
  • Update peerigon/node to match node >= 6 (c8ff737)

BREAKING CHANGES

  • If you're using Flowtype and the flowtype rules, you just need to call ESLint now to also do the typechecking.
  • You need to add babel-eslint as project dependencies in project where the peerigon/flowtype rules are used. You don't need to change anything if you're using other rules.
  • These plugins introduce new rules that might cause linting errors now.
    • Add autofixable order of imports
  • Discourage anonymous default exports

  • Changes a lot of rules that are concerned with whitespace after curlies and brackets. For consistency reasons, we do not write spaces after these characters.

  • Always add new line before multiline wraps. This change was necessary because of the new react/jsx-closing-tag-location which requires the closing tag to be on the same indentation as the opening tag. In combination with the parentheses rule, it could lead to an unstable state where eslint was trying to fix it by switching back and forth between two states.
  • This change adds a lot of new rules which help us to improve the accessibility of our applications.
  • There are new rules that might cause errors now.
  • The padded-blocks rule has been activated for tests again.
  • The fp rules where part of an experiment. These overly strict rules don't make sense in JavaScript.
  • Remove node 4 support
    • "import/extensions": ["error", "ignorePackages"],
    • "multiline-ternary": ["error", "always-multiline"]
    • import/no-self-import error
  • import/no-useless-path-segments error

  • A lof of rules have changed, expect some new errors.

12.0.1 (2017-10-26)

12.0.0 (2017-10-26)

Chores

  • Update eslint peer dependency (b0c3e28)

Features

BREAKING CHANGES

  • The eslint-config-peerigon now requires at least eslint@^4.9.0
  • There have been new rules added which might break your build. But they should be auto-fixable 🖖

11.3.1 (2017-06-25)

Bug Fixes

  • Switch off react/no-set-state (f4139d4)

11.3.0 (2017-06-23)

Features

  • Relax class-methods-use-this to warn because it should be a hint (9af3645)
  • Relax react rules (a026414)

11.2.0 (2017-06-22)

Features

  • Relax no-extraneous-dependencies rule (50710b5)

11.1.0 (2017-06-22)

Features

  • Relax import/no-extraneous-dependencies rule (4c26ba0)

11.0.1 (2017-06-22)

Bug Fixes

  • Missing plugin declaration in react rules (3a39340)

11.0.0 (2017-06-22)

Chores

  • Remove eslint-plugin-flowtype (e99537a)

BREAKING CHANGES

  • This commit removes eslint-plugin-flowtype from the package.json. In case you're using the flowtype config, you need to add eslint-plugin-flowtype to your package.json now.

10.1.1 (2017-04-03)

Bug Fixes

  • Turn off "prefer-rest" in node rules (b0af121)

10.1.0 (2017-04-03)

Features

  • Remove no-confusing-arrow rule (bb20a58)

10.0.0 (2017-03-31)

Features

BREAKING CHANGES

  • This version introduces also some breaking changes:

  • Switch "no-alert" to "error" (a831ed4fc3b17d4a932745cdda7f31cbc00e955d)

  • Switch "no-bitwise" to "error" (e8f38b6289c6b3ae7d17dc35a445b1837143c4bd)
  • Switch "no-eq-null" to "error" (329ae4bbaf5b4fd732f899bd89cd8f152b7ac1e2)
  • Switch "no-process-exit" to "error" (850275f029ea37c85c7e766f8d976a38ea89dce3)
  • Switch "no-script-url" to "error" (5b10357db3fe6f836858066c44e740956ad3df61)
  • Switch "no-useless-call" to "error" (66ab5190f01d27d81c5d0654c303f77466c37d47)
  • Switch "no-script-url" to "error" (5b10357db3fe6f836858066c44e740956ad3df61)
  • Add dangling commas (356adb84c3d7c9ba937c4248a38e1d1cc6ba46df)
  • Add a bunch of new rules (bf343f51cba2ae93bc38dff541122705776b2259)
  • Make "no-undef" rule stricter (6ae63b3b83925ebdbcb1586f3292ef9cb93d8dc9)

9.0.0

  • Breaking: Enforce template-curly-spacing (see a3409a3613a58e002921db8cb54db0550fbfa56d)

8.0.0

  • Breaking: Add/change react rules based on discussion in #5
  • Breaking: Add rule to prevent curly spaces in template strings (see c600bd8b71094ee972b933762d646faef091376d)

7.0.0

  • Add new react rules

6.0.1

  • Fix parser silently switching back to es2015 when using the es5 rules

6.0.0

  • Update peer dependency eslint to ^3.0.0

5.1.0

  • Increase allowed max complexity

5.0.0

  • Breaking: Make eslint-plugin-jsdoc ^2.3.1 a peer dependency
  • Add config for eslint-plugin-react

4.0.0

  • Breaking: Improve JSDoc validation (some rules are a bit stricter now)

3.1.1

  • Fix parser options for es6 and es5

3.1.0

  • Change severity of "arrow-parens" rule to 0

3.0.0

  • Breaking: Add rule "no-labels" with severity 2
  • Update to eslint@^2.0.0
  • Remove obsolete rules

2.0.0

  • Breaking: Change rule "quote-props" to "as-needed"
  • Add mocha env to tests config

1.0.0

  • Add ES2015 rules
  • Reached stable state :)