Giter Site home page Giter Site logo

evgenyorekhov / eslint-config-hardcore Goto Github PK

View Code? Open in Web Editor NEW
381.0 5.0 13.0 4.54 MB

The most strict (yet practical) ESLint config. 53 plugins. 1333 rules. React, Vue, Node, and pure JS/TS.

Home Page: https://www.npmjs.com/package/eslint-config-hardcore

License: MIT License

JavaScript 62.07% HTML 20.25% TypeScript 8.59% Vue 9.09%
shareable-configs eslint config eslintconfig eslint-config hardcore code-quality

eslint-config-hardcore's Introduction

eslint-config-hardcore

npm code style: prettier

The most strict (yet practical) ESLint config.

Aims to include as many plugins and rules as possible to make your code extremely consistent and robust.

53 plugins. 1333 rules.

Usage

npm install eslint-config-hardcore --save-dev

Available configs:

  • hardcore - base framework-agnostic config
  • hardcore/ts - additional config for TypeScript
  • hardcore/node- additional config for Node.js
  • hardcore/react - additional config for React
  • hardcore/react-performance - additional React config with performance rules
  • hardcore/vue - additional config for Vue 3/Nuxt 3
  • hardcore/react-testing-library - additional config for React Testing Library
  • hardcore/jest - additional config for Jest
  • hardcore/fp - additional config for functional programming
  • hardcore/ts-for-js - additional config for linting JavaScript with typescript-eslint

Example .eslintrc.json for a React project:

{
  "root": true,

  "extends": [
    "hardcore",
    "hardcore/react",
    "hardcore/react-performance",
    "hardcore/react-testing-library",
    "hardcore/jest",
    "hardcore/fp"
  ],

  "env": {
    "browser": true
  },

  "overrides": [
    {
      "files": ["server/**/*.js"],

      "extends": ["hardcore/node"],

      "env": {
        "browser": false
      }
    }
  ]
}

Example .eslintrc.json for a TypeScript React project:

{
  "root": true,

  "extends": [
    "hardcore",
    "hardcore/react",
    "hardcore/react-performance",
    "hardcore/react-testing-library",
    "hardcore/jest",
    "hardcore/fp",
    "hardcore/ts"
  ],

  "parserOptions": {
    "project": true
  },

  "env": {
    "browser": true
  },

  "overrides": [
    {
      "files": ["server/**/*.ts"],

      "extends": ["hardcore/node"],

      "env": {
        "browser": false
      }
    }
  ]
}

Example .eslintrc.json for a Vue 3 project:

{
  "root": true,

  "extends": ["hardcore", "hardcore/vue"],

  "settings": {
    "import/resolver": {
      "alias": {
        "map": [["@", "./src/"]],
        "extensions": [".js", ".vue"]
      }
    }
  }
}

Example .eslintrc.json for a Nuxt 3 project:

{
  "root": true,

  "extends": ["hardcore", "hardcore/vue"],

  "settings": {
    "import/resolver": {
      "alias": {
        "map": [
          ["@", "./"],
          ["#imports", ".nuxt/imports.d.ts"]
        ],

        "extensions": [".js", ".vue"]
      }
    }
  }
}

Example .eslintrc.json for a TypeScript Vue 3 project (depending on project configuration, you might want to change "project": true to "project": "tsconfig.app.json"):

{
  "root": true,

  "extends": ["hardcore", "hardcore/ts", "hardcore/vue"],

  "parserOptions": {
    "project": true
  },

  "overrides": [
    {
      "files": [
        "vite.config.*",
        "vitest.config.*",
        "cypress.config.*",
        "playwright.config.*"
      ],

      "parserOptions": {
        "project": "tsconfig.node.json"
      }
    },

    {
      "files": ["src/**/__tests__/*"],

      "parserOptions": {
        "project": "tsconfig.vitest.json"
      }
    }
  ]
}

Example .eslintrc.json for a TypeScript Nuxt 3 project:

{
  "root": true,

  "extends": ["hardcore", "hardcore/ts", "hardcore/vue"],

  "parserOptions": {
    "project": true
  }
}

Configs

hardcore

Base framework-agnostic config.

Plugin Enabled rules
ESLint core rules 180
eslint-plugin-unicorn 97
eslint-plugin-regexp 80
eslint-plugin-putout 73
eslint-plugin-sonar 51
eslint-plugin-import 33
eslint-plugin-sonarjs 31
HTML ESLint 22
eslint-plugin-promise 13
eslint-plugin-security 12
eslint-plugin-perfectionist 7
eslint-plugin-eslint-comments 6
eslint-plugin-sdl 5
eslint-plugin-array-func 3
eslint-plugin-unused-imports 2
eslint-plugin-simple-import-sort 2
eslint-plugin-no-constructor-bind 1
eslint-plugin-no-unsanitized 2
@shopify/eslint-plugin 1
eslint-plugin-no-use-extend-native 1
eslint-plugin-ext 1
eslint-plugin-no-only-tests 1
eslint-plugin-compat 1
eslint-plugin-json¹ 1
eslint-plugin-yml¹ 1
eslint-plugin-toml¹ 1
Total: 637

¹ json/yml/toml plugins actually include several rules, but I consider each plugin as a single "no-invalid" rule.

hardcore/ts

Config for TypeScript.

