Socket
Socket
Sign inDemoInstall

@antfu/eslint-define-config

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @antfu/eslint-define-config

Provide a defineConfig function for .eslintrc.js files


Version published
Weekly downloads
20K
decreased by-7.36%
Maintainers
1
Install size
2.83 MB
Created
Weekly downloads
 

Readme

Source

@antfu/eslint-define-config

A fork of eslint-define-config to experiment better Flat Config support.

Changes In This Fork

1. Re-export Rules for Each Plugin

import {
  VitestRules,
  VueRules,
  // ...
} from '@antfu/eslint-define-config'

2. Allow Overriding Rules

import pluginVitest from 'eslint-plugin-vitest'
import {
  defineFlatConfig,
  VitestRules
} from '@antfu/eslint-define-config'

export default defineFlatConfig<VitestRules, /* Strict */ true>({
  plugins: {
    vitest: pluginVitest,
  },
  rules: {
    // only `vitest/` rules are allowed and will be auto-completed
    'vitest/no-async': 'error',

    // @ts-expect-error not allowed
    'indent': 'error'
  },
})

3. Support Renaming Rules

import {
  RenamePrefix,
  TypeScriptRules // { '@typescript-eslint/indent': 'error', ... }
} from '@antfu/eslint-define-config'

type RenamedRules = RenamePrefix<TypeScriptRules, '@typescript-eslint/', 'ts/'>
// { 'ts/indent': 'error', ... }

This way it could work for Flat Config plugin renaming:

import pluginTypeScript from '@typescript-eslint/eslint-plugin'
import {
  defineFlatConfig,
  RenamePrefix,
  TypeScriptRules
} from '@antfu/eslint-define-config'

type RenamedRules = RenamePrefix<TypeScriptRules, '@typescript-eslint/', 'ts/'>

export default defineFlatConfig<RenamedRules>({
  plugins: {
    ts: pluginTypeScript, // renames to `ts/`
  },
  rules: {
    'ts/indent': 'error',

    // now we have auto-completion for `ts/` rules
  },
})

Keywords

FAQs

Last updated on 24 Oct 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc