ESLint:`eslintrc.js` 的类型

Dim*_*ava 2 typing eslint typescript-definitions eslintrc typescript-eslint

我希望对我的eslintrc.js类型进行类型检查,并内置允许的规则的所有类型定义。

即喜欢:

module.exports = defineESLint({
  rules: {
    // intellisence: Enforce the consistent use of either backticks, double, or single quotes
    // quotes?: 'off' | 'warn' | 'error'
    // | ['warn' | 'error', 'single' | 'double', { avoidEscape?: true }]
    quotes: ["warn", 'single', {avoidEscape: true}],
  }
})
Run Code Online (Sandbox Code Playgroud)

我通常希望它能与我所有的eslint 扩展一起使用

目前我能做的就是

{
  "$schema": "https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/eslintrc.json",
  "rules": {
    "quotes": [
      "warn",
      "single",
      {
        "avoidEscape": true
      }
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

在 json 中,但它几乎不起作用

Dim*_*ava 5

npm:eslint-定义-配置

用法:

.eslintrc.js

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

module.exports = defineConfig({
  root: true,
  rules: {
    // rules...
  },
});
Run Code Online (Sandbox Code Playgroud)

通过以下方式改善您的 eslint 配置体验:

  • 自动建议
  • 类型检查(// @ts-check在您的第一行使用.eslintrc.js
  • 文档
  • 弃用警告