Code Monkey home page Code Monkey logo

eslint-define-config's Introduction

NPM package Downloads Build Status License: MIT Code Style: Prettier Donate: PayPal

eslint-define-config

Provide a defineConfig function for .eslintrc.js, and a defineFlatConfig function for eslint.config.js files.

Installation

# add eslint and eslint-define-config to project’s dev dependencies
npm add --save-dev eslint eslint-define-config
# or
yarn add --dev eslint eslint-define-config
# or
pnpm add --save-dev eslint eslint-define-config

Usage

By default only eslint's rules are supported. To activate auto-suggestions for Rules of specific plugins, you need to install the respective types for that plugin.
Plugins can either support their own types, or they could be supported by the community in the @eslint-types repository.

A list of community supported plugins can be found here.

.eslintrc.js

// @ts-check
const { defineConfig } = require('eslint-define-config');

/// <reference types="@eslint-types/typescript-eslint" />

module.exports = defineConfig({
  root: true,
  rules: {
    // rules...
  },
});

Flat Config

eslint.config.js

// @ts-check
const { defineFlatConfig } = require('eslint-define-config');

/// <reference types="@eslint-types/typescript-eslint" />

module.exports = defineFlatConfig([
  'eslint:recommended',
  {
    plugins: {
      // plugins...
    },
    rules: {
      // rules...
    },
  },
]);

Why?

Improve your eslint configuration experience with:

  • auto-suggestions
  • type checking (Use // @ts-check at the first line in your .eslintrc.js or eslint.config.js)
  • documentation
  • deprecation warnings

Image

Video

Click on the thumbnail to play the video

Video

Want to support your own plugin?

⚠️ This feature is very new and requires the support of the respective plugin owners

Add a declare module to your plugin package like this:

declare module 'eslint-define-config' {
  export interface CustomRuleOptions {
    /**
     * Require consistently using either `T[]` or `Array<T>` for arrays.
     *
     * @see [array-type](https://typescript-eslint.io/rules/array-type)
     */
    '@typescript-eslint/array-type': [
      {
        default?: 'array' | 'generic' | 'array-simple';
        readonly?: 'array' | 'generic' | 'array-simple';
      },
    ];

    // ... more Rules
  }
}

There are other interfaces that can be extended.

  • CustomExtends
  • CustomParserOptions
  • CustomParsers
  • CustomPlugins
  • CustomSettings

Credits

eslint-define-config's People

Contributors

shinigami92 avatar renovate[bot] avatar sxzz avatar azat-io avatar dependabot[bot] avatar julien-r44 avatar holazz avatar notevenaneko avatar dimava avatar deraw avatar leaftail1880 avatar lehoczky avatar xeho91 avatar sosukesuzuki avatar danielwerg avatar fisker avatar scarf005 avatar sapphi-red avatar

Watchers

 avatar

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.