1.0.0 • Published 17 days ago

wetravel-eslint-config v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
17 days ago

Wetravel ESLing config

Overview

The WeTravel ESLint Configuration project provides a standardized ESLint setup optimized for both JavaScript and TypeScript environments. This configuration aims to enforce best practices and consistency across the development of React applications, as well as writing maintainable tests using Jest.

Installation

Remove current eslint

You need to remove all eslint related package, you can do it manually or with this command:

jq -r '.dependencies + .devDependencies | keys | map(select(test("eslint")))[]' package.json | xargs yarn remove

!NOTE You would need jq installed on your system, brew install jq might help

Install config package

yarn add wetravel-eslint-config

Potentially you would need to install dependencies that are used by eslint plugins

yarn add --dev @eslint/js@^8 eslint@^8 eslint-config-prettier eslint-plugin-jest-dom eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-hooks typescript-eslint prettier globals

Now replace in package.json scripts to run lint and lit with autofix:

    "lint": "ESLINT_USE_FLAT_CONFIG=true eslint . --config node_modules/wetravel-eslint-config/eslint.config.mjs",
    "lint:fix": "ESLINT_USE_FLAT_CONFIG=true eslint . --config node_modules/wetravel-eslint-config/eslint.config.mjs --fix"

We're using ESLINT_USE_FLAT_CONFIG flag to be compatiple with ESLint 9 that came out recently and requires new, flat config by default. Unfortunately React Hooks plugin not yet compatible with ESLint 9, so we're using ESLint 8 but with new config.

We also using config file directly from node_modules folder to avoid unnecessary customisations of rulest (which kinda defeats the purpose of one centralized config).

Usage

Run to lint the project

yarn lint