如何使用antful的eslint

0 阅读1分钟

资源

eslint.style/rules/defau…

github.com/antfu/eslin… antful的官网

import antfu from "@antfu/eslint-config";

export default antfu(
  {
    ignores: ["snapshot*", "**/snapshot*/**", "dist", "**/dist/**", "lib", "**/lib/**", "es", "**/es/**", "esm", "**/esm/**", "node_modules", "**/node_modules/**", "src/_common", "src/_common/**", "static", "**/static/**", "cypress", "**/cypress/**", "script/test/cypress", "script/test/cypress/**", "_site", "**/_site/**", "temp*", "**/temp*/**", "static/", "**/static/**/", "!.prettierrc.js", "!**/.prettierrc.js/**"],
    formatters: {
      css: true, // 格式化 CSS 和 <style> 块
      html: true, // 格式化 HTML 文件
      markdown: "prettier" // 格式化 Markdown 文件
    },
    unocss: true,
    vue: true,
    stylistic: {
      indent: 2, // 4, or 'tab'
      quotes: "double", // or 'double'
      semi: true,
      jsx: true

    },
    rules: {
      "style/semi": ["error", "always"], // 强制在语句末尾使用分号
      "style/comma-dangle": ["error", "never"], // 禁止末尾逗号
      "style/arrow-parens": ["error", "always"]

    }
  }

);

解释下stylistic 和 rule下面的 style: 他们两个是一样的,看这段参考

image.png

你可以直接写stylistic 去配置规则,也可以在rule中配置规则,但是semi应该有一个前缀,就是用style 代替stylistic