eslint import 排序和单词拼写检查 插件

本文介绍了如何利用eslint插件进行import排序和单词拼写检查,以提升代码质量和规范性。通过配置.eslintrc文件,可以确保代码中的import语句自动排序,并对可能的拼写错误进行警告,从而在Vite等项目中避免导入错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原文链接: eslint import 排序和单词拼写检查 插件

上一篇: ts import type和export type 解决vite中导入类型报错的问题

下一篇: vite worker 简单使用

对import语句进行排序, 这样可以保持项目中引入位置是一致的, 单词检查主要是减少拼写错误, 这个插件还有待完善, 但可以不定期试试, 减少typo

运行时提示缺啥就装啥

.eslintrc

module.exports = {
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: ['tsconfig.json'],
  },
  plugins: ['@typescript-eslint', "spellcheck","simple-import-sort"],
  rules: {
    'no-unused-vars': 'off',
    "spellcheck/spell-checker": [1,
        {
            "comments": false,
            "strings": false,
            "identifiers": false,
            "lang": "en_US",
            "skipWords": [
                "dict",
                "aff",
                "hunspellchecker",
                "hunspell",
                "utils",
                "lottie"
            ],
            "skipIfMatch": [
                "http://[^s]*",
                "^[-\\w]+\/[-\\w\\.]+$" //For MIME Types
            ],
            "skipWordIfMatch": [
                "^foobar.*$" // words that begin with foobar will not be checked
            ],
            "minLength": 5
         }
     ],
    "simple-import-sort/imports": "error",
    "simple-import-sort/exports": "error",
    "import/first": "error",
    "import/newline-after-import": "error",
    "import/no-duplicates": "error"
  },
  overrides: [
    {
      files: ['**/*.ts'],
      rules: {
        'no-undef': 'off',
      },

    },
  ],
};
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值