反斜体
有观点认为Oxlint规则拒绝低证据和低信号的TypeScript和JavaScript模式.
这个项目的用意是销售,而不是作为固定npm依赖。 将规则复制到您的寄存器中,读取,并修改,以符合您的团队标准. 捆绑的代理技能处理初始复制和配置;之后,卖出的文件由您维护并自行制作.
用代理技能安装
npx skills add dmmulroy/anti-slop --skill install-anti-slop
然后请您的编码代理在当前的寄存器中安装或配置反斜体 。 技能复制了插件,安装了当前Oxlint的依赖性,将插件合并到现有的林特配置中,使每个通用规则都能够实现,并验证结果. 在依赖于Effect的寄存器中,它也使选择生效规则组成为可能.
首先检查现有技能:
npx skills add dmmulroy/anti-slop --list
手动本地安装
复制 src/ 输入目标存储器,例如 tools/oxlint/anti-slop/,并安装匹配当前版本的 oxlint 财务报告和审定财务报表 @oxlint/plugins。 。 。 .
注册在 oxlint.config.ts数字 :
import { defineConfig } from "oxlint";
export default defineConfig({
ignorePatterns: [
".agent/**",
".agents/**",
".claude/**",
".codex/**",
".continue/**",
".cursor/**",
".gemini/**",
".opencode/**",
".pi/**",
".roo/**",
".windsurf/**",
"tools/oxlint/anti-slop/**",
],
jsPlugins: [
{ name: "anti-slop", specifier: "./tools/oxlint/anti-slop/index.ts" },
],
rules: {
"anti-slop/no-chained-type-assertions": "error",
"anti-slop/no-conditional-empty-object-spread": "error",
"anti-slop/no-known-value-widening": "error",
"anti-slop/no-module-mocking": "error",
"anti-slop/no-object-parameters": "error",
"anti-slop/no-reflect-apply": "error",
"anti-slop/no-reflect-get": "error",
"anti-slop/no-runtime-typeof": "error",
"anti-slop/no-shape-in-symbol-names": "error",
"anti-slop/no-unknown-parameters": "error",
"anti-slop/no-unknown-returns": "error",
"anti-slop/no-unknown-type-aliases": "error",
"anti-slop/no-unsafe-dictionary-type": "error",
"anti-slop/no-widen-then-assert": "error",
"anti-slop/require-safety-comment-for-type-assertion": "error"
}
});
一样 ignorePatterns, (中文(简体) ), jsPlugins和规则 lint 在 Vite+ 配置中。 将忽略模式合并到 Vite+ 的 fmt.ignorePatterns 也一样 vp check 不重构已安装的代理资产或供应商插件。 保存已存在的已忽略并添加在寄存器中检测到的任何其他工程本地代理工具目录;不广泛忽略每个点目录.
可选效果规则
效果特定规则生活在单独的插件中,因此不使用效果的项目不会继承效果架构政策. 仅在使用效果的寄存器中注册效果切入点:
export default defineConfig({
jsPlugins: [
{ name: "anti-slop", specifier: "./tools/oxlint/anti-slop/index.ts" },
{
name: "anti-slop-effect",
specifier: "./tools/oxlint/anti-slop/effect/index.ts"
}
],
rules: {
"anti-slop-effect/no-service-constructor-imports": "error"
}
});
规则
通则
no-chained-type-assertions——拒绝编造出证据的巢类断言.no-conditional-empty-object-spread- 拒绝使用的条件差{}以略去字段.no-known-value-widening——拒绝明确而广泛的目标类型来抛弃已知的价值证据.no-module-mocking——拒绝Vitest和Jest模块为取而代之的是真正的依赖接合.no-object-parameters- 拒绝广泛object键入函数输入.no-reflect-apply- 拒绝Reflect.apply用于键入函数调用.no-reflect-get- 拒绝Reflect.get倾向于打入财产或解析边界.no-runtime-typeof- 需要解析边界而不是临时解析typeof缩小.no-shape-in-symbol-names- 拒绝shape在符号名称中.no-unknown-parameters- 拒绝unknown输入,但明确cause公约.no-unknown-returns拒绝返回的函数合同unknown或者说Promise<unknown>。 。 。 .no-unknown-type-aliases- 拒绝只是隐瞒的别名unknown。 。 。 .no-unsafe-dictionary-type- 拒绝基于unknown, (中文(简体) ),any, (中文(简体) ),object, (中文(简体) ),{},和语义等同.no-widen-then-assert——拒绝拓宽已知价值的本地流动,后又加以回溯.require-safety-comment-for-type-assertion要求每个非一致的断言记录其检查的无变化性.
效果规则
no-service-constructor-imports- 拒绝出口的相对项目进口make<CapabilityName>外部构造器*.test.*财务报告和审定财务报表*.spec.*文档。 运行时调用者应导入自有的图层并生成背景服务。 进口包和静态构造器,例如:WorkspaceName.make不在规则范围内.
违规事例
下面的每个片段被命名规则所拒绝.
no-chained-type-assertions
const user = input as object as User;
no-conditional-empty-object-spread
const options = {
...(timeout !== undefined ? { timeout } : {}),
};
no-known-value-widening
const handlers: Record<string, Handler> = {
start: startHandler,
};
丢弃已知的 start 键。 保留推断或使用 satisfies Record<string, Handler> 换句话说.
no-module-mocking
vi.mock("./user-store");
no-object-parameters
function save(value: object) {}
no-reflect-apply
const value = Reflect.apply(operation, owner, args);
no-reflect-get
const value = Reflect.get(owner, key);
no-runtime-typeof
if (typeof input === "string") {
useName(input);
}
无项目可以允许 typeof 直接检查类型上游和
在继续拒绝在其他地方进行特别检查的同时,保留功能:
{
"anti-slop/no-runtime-typeof": [
"error",
{ "allowInTypeGuards": true }
]
}
选项默认为 false。 。 。 .
no-shape-in-symbol-names
interface UserShape {
id: string;
}
效果 : no-service-constructor-imports
import { makeIssueService } from "./issue-service.ts";
导入自有图层并生成 IssueService 换句话说 重点 *.test.* 财务报告和审定财务报表 *.spec.* 文件可能直接导入构建器 .
no-unknown-parameters
function handle(input: unknown) {}
no-unknown-returns
function loadUser(): unknown {
return input;
}
no-unknown-type-aliases
type ExternalValue = unknown;
no-unsafe-dictionary-type
type Metadata = Record<string, unknown>;
type OtherMetadata = { [key: string]: object };
no-widen-then-assert
const loaded: User = loadUser();
const stored: unknown = loaded;
const user = stored as User;
require-safety-comment-for-type-assertion
const userId = value as UserId;
在必要的断言之前增加具体理由:
// SAFETY: parseUserId validated the identifier before branding it.
const userId = value as UserId;
发展
pnpm install
pnpm check
src/ 简直太夸张了 改变生产来源后运行 pnpm sync:skill-assets; CI 检查该技能捆绑的拷贝是否仍然相同.
许可证
麻省理工学院