4.1.0 • Published 2 years ago

@fastcms/eslint-config v4.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

eslint-config

Peer ESLint Version Peer Babel Version Peer TypeScript Version

Shared @eslint configs for projects of @fastcms.

Installation

Use npx to install peerdeps automatically or install peerDependencies and optionalDependencies with npm/yarn manually.

# Install using npm
$ npm info "@fastcms/eslint-config" peerDependencies optionalDependencies
$ npx install-peerdeps --dev @fastcms/eslint-config

# Install using yarn
$ yarn add --dev @fastcms/eslint-config @babel/core eslint typescript

Usage

After installation, add following contents to your .eslintrc or the eslintConfig entry of package.json file.

Base

{
  "root": true,
  "extends": "@fastcms/eslint-config/base"
}

This config is used for web utils project, the codebase can be written in both JavaScript and TypeScript.

React (default)

{
  "root": true,
  "extends": "@fastcms",
  "settings": {
    "polyfills": ["fetch", "Promise", "URL"]
  }
}

This config is used for react component or app project, the codebase can be written in both JavaScript and TypeScript.

If you want to use different tsconfig.json for each working directory, you should add workingDirectories in .vscode/settings.json.

{
  "eslint.workingDirectories": [
    "./@types/fastcms",
    "./apps/react-app",
    "./libs/utils",
    "./tools/eslint-config"
  ]
}

Scripts

Add eslint scripts to package.json, then run ESLint with yarn run eslint manually, or integrate with GitHub Actions.

{
  "scripts": {
    "eslint": "eslint --ext .js,.ts,.cjs,.cts,.mjs,.mts,.jsx,.tsx,.md,.mdx .",
    "eslint:fix": "eslint --fix --ext .js,.ts,.cjs,.cts,.mjs,.mts,.jsx,.tsx,.md,.mdx ."
  }
}

Project TypeScript Config

If your project includes TypeScript code, you should provide tsconfig.json for ESLint, the searching priority of tsconfig.json are below.

  1. tsconfig.json (root)
  2. packages/*/tsconfig.json (workspace)

License

The codebase and documentation in this repository are released under the MIT License