0.1.1 • Published 8 months ago

@fenge/eslint-config v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@fenge/eslint-config

npm.io npm.io npm.io npm.io PRs Welcome

A strict eslint config preset containing a comprehensive set of rules for linting js / ts / package.json files. Based on standard.js without any stylistic opinions.

Feature

  • Lint js / mjs / cjs / jsx / ts / mts / cts / tsx / package.json files only.
  • Strict. More than 300+ rules.
  • Highly customizable by omitting unwanted.
  • Type safe. TypeScript friendly.
  • Pure JavaScript project friendly.
  • React friendly.
  • NestJS friendly.
  • Based on standard.js, introduced more stricter rules.
  • Have no stylistic opinions. Prettier friendly.
  • Respect .gitignore.
  • ESLint Flat config, compose easily!
  • Modern. ESM first.
  • One-line of config.

Usage

Install it in the root of js / ts project.

npm install -D eslint @fenge/eslint-config

Config eslint.config.js (for ESM).

import config from "@fenge/eslint-config";

export default config;

If you are in CommonJS, config eslint.config.js bellow:

module.exports = import("@fenge/eslint-config");

Config package.json

{
  "scripts": {
    "lint": "eslint .",
    "lint:fix": "eslint . --fix"
  }
}

Note: TypeScript project is required a tsconfig.json file in the root.

Advanced Usage

Config Builder

You can use Builder class to customize for selecting or omitting some rules.

import { Builder } from "@fenge/eslint-config";

export default new Builder()
  .enablePackagejson({
    pick: ["packagejson/top-types"], // only these rules will work for package.json files
  })
  .enableJavascript({
    omit: ["no-var"], // these rules will not work for js files
  })
  .enableTypescript({
    project: "tsconfig.json", // tsconfig.json path
    extend: {
      // apply additional rules for ts files
      "@typescript-eslint/no-explicit-any": "error",
      "@typescript-eslint/consistent-type-assertions": [
        "error",
        { assertionStyle: "never" },
      ],
      "@typescript-eslint/no-non-null-assertion": "error",
    },
  })
  .toConfig();

License

MIT