@mlaursen/eslint-config 12.0.5 → 12.0.7
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/index.d.ts +296 -13
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +645 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +31 -21
- package/src/constants.ts +2 -2
- package/src/react.ts +2 -2
- package/dist/base.d.ts +0 -11
- package/dist/base.js +0 -51
- package/dist/constants.d.ts +0 -12
- package/dist/constants.js +0 -15
- package/dist/gitignore.d.ts +0 -23
- package/dist/gitignore.js +0 -26
- package/dist/index.js +0 -28
- package/dist/jsxA11y.d.ts +0 -11
- package/dist/jsxA11y.js +0 -37
- package/dist/mui.d.ts +0 -2
- package/dist/mui.js +0 -16
- package/dist/react.d.ts +0 -57
- package/dist/react.js +0 -82
- package/dist/recommended.d.ts +0 -18
- package/dist/recommended.js +0 -45
- package/dist/recommendedFrontend.d.ts +0 -18
- package/dist/recommendedFrontend.js +0 -46
- package/dist/scripts.d.ts +0 -11
- package/dist/scripts.js +0 -19
- package/dist/testing-library.d.ts +0 -35
- package/dist/testing-library.js +0 -57
- package/dist/testing.d.ts +0 -54
- package/dist/testing.js +0 -112
- package/dist/typescript.d.ts +0 -41
- package/dist/typescript.js +0 -161
- package/dist/unicorn.d.ts +0 -2
- package/dist/unicorn.js +0 -56
package/dist/recommended.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
-
if (!m) return o;
|
|
4
|
-
var i = m.call(o), r, ar = [], e;
|
|
5
|
-
try {
|
|
6
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
-
}
|
|
8
|
-
catch (error) { e = { error: error }; }
|
|
9
|
-
finally {
|
|
10
|
-
try {
|
|
11
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
-
}
|
|
13
|
-
finally { if (e) throw e.error; }
|
|
14
|
-
}
|
|
15
|
-
return ar;
|
|
16
|
-
};
|
|
17
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
|
-
if (ar || !(i in from)) {
|
|
20
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21
|
-
ar[i] = from[i];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
|
-
};
|
|
26
|
-
import { scripts } from "./scripts.js";
|
|
27
|
-
import { testing } from "./testing.js";
|
|
28
|
-
import { typescript } from "./typescript.js";
|
|
29
|
-
import { unicorn } from "./unicorn.js";
|
|
30
|
-
/**
|
|
31
|
-
* @example
|
|
32
|
-
* ```ts
|
|
33
|
-
* import { configs, gitignore } from "@mlaursen/eslint-config";
|
|
34
|
-
* import { defineConfig } from "eslint/config";
|
|
35
|
-
*
|
|
36
|
-
* export default defineConfig([
|
|
37
|
-
* gitignore(import.meta.url),
|
|
38
|
-
* ...configs.recommended(),
|
|
39
|
-
* ]);
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export var recommended = function (options) {
|
|
43
|
-
if (options === void 0) { options = {}; }
|
|
44
|
-
return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(typescript(options)), false), __read(scripts), false), __read(testing(options)), false), __read(unicorn), false);
|
|
45
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type Linter } from "eslint";
|
|
2
|
-
import { type ReactOptions } from "./react.js";
|
|
3
|
-
import { type RecommendedOptions } from "./recommended.js";
|
|
4
|
-
export interface RecommendedFrontendOptions extends RecommendedOptions, ReactOptions {
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import { configs, gitignore } from "@mlaursen/eslint-config";
|
|
10
|
-
* import { defineConfig } from "eslint/config";
|
|
11
|
-
*
|
|
12
|
-
* export default defineConfig([
|
|
13
|
-
* gitignore(import.meta.url),
|
|
14
|
-
* ...configs.recommendedFrontend(),
|
|
15
|
-
* ]);
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare const recommendedFrontend: (options?: RecommendedFrontendOptions) => readonly Linter.Config[];
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
-
if (!m) return o;
|
|
4
|
-
var i = m.call(o), r, ar = [], e;
|
|
5
|
-
try {
|
|
6
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
-
}
|
|
8
|
-
catch (error) { e = { error: error }; }
|
|
9
|
-
finally {
|
|
10
|
-
try {
|
|
11
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
-
}
|
|
13
|
-
finally { if (e) throw e.error; }
|
|
14
|
-
}
|
|
15
|
-
return ar;
|
|
16
|
-
};
|
|
17
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
|
-
if (ar || !(i in from)) {
|
|
20
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21
|
-
ar[i] = from[i];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
|
-
};
|
|
26
|
-
import { jsxA11y } from "./jsxA11y.js";
|
|
27
|
-
import { mui } from "./mui.js";
|
|
28
|
-
import { react } from "./react.js";
|
|
29
|
-
import { recommended } from "./recommended.js";
|
|
30
|
-
import { testingLibraryReact } from "./testing-library.js";
|
|
31
|
-
/**
|
|
32
|
-
* @example
|
|
33
|
-
* ```ts
|
|
34
|
-
* import { configs, gitignore } from "@mlaursen/eslint-config";
|
|
35
|
-
* import { defineConfig } from "eslint/config";
|
|
36
|
-
*
|
|
37
|
-
* export default defineConfig([
|
|
38
|
-
* gitignore(import.meta.url),
|
|
39
|
-
* ...configs.recommendedFrontend(),
|
|
40
|
-
* ]);
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
export var recommendedFrontend = function (options) {
|
|
44
|
-
if (options === void 0) { options = {}; }
|
|
45
|
-
return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(recommended(options)), false), __read(mui), false), __read(react(options)), false), __read(jsxA11y), false), __read(testingLibraryReact), false);
|
|
46
|
-
};
|
package/dist/scripts.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Linter } from "eslint";
|
|
2
|
-
/**
|
|
3
|
-
* @example
|
|
4
|
-
* ```ts
|
|
5
|
-
* import { configs } from "@mlaursen/eslint-config";
|
|
6
|
-
* import { defineConfig } from "eslint/config";
|
|
7
|
-
*
|
|
8
|
-
* export default defineConfig(configs.scripts);
|
|
9
|
-
* ```
|
|
10
|
-
*/
|
|
11
|
-
export declare const scripts: Linter.Config[];
|
package/dist/scripts.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BASE_NAME } from "./constants.js";
|
|
2
|
-
/**
|
|
3
|
-
* @example
|
|
4
|
-
* ```ts
|
|
5
|
-
* import { configs } from "@mlaursen/eslint-config";
|
|
6
|
-
* import { defineConfig } from "eslint/config";
|
|
7
|
-
*
|
|
8
|
-
* export default defineConfig(configs.scripts);
|
|
9
|
-
* ```
|
|
10
|
-
*/
|
|
11
|
-
export var scripts = [
|
|
12
|
-
{
|
|
13
|
-
name: "".concat(BASE_NAME, "/scripts"),
|
|
14
|
-
files: ["scripts/**"],
|
|
15
|
-
rules: {
|
|
16
|
-
"no-console": "off",
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
];
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { type Linter } from "eslint";
|
|
2
|
-
/**
|
|
3
|
-
* @example
|
|
4
|
-
* ```ts
|
|
5
|
-
* import { configs } from "@mlaursen/eslint-config";
|
|
6
|
-
* import { defineConfig } from "eslint/config";
|
|
7
|
-
*
|
|
8
|
-
* export default defineConfig([
|
|
9
|
-
* ...configs.react,
|
|
10
|
-
* ...configs.jest,
|
|
11
|
-
* ...configs.jestDom,
|
|
12
|
-
* ...configs.testingLibraryReact
|
|
13
|
-
* ]);
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* NOTE: Only choose this or the {@link testingLibraryDom}. Do not use
|
|
17
|
-
* both.
|
|
18
|
-
*/
|
|
19
|
-
export declare const testingLibraryReact: Linter.Config[];
|
|
20
|
-
/**
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* import { configs, defineConfig } from "@mlaursen/eslint-config";
|
|
24
|
-
*
|
|
25
|
-
* export default defineConfig([
|
|
26
|
-
* ...configs.jest,
|
|
27
|
-
* ...configs.jestDom,
|
|
28
|
-
* ...configs.testingLibraryDom
|
|
29
|
-
* ]);
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* NOTE: Only choose this or the {@link testingLibraryReact}. Do not use
|
|
33
|
-
* both.
|
|
34
|
-
*/
|
|
35
|
-
export declare const testingLibraryDom: Linter.Config[];
|
package/dist/testing-library.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import testingLibraryPlugin from "eslint-plugin-testing-library";
|
|
13
|
-
import { BASE_NAME, TEST_FILES } from "./constants.js";
|
|
14
|
-
/**
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* import { configs } from "@mlaursen/eslint-config";
|
|
18
|
-
* import { defineConfig } from "eslint/config";
|
|
19
|
-
*
|
|
20
|
-
* export default defineConfig([
|
|
21
|
-
* ...configs.react,
|
|
22
|
-
* ...configs.jest,
|
|
23
|
-
* ...configs.jestDom,
|
|
24
|
-
* ...configs.testingLibraryReact
|
|
25
|
-
* ]);
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* NOTE: Only choose this or the {@link testingLibraryDom}. Do not use
|
|
29
|
-
* both.
|
|
30
|
-
*/
|
|
31
|
-
export var testingLibraryReact = [
|
|
32
|
-
__assign(__assign({ name: "".concat(BASE_NAME, "/testing-library/react"), files: TEST_FILES }, testingLibraryPlugin.configs["flat/react"]), { rules: __assign(__assign({}, testingLibraryPlugin.configs["flat/react"].rules), {
|
|
33
|
-
// it can be useful to reassign screen.* queries without reusing to
|
|
34
|
-
// verify it still exists
|
|
35
|
-
"no-useless-assignment": "off" }) }),
|
|
36
|
-
];
|
|
37
|
-
/**
|
|
38
|
-
* @example
|
|
39
|
-
* ```ts
|
|
40
|
-
* import { configs, defineConfig } from "@mlaursen/eslint-config";
|
|
41
|
-
*
|
|
42
|
-
* export default defineConfig([
|
|
43
|
-
* ...configs.jest,
|
|
44
|
-
* ...configs.jestDom,
|
|
45
|
-
* ...configs.testingLibraryDom
|
|
46
|
-
* ]);
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* NOTE: Only choose this or the {@link testingLibraryReact}. Do not use
|
|
50
|
-
* both.
|
|
51
|
-
*/
|
|
52
|
-
export var testingLibraryDom = [
|
|
53
|
-
__assign(__assign({ name: "".concat(BASE_NAME, "/testing-library/dom"), files: TEST_FILES }, testingLibraryPlugin.configs["flat/dom"]), { rules: __assign(__assign({}, testingLibraryPlugin.configs["flat/dom"].rules), {
|
|
54
|
-
// it can be useful to reassign screen.* queries without reusing to
|
|
55
|
-
// verify it still exists
|
|
56
|
-
"no-useless-assignment": "off" }) }),
|
|
57
|
-
];
|
package/dist/testing.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { type Linter } from "eslint";
|
|
2
|
-
export type TestFramework = "jest" | "vitest";
|
|
3
|
-
export interface TestOptions {
|
|
4
|
-
/**
|
|
5
|
-
* @defaultValue `"vitest"`
|
|
6
|
-
*/
|
|
7
|
-
testFramework?: TestFramework;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { configs } from "@mlaursen/eslint-config";
|
|
13
|
-
* import { defineConfig } from "eslint/config";
|
|
14
|
-
*
|
|
15
|
-
* export default defineConfig(configs.vitest);
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare const vitest: Linter.Config[];
|
|
19
|
-
/**
|
|
20
|
-
* @example
|
|
21
|
-
* ```ts
|
|
22
|
-
* import { configs } from "@mlaursen/eslint-config";
|
|
23
|
-
* import { defineConfig } from "eslint/config";
|
|
24
|
-
*
|
|
25
|
-
* export default defineConfig(configs.jest);
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare const jest: Linter.Config[];
|
|
29
|
-
/**
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* import { configs } from "@mlaursen/eslint-config";
|
|
33
|
-
* import { defineConfig } from "eslint/config";
|
|
34
|
-
*
|
|
35
|
-
* export default defineConfig([
|
|
36
|
-
* ...configs.jest,
|
|
37
|
-
* ...configs.jestDom,
|
|
38
|
-
* ]);
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export declare const jestDom: Linter.Config[];
|
|
42
|
-
/**
|
|
43
|
-
* @example
|
|
44
|
-
* ```ts
|
|
45
|
-
* import { configs } from "@mlaursen/eslint-config";
|
|
46
|
-
* import { defineConfig } from "eslint/config";
|
|
47
|
-
*
|
|
48
|
-
* export default defineConfig(configs.testing({ testFramework: "jest" }));
|
|
49
|
-
*
|
|
50
|
-
* // or
|
|
51
|
-
* export default defineConfig(configs.testing({ testFramework: "vitest" }));
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
export declare const testing: (options?: TestOptions) => Linter.Config[];
|
package/dist/testing.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
-
if (!m) return o;
|
|
15
|
-
var i = m.call(o), r, ar = [], e;
|
|
16
|
-
try {
|
|
17
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
-
}
|
|
19
|
-
catch (error) { e = { error: error }; }
|
|
20
|
-
finally {
|
|
21
|
-
try {
|
|
22
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
-
}
|
|
24
|
-
finally { if (e) throw e.error; }
|
|
25
|
-
}
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
29
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
30
|
-
if (ar || !(i in from)) {
|
|
31
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
32
|
-
ar[i] = from[i];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
|
-
};
|
|
37
|
-
import vitestPlugin from "@vitest/eslint-plugin";
|
|
38
|
-
import jestPlugin from "eslint-plugin-jest";
|
|
39
|
-
import jestDomPlugin from "eslint-plugin-jest-dom";
|
|
40
|
-
import { BASE_NAME, DEV_OFF_PROD_ERROR, TEST_FILES } from "./constants.js";
|
|
41
|
-
/**
|
|
42
|
-
* @example
|
|
43
|
-
* ```ts
|
|
44
|
-
* import { configs } from "@mlaursen/eslint-config";
|
|
45
|
-
* import { defineConfig } from "eslint/config";
|
|
46
|
-
*
|
|
47
|
-
* export default defineConfig(configs.vitest);
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export var vitest = [
|
|
51
|
-
{
|
|
52
|
-
name: "".concat(BASE_NAME, "/vitest"),
|
|
53
|
-
files: TEST_FILES,
|
|
54
|
-
plugins: {
|
|
55
|
-
vitest: vitestPlugin,
|
|
56
|
-
},
|
|
57
|
-
rules: __assign(__assign({}, vitestPlugin.configs.recommended.rules), { "vitest/no-alias-methods": "error", "vitest/no-focused-tests": DEV_OFF_PROD_ERROR, "vitest/no-disabled-tests": DEV_OFF_PROD_ERROR, "vitest/no-duplicate-hooks": "error", "vitest/no-standalone-expect": "error", "vitest/prefer-expect-resolves": "error", "vitest/prefer-spy-on": "error", "vitest/prefer-vi-mocked": "error" }),
|
|
58
|
-
},
|
|
59
|
-
];
|
|
60
|
-
/**
|
|
61
|
-
* @example
|
|
62
|
-
* ```ts
|
|
63
|
-
* import { configs } from "@mlaursen/eslint-config";
|
|
64
|
-
* import { defineConfig } from "eslint/config";
|
|
65
|
-
*
|
|
66
|
-
* export default defineConfig(configs.jest);
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
export var jest = [
|
|
70
|
-
__assign({ name: "".concat(BASE_NAME, "/jest"), files: TEST_FILES }, jestPlugin.configs["flat/recommended"]),
|
|
71
|
-
];
|
|
72
|
-
/**
|
|
73
|
-
* @example
|
|
74
|
-
* ```ts
|
|
75
|
-
* import { configs } from "@mlaursen/eslint-config";
|
|
76
|
-
* import { defineConfig } from "eslint/config";
|
|
77
|
-
*
|
|
78
|
-
* export default defineConfig([
|
|
79
|
-
* ...configs.jest,
|
|
80
|
-
* ...configs.jestDom,
|
|
81
|
-
* ]);
|
|
82
|
-
* ```
|
|
83
|
-
*/
|
|
84
|
-
export var jestDom = [
|
|
85
|
-
__assign({ name: "".concat(BASE_NAME, "/jest-dom"), files: TEST_FILES }, jestDomPlugin.configs["flat/recommended"]),
|
|
86
|
-
];
|
|
87
|
-
/**
|
|
88
|
-
* @example
|
|
89
|
-
* ```ts
|
|
90
|
-
* import { configs } from "@mlaursen/eslint-config";
|
|
91
|
-
* import { defineConfig } from "eslint/config";
|
|
92
|
-
*
|
|
93
|
-
* export default defineConfig(configs.testing({ testFramework: "jest" }));
|
|
94
|
-
*
|
|
95
|
-
* // or
|
|
96
|
-
* export default defineConfig(configs.testing({ testFramework: "vitest" }));
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
export var testing = function (options) {
|
|
100
|
-
if (options === void 0) { options = {}; }
|
|
101
|
-
var _a = options.testFramework, testFramework = _a === void 0 ? "vitest" : _a;
|
|
102
|
-
var config;
|
|
103
|
-
switch (testFramework) {
|
|
104
|
-
case "jest":
|
|
105
|
-
config = jest;
|
|
106
|
-
break;
|
|
107
|
-
case "vitest":
|
|
108
|
-
config = vitest;
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
return __spreadArray(__spreadArray([], __read(config), false), __read(jestDom), false);
|
|
112
|
-
};
|
package/dist/typescript.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { type Linter } from "eslint";
|
|
2
|
-
export interface TypescriptOptions {
|
|
3
|
-
/**
|
|
4
|
-
* This is required when working in monorepos or when the
|
|
5
|
-
* {@link strictTypeChecked} rules are enabled.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```js
|
|
9
|
-
* configs.recommended({
|
|
10
|
-
* tsconfigRootDir: import.meta.dirname,
|
|
11
|
-
* })
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
tsconfigRootDir?: string;
|
|
15
|
-
/**
|
|
16
|
-
* The {@link tsconfigRootDir} must be set if this is `true`.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```js
|
|
20
|
-
* configs.recommended({
|
|
21
|
-
* tsconfigRootDir: import.meta.dirname,
|
|
22
|
-
* strictTypeChecked: process.env.STRICT_TYPING === "true",
|
|
23
|
-
* })
|
|
24
|
-
*
|
|
25
|
-
* @defaultValue `false`
|
|
26
|
-
*/
|
|
27
|
-
strictTypeChecked?: boolean;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* import { configs, gitignore } from "@mlaursen/eslint-config";
|
|
33
|
-
* import { defineConfig } from "eslint/config";
|
|
34
|
-
*
|
|
35
|
-
* export default defineConfig([
|
|
36
|
-
* gitignore(import.meta.url),
|
|
37
|
-
* ...configs.typescript(),
|
|
38
|
-
* ]);
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export declare const typescript: (options?: TypescriptOptions) => Linter.Config[];
|
package/dist/typescript.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
-
if (!m) return o;
|
|
4
|
-
var i = m.call(o), r, ar = [], e;
|
|
5
|
-
try {
|
|
6
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
-
}
|
|
8
|
-
catch (error) { e = { error: error }; }
|
|
9
|
-
finally {
|
|
10
|
-
try {
|
|
11
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
-
}
|
|
13
|
-
finally { if (e) throw e.error; }
|
|
14
|
-
}
|
|
15
|
-
return ar;
|
|
16
|
-
};
|
|
17
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
18
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
19
|
-
if (ar || !(i in from)) {
|
|
20
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
21
|
-
ar[i] = from[i];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
25
|
-
};
|
|
26
|
-
import tseslint from "typescript-eslint";
|
|
27
|
-
import { base } from "./base.js";
|
|
28
|
-
import { BASE_NAME, TEST_FILES, TS_FILES, VITE_MAIN_FILES, } from "./constants.js";
|
|
29
|
-
/**
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* import { configs, gitignore } from "@mlaursen/eslint-config";
|
|
33
|
-
* import { defineConfig } from "eslint/config";
|
|
34
|
-
*
|
|
35
|
-
* export default defineConfig([
|
|
36
|
-
* gitignore(import.meta.url),
|
|
37
|
-
* ...configs.typescript(),
|
|
38
|
-
* ]);
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export var typescript = function (options) {
|
|
42
|
-
if (options === void 0) { options = {}; }
|
|
43
|
-
var tsconfigRootDir = options.tsconfigRootDir, strictTypeChecked = options.strictTypeChecked;
|
|
44
|
-
var configs = __spreadArray(__spreadArray(__spreadArray([], __read(base), false), __read(tseslint.configs.strict), false), [
|
|
45
|
-
{
|
|
46
|
-
name: "".concat(BASE_NAME, "/typescript"),
|
|
47
|
-
files: TS_FILES,
|
|
48
|
-
rules: {
|
|
49
|
-
// I normally do not want unified signatures since it helps improve type
|
|
50
|
-
// inference with function overloading
|
|
51
|
-
"@typescript-eslint/unified-signatures": "off",
|
|
52
|
-
// I prefer specifying when something is used only as a type
|
|
53
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
54
|
-
"error",
|
|
55
|
-
{ fixStyle: "inline-type-imports" },
|
|
56
|
-
],
|
|
57
|
-
// I prefer shorthand syntax
|
|
58
|
-
"@typescript-eslint/array-type": ["error", { default: "array" }],
|
|
59
|
-
// I prefer using `interface` over `type = {}`
|
|
60
|
-
"@typescript-eslint/consistent-type-definitions": [
|
|
61
|
-
"error",
|
|
62
|
-
"interface",
|
|
63
|
-
],
|
|
64
|
-
// Allow expressions to work with react hooks. Annoying to have to
|
|
65
|
-
// typedef each arrow function in a `useEffect` or `useCallback` when
|
|
66
|
-
// it can be derived.
|
|
67
|
-
"@typescript-eslint/explicit-function-return-type": [
|
|
68
|
-
"error",
|
|
69
|
-
{
|
|
70
|
-
allowExpressions: true,
|
|
71
|
-
// allow FC definitions for React
|
|
72
|
-
allowTypedFunctionExpressions: true,
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
"@typescript-eslint/no-unused-vars": [
|
|
76
|
-
"error",
|
|
77
|
-
{
|
|
78
|
-
argsIgnorePattern: "^_",
|
|
79
|
-
varsIgnorePattern: "^_",
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
"no-use-before-define": "off",
|
|
83
|
-
"@typescript-eslint/no-use-before-define": [
|
|
84
|
-
"warn",
|
|
85
|
-
{ ignoreTypeReferences: true },
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
name: "".concat(BASE_NAME, "/typescript/tests"),
|
|
91
|
-
files: TEST_FILES,
|
|
92
|
-
rules: {
|
|
93
|
-
// allow tests to be less strict
|
|
94
|
-
"@typescript-eslint/ban-ts-comment": "off",
|
|
95
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
96
|
-
"@typescript-eslint/no-empty-function": "off",
|
|
97
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
98
|
-
"@typescript-eslint/no-object-literal-type-assertion": "off",
|
|
99
|
-
"@typescript-eslint/no-var-requires": "off",
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
name: "".concat(BASE_NAME, "/typescript/vite"),
|
|
104
|
-
files: VITE_MAIN_FILES,
|
|
105
|
-
rules: {
|
|
106
|
-
// allow `createRoot(document.getElementById("root")).render(...)` for
|
|
107
|
-
// `vite` without disabling eslint
|
|
108
|
-
"@typescript-eslint/no-non-null-assertion": "off",
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
], false);
|
|
112
|
-
if (tsconfigRootDir) {
|
|
113
|
-
configs.push({
|
|
114
|
-
name: "".concat(BASE_NAME, "/typescript-type-checking-language-options"),
|
|
115
|
-
languageOptions: {
|
|
116
|
-
parserOptions: {
|
|
117
|
-
projectService: strictTypeChecked,
|
|
118
|
-
tsconfigRootDir: tsconfigRootDir,
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
if (strictTypeChecked) {
|
|
124
|
-
configs.push.apply(configs, __spreadArray(__spreadArray([], __read(tseslint.configs.strictTypeCheckedOnly), false), [{
|
|
125
|
-
name: "".concat(BASE_NAME, "/typescript-type-checking"),
|
|
126
|
-
files: TS_FILES,
|
|
127
|
-
rules: {
|
|
128
|
-
// I do not enable the `noUncheckedIndexedAccess` tsconfig option, so I
|
|
129
|
-
// still need to verify that stuff exists. There are other cases where I
|
|
130
|
-
// know it exists, so I can ignore those as well
|
|
131
|
-
"@typescript-eslint/no-unnecessary-condition": "off",
|
|
132
|
-
// I never use `this`
|
|
133
|
-
"@typescript-eslint/unbound-method": "off",
|
|
134
|
-
"@typescript-eslint/restrict-template-expressions": [
|
|
135
|
-
"error",
|
|
136
|
-
{
|
|
137
|
-
allowNumber: true,
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
// I want to allow `onClick={async (event) => { ... }}`
|
|
141
|
-
"@typescript-eslint/no-misused-promises": [
|
|
142
|
-
"error",
|
|
143
|
-
{
|
|
144
|
-
checksVoidReturn: false,
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
name: "".concat(BASE_NAME, "/typescript-type-checking/tests"),
|
|
151
|
-
files: TEST_FILES,
|
|
152
|
-
rules: {
|
|
153
|
-
// like base typescript, can be less strict in tests
|
|
154
|
-
"@typescript-eslint/no-unsafe-return": "off",
|
|
155
|
-
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
156
|
-
"@typescript-eslint/restrict-template-expressions": "off",
|
|
157
|
-
},
|
|
158
|
-
}], false));
|
|
159
|
-
}
|
|
160
|
-
return configs;
|
|
161
|
-
};
|
package/dist/unicorn.d.ts
DELETED
package/dist/unicorn.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { BASE_NAME, TEST_FILES, VITE_MAIN_FILES } from "./constants.js";
|
|
13
|
-
import eslintPluiginUnicorn from "eslint-plugin-unicorn";
|
|
14
|
-
export var unicorn = [
|
|
15
|
-
__assign(__assign({}, eslintPluiginUnicorn.configs.recommended), { name: "".concat(BASE_NAME, "/unicorn"), rules: __assign(__assign({}, eslintPluiginUnicorn.configs.recommended.rules), {
|
|
16
|
-
// this flags `dist` and `dest` which is annoying
|
|
17
|
-
"unicorn/prevent-abbreviations": "off",
|
|
18
|
-
// I do not like using the default exports from `node:path`, `node:fs`,
|
|
19
|
-
// etc
|
|
20
|
-
"unicorn/import-style": "off",
|
|
21
|
-
// I want PascalCase for React components/classes, camelCase for others.
|
|
22
|
-
// Don't care enough to enforce through a rule and don't think it's
|
|
23
|
-
// possible.
|
|
24
|
-
"unicorn/filename-case": "off",
|
|
25
|
-
// prettier instead
|
|
26
|
-
"unicorn/empty-brace-spaces": "off",
|
|
27
|
-
// I like `null`
|
|
28
|
-
"unicorn/no-null": "off",
|
|
29
|
-
// the description is incorrect since it attempts converting multi-line
|
|
30
|
-
// statements to ternary which is awful:
|
|
31
|
-
//
|
|
32
|
-
// > This rule enforces the use of ternary expressions over 'simple'
|
|
33
|
-
// > if-else statements, where 'simple' means the consequent and alternate
|
|
34
|
-
// > are each one line and have the same basic type and form.
|
|
35
|
-
"unicorn/prefer-ternary": "off",
|
|
36
|
-
// I don't care about adding braces to switch cases. I'd prefer
|
|
37
|
-
// `["error", "avoid"]` more though since it only adds them when needed.
|
|
38
|
-
"unicorn/switch-case-braces": "off" }) }),
|
|
39
|
-
{
|
|
40
|
-
name: "".concat(BASE_NAME, "/unicorn/vite"),
|
|
41
|
-
files: VITE_MAIN_FILES,
|
|
42
|
-
rules: {
|
|
43
|
-
// allow `createRoot(document.getElementById("root")).render(...)` for
|
|
44
|
-
// `vite` without disabling eslint
|
|
45
|
-
"unicorn/prefer-query-selector": "off",
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: "".concat(BASE_NAME, "/unicorn/testing"),
|
|
50
|
-
files: TEST_FILES,
|
|
51
|
-
rules: {
|
|
52
|
-
// allow functions to be scoped to tests
|
|
53
|
-
"unicorn/consistent-function-scoping": "off",
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
];
|