@antfu/eslint-config 9.4.0 → 9.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +1841 -189
- package/dist/index.mjs +76 -7
- package/package.json +13 -3
package/README.md
CHANGED
|
@@ -814,6 +814,50 @@ Running `npx eslint` should prompt you to install the required dependencies, oth
|
|
|
814
814
|
npm i -D @angular-eslint/eslint-plugin @angular-eslint/eslint-plugin-template @angular-eslint/template-parser
|
|
815
815
|
```
|
|
816
816
|
|
|
817
|
+
#### Anti-Slop
|
|
818
|
+
|
|
819
|
+
> [!WARNING]
|
|
820
|
+
> Experimental: the enabled rule set is maintained in-house and may change in any release without following semver.
|
|
821
|
+
|
|
822
|
+
To guard against low-value code patterns commonly introduced by AI agents, you can explicitly turn on the anti-slop rules:
|
|
823
|
+
|
|
824
|
+
```js
|
|
825
|
+
// eslint.config.js
|
|
826
|
+
import antfu from '@antfu/eslint-config'
|
|
827
|
+
|
|
828
|
+
export default antfu({
|
|
829
|
+
antislop: true,
|
|
830
|
+
})
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
This enables [`eslint-plugin-slop`](https://github.com/antfu/eslint-plugin-slop) and a curated, in-house maintained subset of [`eslint-plugin-sonarjs`](https://github.com/SonarSource/SonarJS) rules focusing on redundant and duplicated code. It also disallows explicit `any` when TypeScript is enabled (inspired by [this writeup on keeping AI-authored code clean](https://zenn.dev/singularity/articles/clean-code-ci-for-ai-era)).
|
|
834
|
+
|
|
835
|
+
You can toggle each plugin and pass options to `eslint-plugin-slop`:
|
|
836
|
+
|
|
837
|
+
```js
|
|
838
|
+
// eslint.config.js
|
|
839
|
+
import antfu from '@antfu/eslint-config'
|
|
840
|
+
|
|
841
|
+
export default antfu({
|
|
842
|
+
antislop: {
|
|
843
|
+
sonarjs: false,
|
|
844
|
+
// an object enables `eslint-plugin-slop` and is forwarded to it
|
|
845
|
+
// via `settings.slop`, for example to only inspect recently changed code
|
|
846
|
+
slop: {
|
|
847
|
+
inspection: { mode: 'recent-changes', tracebackCommits: 5 },
|
|
848
|
+
},
|
|
849
|
+
},
|
|
850
|
+
})
|
|
851
|
+
```
|
|
852
|
+
|
|
853
|
+
Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
|
|
854
|
+
|
|
855
|
+
```bash
|
|
856
|
+
npm i -D eslint-plugin-slop eslint-plugin-sonarjs
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
Since linters only see one file at a time, we recommend pairing this option with [`jscpd`](https://github.com/kucherenko/jscpd) to detect copy-paste duplication across files, and [`knip`](https://knip.dev) to find unused files, dependencies, and exports.
|
|
860
|
+
|
|
817
861
|
### Optional Rules
|
|
818
862
|
|
|
819
863
|
This config also provides some optional plugins/rules for extended usage.
|
package/dist/cli.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { cac } from "cac";
|
|
|
8
8
|
import parse from "parse-gitignore";
|
|
9
9
|
import { execSync } from "node:child_process";
|
|
10
10
|
//#region package.json
|
|
11
|
-
var version = "9.
|
|
11
|
+
var version = "9.5.0";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/cli/constants.ts
|
|
14
14
|
const vscodeSettingsString = `
|