eslint/max-lines Pedantic
作用
强制限制每个文件的最大行数。
为什么不好?
有些人认为大文件是一种代码异味。大文件往往包含过多功能,导致难以理解代码逻辑。虽然文件中可接受的最大行数没有客观标准,但大多数人会同意不应达到数千行。建议通常在 100 到 500 行之间。
配置
此规则接受一个包含以下属性的配置对象:
max
type: integer
default: 300
每个文件允许的最大行数。
skipBlankLines
type: boolean
default: false
计数时是否忽略空行。
skipComments
type: boolean
default: false
计数时是否忽略注释。
使用方法
To enable this rule using the config file or in the CLI, you can use:
json
{
"rules": {
"max-lines": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
rules: {
"max-lines": "error",
},
});bash
oxlint --deny max-lines版本
此规则已在 v0.2.14 中添加。
