@fenge/eslint-config 0.6.2 → 0.6.4
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/dist/config/javascript.d.ts +1 -1
- package/dist/config/javascript.d.ts.map +1 -1
- package/dist/config/js/base.d.ts +2 -1
- package/dist/config/js/base.d.ts.map +1 -1
- package/dist/config/ts/base.d.ts +2 -1
- package/dist/config/ts/base.d.ts.map +1 -1
- package/dist/config/ts/base.js +2 -1
- package/dist/config/typescript.d.ts +2 -1
- package/dist/config/typescript.d.ts.map +1 -1
- package/dist/eslint.config.d.ts +1 -1
- package/dist/eslint.config.d.ts.map +1 -1
- package/dist/eslint.config.js +1 -1
- package/package.json +9 -6
- package/CHANGELOG.md +0 -301
- package/src/config/base.ts +0 -56
- package/src/config/javascript.test.ts +0 -63
- package/src/config/javascript.ts +0 -8
- package/src/config/js/base.ts +0 -554
- package/src/config/js/cli.ts +0 -14
- package/src/config/js/config.ts +0 -11
- package/src/config/js/test.ts +0 -15
- package/src/config/packagejson.ts +0 -35
- package/src/config/ts/base.ts +0 -238
- package/src/config/ts/cli.ts +0 -13
- package/src/config/ts/config.ts +0 -13
- package/src/config/ts/declaration.ts +0 -13
- package/src/config/ts/test.ts +0 -18
- package/src/config/typescript.test.ts +0 -98
- package/src/config/typescript.ts +0 -15
- package/src/eslint.config.test.ts +0 -108
- package/src/eslint.config.ts +0 -99
- package/src/typing.d.ts +0 -8
- package/test/fixtures.test.ts +0 -101
- package/test/prettier.test.ts +0 -42
- package/tsconfig.json +0 -5
package/src/config/base.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import childProcess from "node:child_process";
|
|
2
|
-
import type { Linter } from "eslint";
|
|
3
|
-
|
|
4
|
-
export type BaseOptions = Linter.LinterOptions;
|
|
5
|
-
|
|
6
|
-
export function base(
|
|
7
|
-
options: BaseOptions,
|
|
8
|
-
enabled: Set<"js" | "ts" | "pkg">,
|
|
9
|
-
): Linter.Config[] {
|
|
10
|
-
const filesMap = {
|
|
11
|
-
js: "**/*.{js,cjs,mjs,jsx}",
|
|
12
|
-
ts: "**/*.{ts,cts,mts,tsx}",
|
|
13
|
-
pkg: "package.json",
|
|
14
|
-
} as const;
|
|
15
|
-
const files = [...enabled].map((key) => filesMap[key]);
|
|
16
|
-
return [
|
|
17
|
-
// Global ignore. Refer: https://eslint.org/docs/latest/use/configure/configuration-files#specifying-files-and-ignores.
|
|
18
|
-
{
|
|
19
|
-
name: "fenge/gitignore",
|
|
20
|
-
// There are 2 kinds of exception when running `git ls-files`:
|
|
21
|
-
// 1. Git is not installed. The `stdout` will be null.
|
|
22
|
-
// 2. The running directory is not initialized by `git init` command. The `stdout` will an empty string.
|
|
23
|
-
ignores: (
|
|
24
|
-
childProcess.spawnSync(
|
|
25
|
-
"git",
|
|
26
|
-
[
|
|
27
|
-
"ls-files",
|
|
28
|
-
"--others",
|
|
29
|
-
"--ignored",
|
|
30
|
-
"--exclude-standard",
|
|
31
|
-
"--directory",
|
|
32
|
-
],
|
|
33
|
-
{ encoding: "utf8" },
|
|
34
|
-
).stdout || ""
|
|
35
|
-
)
|
|
36
|
-
.split("\n")
|
|
37
|
-
.filter(Boolean),
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: "fenge/common",
|
|
41
|
-
files,
|
|
42
|
-
linterOptions: options,
|
|
43
|
-
},
|
|
44
|
-
// Ignore unsupported files.
|
|
45
|
-
// This config is for suppressing error when linting a directory which does not contain supported files.
|
|
46
|
-
{
|
|
47
|
-
name: "fenge/ignore",
|
|
48
|
-
files: ["**"], // I've tried all. Only '**' works.
|
|
49
|
-
ignores: files,
|
|
50
|
-
processor: {
|
|
51
|
-
preprocess: (_text: string, _filename: string) => [""],
|
|
52
|
-
postprocess: (_messages: unknown[][]) => [], // Returning empty array to ignore all errors
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
] as const;
|
|
56
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { describe, it } from "node:test";
|
|
3
|
-
import { javascript } from "./javascript.ts";
|
|
4
|
-
|
|
5
|
-
await describe("js config", async () => {
|
|
6
|
-
await it("js main config value should be error", () => {
|
|
7
|
-
Object.values(javascript()[0].rules).forEach((value) => {
|
|
8
|
-
assert.strictEqual(getValueString(value), "error");
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
await it("js rest configs rules should exist in main rules", () => {
|
|
13
|
-
const [main, ...restConfigs] = javascript();
|
|
14
|
-
restConfigs.forEach((restConfig) => {
|
|
15
|
-
Object.entries(restConfig.rules).forEach(([key, value]) => {
|
|
16
|
-
assert.strictEqual(key in main.rules, true);
|
|
17
|
-
assert.notDeepStrictEqual(value, Reflect.get(main.rules, key));
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
await it("properties in js main config should be valid", () => {
|
|
23
|
-
const jsMainConfig = javascript()[0];
|
|
24
|
-
assert.deepStrictEqual(Object.keys(jsMainConfig), [
|
|
25
|
-
"name",
|
|
26
|
-
"files",
|
|
27
|
-
"languageOptions",
|
|
28
|
-
"plugins",
|
|
29
|
-
"rules",
|
|
30
|
-
]);
|
|
31
|
-
assert.strictEqual(jsMainConfig.name.endsWith("/javascript"), true);
|
|
32
|
-
assert.strictEqual(
|
|
33
|
-
jsMainConfig.files.every((file) => file.endsWith(".{js,cjs,mjs,jsx}")),
|
|
34
|
-
true,
|
|
35
|
-
);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
await it("properties in js rest configs should be valid", () => {
|
|
39
|
-
const [, ...restConfigs] = javascript();
|
|
40
|
-
for (const restConfig of restConfigs) {
|
|
41
|
-
assert.deepStrictEqual(Object.keys(restConfig), [
|
|
42
|
-
"name",
|
|
43
|
-
"files",
|
|
44
|
-
"rules",
|
|
45
|
-
]);
|
|
46
|
-
assert.strictEqual(restConfig.name.includes("/javascript/"), true);
|
|
47
|
-
assert.strictEqual(
|
|
48
|
-
restConfig.files.every((file) => file.endsWith(".{js,cjs,mjs,jsx}")),
|
|
49
|
-
true,
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
function getValueString(value: unknown): string {
|
|
56
|
-
if (typeof value === "string") {
|
|
57
|
-
return value;
|
|
58
|
-
} else if (Array.isArray(value) && typeof value[0] === "string") {
|
|
59
|
-
return value[0];
|
|
60
|
-
} else {
|
|
61
|
-
throw new Error("unknown value");
|
|
62
|
-
}
|
|
63
|
-
}
|
package/src/config/javascript.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { getJsBase } from "./js/base.ts";
|
|
2
|
-
import { getJsCli } from "./js/cli.ts";
|
|
3
|
-
import { getJsConfig } from "./js/config.ts";
|
|
4
|
-
import { getJsTest } from "./js/test.ts";
|
|
5
|
-
|
|
6
|
-
export function javascript() {
|
|
7
|
-
return [getJsBase(), getJsCli(), getJsConfig(), getJsTest()] as const;
|
|
8
|
-
}
|