Plugin Enabled rules
typescript-eslint 105
eslint-plugin-etc 10
eslint-plugin-total-functions 8
@shopify/eslint-plugin 3
eslint-plugin-sonar 1
eslint-plugin-sort-class-members 1
eslint-plugin-decorator-position 1
eslint-plugin-no-explicit-type-exports 1
eslint-plugin-typescript-compat 1
Total: 131

hardcore/node

Config for Node.js.

Plugin Enabled rules
eslint-plugin-sonar 53
eslint-plugin-n 35
eslint-plugin-sdl 1
Total: 89

hardcore/react

Config for React.

Plugin Enabled rules
eslint-plugin-react 74
eslint-plugin-styled-components-a11y 33
eslint-plugin-jsx-a11y 34
eslint-plugin-storybook 14
eslint-plugin-react-form-fields 4
eslint-plugin-ssr-friendly 4
@shopify/eslint-plugin 3
eslint-plugin-react-hook-form 3
eslint-plugin-react-hooks 2
eslint-plugin-sonar 2
eslint-plugin-validate-jsx-nesting 1
eslint-plugin-react-prefer-function-component 1
Total: 175

hardcore/react-performance

Config with performance rules for React.

Plugin Enabled rules
eslint-plugin-react 4
eslint-plugin-react-perf 4
eslint-plugin-react-usememo 1
Total: 9

hardcore/vue

Config for Vue 3/Nuxt 3.

Plugin Enabled rules
eslint-plugin-vue 168
eslint-plugin-vuejs-accessibility 20
eslint-plugin-vue-scoped-css 12
eslint-plugin-sonar 1
Total: 201

hardcore/react-testing-library

Config for React Testing Library.

Plugin Enabled rules
eslint-plugin-testing-library 24
Total: 24

hardcore/jest

Config for Jest.

Plugin Enabled rules
eslint-plugin-jest 49
eslint-plugin-jest-dom 11
eslint-plugin-jest-formatting 7
Total: 67

hardcore/fp

Config for functional programming.

Plugin Enabled rules
eslint-plugin-functional 9
Total: 9

hardcore/ts-for-js

Config for linting JavaScript with typescript-eslint.

Plugin Enabled rules
typescript-eslint 28
eslint-plugin-etc 4
@shopify/eslint-plugin 2
eslint-plugin-sort-class-members 1
eslint-plugin-decorator-position 1
eslint-plugin-typescript-compat 1
Total: 37

Did you know you can lint JavaScript code with typescript-eslint?

Use this config to take advantage of typescript-eslint's advanced type-aware rules (like @typescript-eslint/naming-convention and @typescript-eslint/prefer-optional-chain) without the need to switch to writing TypeScript.

  1. First, you'll need to create tsconfig.json in the root of your project. You don't have to specify any options, just {} should do it.
  2. Then add hardcore/ts-for-js to the overrides section in your .eslintrc like this:
{
  "extends": ["hardcore"],

  "env": {
    "browser": true
  },

  "overrides": [
    {
      "files": ["*.js"],
      "extends": ["hardcore/ts-for-js"],
      "parserOptions": {
        "project": true
      }
    }
  ]
}

License

MIT

eslint-config-hardcore's People

Contributors

alexkramer98 avatar dependabot-preview[bot] avatar dependabot[bot] avatar evgenyorekhov avatar jonataswalker avatar pmcelhaney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

eslint-config-hardcore's Issues

Perhaps the "object-property-newline" rule is too strict

Compare:

h(
    Component,
    {
        someProp: 123,
        anotherProp: 321
    },
    [
        h(Component, {
            someProp: 123,
            anotherProp: 321
        }),
        h(Component, {
            someProp: 123,
            anotherProp: 321
        }),
        h(
            Component,
            {
                someProp: 123,
                anotherProp: 321
            },
            [
                h(Component, {
                    someProp: 123,
                    anotherProp: 321
                }),
                h(Component, {
                    someProp: 123,
                    anotherProp: 321
                })
            ]
        )
    ]
);
h(Component, {someProp: 123, anotherProp: 321}, [
    h(Component, {someProp: 123, anotherProp: 321}),
    h(Component, {someProp: 123, anotherProp: 321}),
    h(Component, {someProp: 123, anotherProp: 321}, [
        h(Component, {someProp: 123, anotherProp: 321}),
        h(Component, {someProp: 123, anotherProp: 321})
    ])
]);

Perhaps the "object-property-newline" rule should be reconfigured to

["error", {"allowAllPropertiesOnSameLine": true}]

Add smoke test

  1. Create .eslintrc.json file with the following contents: {"extends": ["./index.json"]}.
  2. Change the test script to node test.js && eslint **/*.js.

Automate releasing

The simplest way is

"preversion": "npm test",
"postversion": "git push && git push --tags && npm publish"

Investigate:

Conflict with index files

There is a conflict between import/extensions, import/no-useless-path-segments, and unicorn/import-index, when referencing index files, e. g. ./index.js.

Add more configs

One would use them like this:

{
    "extends": ["hardcore", "hardcore/fp"],
    "overrides": [
        {
            "files": ["server/**/*.js"],
            "extends": ["hardcore/node"]
        }
    ]
}

Relax no-shadow rule

"hoist": "all" seems too strict. Perhaps it should have the default functions value.

Or not?

Note: JSLint works the same as the all value.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.