0.2.4 • Published 1 year ago

eslint-config-fritx v0.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

eslint-config-fritx

Highly inspired by @antfu/eslint-config

  

  • Extends eslint-config-standard
  • Standard like, super light-weight
  • Single quotes, no semi
  • Auto fix for formatting (aimed to be used standalone without Prettier)
  • Prefer let (const is allowed at the top-level)
  • Node / Browser / Wxapp / TypeScript / ESM
  • es2022 / es2018 / es5 / etc

Usage

Install

npm i -g @antfu/ni  # `ni` is recommended

ni -D eslint eslint-config-fritx

Config .eslintrc.cjs

module.exports = {
  extends: ['fritx/node'],
  // or es2017 for better compatibility
  extends: ['fritx/node', 'fritx/es2018'],

  // or for front-end projects
  extends: ['fritx/browser'],

  // or for some really old projects
  extends: ['fritx/browser', 'fritx/es5-loose'],

  // if you want to lint third-party libraries with es5
  overrides: [
    {
      files: 'vendor/**/*.js',
      extends: ['plugin:es/restrict-to-es5'],
    },
    // ...

  // typescript
  // execute `ni -D typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin`
  extends: ['fritx/typescript'],
  // wechat miniprogram
  extends: ['fritx/wxapp'],
  // both
  extends: ['fritx/wxapp', 'fritx/typescript'],

  // if you want more standard rules on besides
  // execute `ni -D eslint-config-standard eslint-plugin-import eslint-plugin-n eslint-plugin-promise`
  extends: ['fritx/standard-full'],
}

Add scripts for package.json

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

Config VS Code auto fix

// .vscode/settings.json
{
  "prettier.enable": false,
  "editor.formatOnSave": false,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  }
}

If you are using ESM (ES Modules)

// package.json
{
  "type": "module",
  // ...
}
// .eslintrc.cjs
module.exports = {
  extends: ['fritx/node', 'fritx/es2022', 'fritx/esm'],
  // or
  extends: ['fritx/browser', 'fritx/es2022', 'fritx/esm'],
  // ...
}
// .vscode/settings.json
{
  // Intellisense vs JavaScript Modules - lack of ".js" in completion #126171
  // https://github.com/microsoft/vscode/issues/126171
  "javascript.preferences.importModuleSpecifierEnding": "js",
  // ...
}

Extended Reading

Learn more about the context - Why I don't use Prettier.

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago