Giter Site home page Giter Site logo

cuppachino / eslint-config Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 111 KB

Lint TypeScript with ESLint, format with Prettier. Type-safe. Zero-conflict.

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

License: MIT License

JavaScript 100.00%
eslint eslint-config eslint-prettier-config eslint-typescript format jsdoc lint prettier tsdoc typescript changesets

eslint-config's Introduction

@cuppachino/eslint-config

Discord Release License npm (scoped) npm

  • Extendable... fully customized ESLint configuration

  • Optimized... for explosive TypeScript development

  • Consistent... comment doc formatting with jsdoc and tsdoc

  • Seamless... integration with Prettier

  • Granular... keep Prettier and ESLint separate without conflict

Using this package in your project

Install

pnpm add -D eslint @cuppachino/eslint-config

Create a tsconfig.eslint.json at the root of your project and extend your own tsconfig.json:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "noEmit": true
  },
  "include": [
    "pkg/",
    // "src/",
    //  "./vite.config.ts",
    // "./apps/*/tsconfig.json"
  ],
}

Configure

Create a .eslintrc.cjs file in the root of your project and extend the config:

or .eslintrc.js or .eslintrc.json

module.exports = {
  
  /* 1️⃣ focus eslint to not look outside of your project */
  root: true, 

  /* 2️⃣ extend your config with the package */
  extends: ['@cuppachino/eslint-config'], 

  /* 3️⃣ point your own tsconfig(s) */
  parserOptions: {
    tsconfigRootDir: __dirname,
    project: [
      './tsconfig.eslint.json', // REQUIRED
      './apps/*/tsconfig.json',
      './packages/*/tsconfig.json'
    ]
  },
  settings: {
    'import/resolver': {
      typescript: {
        alwaysTryTypes: true,
        project: [
          './tsconfig.eslint.json', // REQUIRED
          './apps/*/tsconfig.json',
          './packages/*/tsconfig.json'
        ]
      }
    }
  },

  /* ⭐ Override rules here */
  rules: {
    // ...
  }
}

If you extend additional configs after @cuppachino/eslint-config, you may introduce conflicts between Prettier and ESLint. You can work around this by always including the config last OR by manually adding the eslint-config-prettier package to your project and adding "prettier" to the end of your extends array.

// ❌ NOT OK
extends: [
  '@cuppachino/eslint-config',
  'plugin:react/recommended',
]
// ✅ OK
extends: [
  'plugin:react/recommended',
  '@cuppachino/eslint-config',
]
// ✅ OK
extends: [
  '@cuppachino/eslint-config',
  'plugin:react/recommended',
  'prettier'
]

IDE Integration

TypeScript npm dev dependency version (scoped)

Make sure to use your workspace's version of TypeScript and your tsconfig.json for type checking!

typescript-workspace-version

ESLint npm (prod) dependency version (scoped)

To highlight code quality errors in vscode, you can use dbaeumer.vscode-eslint.

Add the following scripts to your package.json for usage in your pipeline:

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

Prettier npm (peer) dependency version (scoped)

Follow the setup directions for rvest.vs-code-prettier-eslint. This will allow you to fix linting errors with eslint and format your code with prettier, on save, in one step.

These scripts can be used to format your entire project:

{
  "scripts": {
    "format": "prettier --check .",
    "format:fix": "prettier --write ."
  }
}

Development Cycle

If you have the previously mentioned extensions installed, you should be able to use them during development.

Install Dependencies

This package is managed with PNPM. To get started, run the following commands:

cd YOUR-eslint-config
pnpm install

Change, Commit, Merge & Release & Publish

  1. After you make changes and save, create a new changeset and follow the cli prompts:

    cd YOUR-eslint-config
    pnpm new
  2. Push your changes to a new branch and open a PR.

  3. Once your PR is merged, changesets will automatically create a new release and publish it to NPM.

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.