oxlint@0.0.21 可以指定rules啦

oxlint 官网

oxlint 0.0.21 版本已经可以读取 eslint的配置文件了(体验版)

之前是不可以改变规则的, 我们知道 eslint是拥有非常多的 rules, 现在可以手动配置oxlint的规则, 将更加适配我们的项目个性化需求

shell 复制代码
npx oxlint -c .eslintrc.json

oxlint 可以通过配置文件覆盖所有启用的规则(Configure Rules - ESLint - Pluggable JavaScript Linter)

json 复制代码
{
    "rules": {
        "eqeqeq": "off",
        "curly": "error",
        "quotes": ["error", "double"]
    }
}

命令

shell 复制代码
npx oxlint --help

自动修复

css 复制代码
npx oxlint --fix

忽略文件

shell 复制代码
npx oxlint --ignore-path=PATH 

ignore-path 可以指定配置文件存放路径

例如: 我把 .eslintignore 文件 放在test目录下

ini 复制代码
npx oxlint --ignore-path=./test/.eslintignore

比如,有的文件, oxlint 暂时无法识别或者报错, 但是我们人工判定,不需要处理它, 则可以在项目目录创建一个 .eslintignore 将我们指定文件或者目录配置进去

示例如下: 下面iconfont 文件 我们不需要管它, 可以添加到忽略文件

vbnet 复制代码
  × File is too long to fit on the screen
  help: "src\\assets\\iconFont\\iconfont.js" seems like a minified file

Finished in 29ms on 23 files with 73 rules using 12 threads.
Found 1 warning and 0 errors.

项目根目录新建: .eslintignore

bash 复制代码
src/assets/iconFont

现在,oxlint 不会验证这个目录下的文件

指定eslint 配置文件

shell 复制代码
npx oxlint -c .eslintrc.json

全部命令

sql 复制代码
Usage: oxlint.exe [-A=NAME | -D=NAME]... [--fix] [-c=PATH] [PATH]...

Allowing / Denying Multiple Lints
  For example `-D correctness -A no-debugger` or `-A all -D no-debugger`. ㅤ
  The default category is "-D correctness".
  Use "--rules" for rule names.
  Use "--help --help" for rule categories.
    -A, --allow=NAME          Allow the rule or category (suppress the lint)
    -D, --deny=NAME           Deny the rule or category (emit an error)

Enable Plugins
        --import-plugin       Enable the experimental import plugin and detect ESM problems
        --jest-plugin         Enable the Jest plugin and detect test problems
        --jsx-a11y-plugin     Enable the JSX-a11y plugin and detect accessibility problems

Fix Problems
        --fix                 Fix as many issues as possible. Only unfixed issues are reported in the
                              output

Ignore Files
        --ignore-path=PATH    Specify the file to use as your .eslintignore
        --ignore-pattern=PAT  Specify patterns of files to ignore (in addition to those in .eslintignore)
        --no-ignore           Disables excluding of files from .eslintignore files, --ignore-path flags
                              and --ignore-pattern flags

Handle Warnings
        --quiet               Disable reporting on warnings, only errors are reported
        --deny-warnings       Ensure warnings produce a non-zero exit code
        --max-warnings=INT    Specify a warning threshold, which can be used to force exit with an error
                              status if there are too many warning-level rule violations in your project

Miscellaneous
        --timing              Display the execution time of each lint rule
                              [env:TIMING: not set]
        --rules               list all the rules that are currently registered
        --threads=INT         Number of threads to use. Set to 1 for using only 1 CPU core

Codeowners
        --codeowners-file=PATH  Path to CODEOWNERS file
        --codeowners=NAME     Code owner names, e.g. @Boshen

Available positional items:
    PATH                      Single file, single path or list of paths

Available options:
    -c, --config=PATH         ESLint configuration file (experimental)
    -h, --help                Prints help information

oxlint 迭代飞速, 已经逐步在完善 js, react(jsx), vue等 规则生态, 期待中!

相关推荐
长天一色3 分钟前
【ECMAScript 从入门到进阶教程】第三部分:高级主题(高级函数与范式,元编程,正则表达式,性能优化)
服务器·开发语言·前端·javascript·性能优化·ecmascript
NiNg_1_23420 分钟前
npm、yarn、pnpm之间的区别
前端·npm·node.js
秋殇与星河22 分钟前
CSS总结
前端·css
NiNg_1_23423 分钟前
Vue3 Pinia持久化存储
开发语言·javascript·ecmascript
读心悦24 分钟前
如何在 Axios 中封装事件中心EventEmitter
javascript·http
BigYe程普44 分钟前
我开发了一个出海全栈SaaS工具,还写了一套全栈开发教程
开发语言·前端·chrome·chatgpt·reactjs·个人开发
神之王楠1 小时前
如何通过js加载css和html
javascript·css·html
余生H1 小时前
前端的全栈混合之路Meteor篇:关于前后端分离及与各框架的对比
前端·javascript·node.js·全栈
程序员-珍1 小时前
使用openapi生成前端请求文件报错 ‘Token “Integer“ does not exist.‘
java·前端·spring boot·后端·restful·个人开发
axihaihai1 小时前
网站开发的发展(后端路由/前后端分离/前端路由)
前端