@mlaursen/eslint-config 5.1.1 → 5.1.3

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.js CHANGED
@@ -1,18 +1,23 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configs = exports.gitignore = exports.config = void 0;
6
+ exports.globals = exports.gitignore = exports.config = exports.configs = void 0;
7
+ var globals_1 = __importDefault(require("globals"));
8
+ exports.globals = globals_1.default;
9
+ var typescript_eslint_1 = require("typescript-eslint");
10
+ Object.defineProperty(exports, "config", { enumerable: true, get: function () { return typescript_eslint_1.config; } });
4
11
  var base_1 = require("./base");
5
12
  var frontend_1 = require("./frontend");
13
+ var gitignore_1 = require("./gitignore");
14
+ Object.defineProperty(exports, "gitignore", { enumerable: true, get: function () { return gitignore_1.gitignore; } });
6
15
  var jest_1 = require("./jest");
7
16
  var jsxA11y_1 = require("./jsxA11y");
8
17
  var next_1 = require("./next");
9
18
  var react_1 = require("./react");
10
19
  var testing_library_1 = require("./testing-library");
11
20
  var typescript_1 = require("./typescript");
12
- var typescript_eslint_1 = require("typescript-eslint");
13
- Object.defineProperty(exports, "config", { enumerable: true, get: function () { return typescript_eslint_1.config; } });
14
- var gitignore_1 = require("./gitignore");
15
- Object.defineProperty(exports, "gitignore", { enumerable: true, get: function () { return gitignore_1.gitignore; } });
16
21
  exports.configs = {
17
22
  base: base_1.base,
18
23
  jest: jest_1.jest,
@@ -27,3 +32,9 @@ exports.configs = {
27
32
  jsxA11y: jsxA11y_1.jsxA11y,
28
33
  next: next_1.next,
29
34
  };
35
+ exports.default = {
36
+ config: typescript_eslint_1.config,
37
+ configs: exports.configs,
38
+ globals: globals_1.default,
39
+ gitignore: gitignore_1.gitignore,
40
+ };
package/dist/jest.d.ts CHANGED
@@ -1,3 +1,19 @@
1
1
  import { type TSESLint } from "@typescript-eslint/utils";
2
+ /**
3
+ * @example
4
+ * ```ts
5
+ * import { config, configs } from "@mlaursen/eslint-config";
6
+ *
7
+ * export default config(...configs.jest);
8
+ * ```
9
+ */
2
10
  export declare const jest: TSESLint.FlatConfig.ConfigArray;
11
+ /**
12
+ * @example
13
+ * ```ts
14
+ * import { config, configs } from "@mlaursen/eslint-config";
15
+ *
16
+ * export default config(...configs.jest, ...configs.jestDom);
17
+ * ```
18
+ */
3
19
  export declare const jestDom: TSESLint.FlatConfig.ConfigArray;
package/dist/jest.js CHANGED
@@ -18,9 +18,25 @@ exports.jestDom = exports.jest = void 0;
18
18
  var eslint_plugin_jest_1 = __importDefault(require("eslint-plugin-jest"));
19
19
  var eslint_plugin_jest_dom_1 = __importDefault(require("eslint-plugin-jest-dom"));
20
20
  var constants_1 = require("./constants");
21
+ /**
22
+ * @example
23
+ * ```ts
24
+ * import { config, configs } from "@mlaursen/eslint-config";
25
+ *
26
+ * export default config(...configs.jest);
27
+ * ```
28
+ */
21
29
  exports.jest = [
22
- __assign({ files: constants_1.TEST_FILES }, eslint_plugin_jest_1.default.configs["flat/recommended"]),
30
+ __assign({ name: "".concat(constants_1.BASE_NAME, "/jest"), files: constants_1.TEST_FILES }, eslint_plugin_jest_1.default.configs["flat/recommended"]),
23
31
  ];
32
+ /**
33
+ * @example
34
+ * ```ts
35
+ * import { config, configs } from "@mlaursen/eslint-config";
36
+ *
37
+ * export default config(...configs.jest, ...configs.jestDom);
38
+ * ```
39
+ */
24
40
  exports.jestDom = [
25
- __assign({ files: constants_1.TEST_FILES }, eslint_plugin_jest_dom_1.default.configs["flat/recommended"]),
41
+ __assign({ name: "".concat(constants_1.BASE_NAME, "/jest-dom"), files: constants_1.TEST_FILES }, eslint_plugin_jest_dom_1.default.configs["flat/recommended"]),
26
42
  ];
package/dist/jsxA11y.d.ts CHANGED
@@ -1,2 +1,10 @@
1
1
  import { type TSESLint } from "@typescript-eslint/utils";
2
+ /**
3
+ * @example
4
+ * ```ts
5
+ * import { config, configs } from "@mlaursen/eslint-config";
6
+ *
7
+ * export default config(...configs.jsxA11y);
8
+ * ```
9
+ */
2
10
  export declare const jsxA11y: TSESLint.FlatConfig.ConfigArray;
package/dist/jsxA11y.js CHANGED
@@ -18,8 +18,29 @@ exports.jsxA11y = void 0;
18
18
  var eslint_plugin_jsx_a11y_1 = __importDefault(require("eslint-plugin-jsx-a11y"));
19
19
  var globals_1 = __importDefault(require("globals"));
20
20
  var constants_1 = require("./constants");
21
+ /**
22
+ * @example
23
+ * ```ts
24
+ * import { config, configs } from "@mlaursen/eslint-config";
25
+ *
26
+ * export default config(...configs.jsxA11y);
27
+ * ```
28
+ */
21
29
  exports.jsxA11y = [
22
- __assign(__assign({ files: constants_1.JSX_FILES }, eslint_plugin_jsx_a11y_1.default.flatConfigs.recommended), { languageOptions: {
30
+ __assign(__assign({ name: "".concat(constants_1.BASE_NAME, "/jsx-a11y"), files: constants_1.JSX_FILES }, eslint_plugin_jsx_a11y_1.default.flatConfigs.recommended), { languageOptions: {
23
31
  globals: __assign({}, globals_1.default.browser),
32
+ }, rules: {
33
+ // I **only** use autoFocus within dialogs which provide the correct
34
+ // context for screen readers.
35
+ "jsx-a11y/no-autofocus": "off",
24
36
  } }),
37
+ {
38
+ files: constants_1.TEST_FILES,
39
+ name: "".concat(constants_1.BASE_NAME, "/jsx-a11y/testing"),
40
+ rules: {
41
+ "jsx-a11y/anchor-has-content": "off",
42
+ "jsx-a11y/click-events-have-key-events": "off",
43
+ "jsx-a11y/no-static-element-interactions": "off",
44
+ },
45
+ },
25
46
  ];
package/dist/next.d.ts CHANGED
@@ -1,2 +1,10 @@
1
1
  import { type TSESLint } from "@typescript-eslint/utils";
2
+ /**
3
+ * @example
4
+ * ```ts
5
+ * import { config, configs, gitignore } from "@mlaursen/eslint-config";
6
+ *
7
+ * export default config(gitignore(import.meta.url), ...configs.typescript, ...configs.next);
8
+ * ```
9
+ */
2
10
  export declare const next: TSESLint.FlatConfig.ConfigArray;
package/dist/next.js CHANGED
@@ -17,8 +17,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.next = void 0;
18
18
  var compat_1 = require("@eslint/compat");
19
19
  var eslint_plugin_next_1 = __importDefault(require("@next/eslint-plugin-next"));
20
+ var constants_1 = require("./constants");
21
+ /**
22
+ * @example
23
+ * ```ts
24
+ * import { config, configs, gitignore } from "@mlaursen/eslint-config";
25
+ *
26
+ * export default config(gitignore(import.meta.url), ...configs.typescript, ...configs.next);
27
+ * ```
28
+ */
20
29
  exports.next = [
21
30
  {
31
+ name: "".concat(constants_1.BASE_NAME, "/next"),
22
32
  plugins: {
23
33
  // @ts-expect-error There is a bad typing atm
24
34
  "@next/next": (0, compat_1.fixupPluginRules)(eslint_plugin_next_1.default),
package/dist/react.d.ts CHANGED
@@ -1,5 +1,12 @@
1
1
  import { type TSESLint } from "@typescript-eslint/utils";
2
2
  /**
3
+ * @example
4
+ * ```ts
5
+ * import { config, configs } from "@mlaursen/eslint-config";
6
+ *
7
+ * export default config(...configs.react);
8
+ * ```
9
+ *
3
10
  * Enables:
4
11
  * - `eslint-plugin-react` with:
5
12
  * - flat.recommended
package/dist/react.js CHANGED
@@ -24,6 +24,13 @@ var reactPlugins = flat.recommended.plugins;
24
24
  var recommendedRules = flat.recommended.rules;
25
25
  var jsxRuntimeRules = flat["jsx-runtime"].rules;
26
26
  /**
27
+ * @example
28
+ * ```ts
29
+ * import { config, configs } from "@mlaursen/eslint-config";
30
+ *
31
+ * export default config(...configs.react);
32
+ * ```
33
+ *
27
34
  * Enables:
28
35
  * - `eslint-plugin-react` with:
29
36
  * - flat.recommended
@@ -33,6 +40,7 @@ var jsxRuntimeRules = flat["jsx-runtime"].rules;
33
40
  */
34
41
  exports.react = [
35
42
  {
43
+ name: "".concat(constants_1.BASE_NAME, "/react"),
36
44
  files: constants_1.JSX_FILES,
37
45
  settings: {
38
46
  react: {
@@ -40,7 +48,12 @@ exports.react = [
40
48
  },
41
49
  },
42
50
  plugins: __assign(__assign({}, reactPlugins), { "react-hooks": eslint_plugin_react_hooks_1.default }),
43
- rules: __assign(__assign(__assign({}, recommendedRules), jsxRuntimeRules), eslint_plugin_react_hooks_1.default.configs.recommended.rules),
51
+ rules: __assign(__assign(__assign(__assign({}, recommendedRules), jsxRuntimeRules), eslint_plugin_react_hooks_1.default.configs.recommended.rules), { "react-hooks/exhaustive-deps": [
52
+ "error",
53
+ {
54
+ additionalHooks: "(useIsomorphicLayoutEffect)",
55
+ },
56
+ ] }),
44
57
  languageOptions: __assign(__assign({}, flat.recommended.languageOptions), { globals: __assign({}, globals_1.default.browser) }),
45
58
  },
46
59
  ];
@@ -1,10 +1,33 @@
1
1
  import { type TSESLint } from "@typescript-eslint/utils";
2
2
  /**
3
+ * @example
4
+ * ```ts
5
+ * import { config, configs } from "@mlaursen/eslint-config";
6
+ *
7
+ * export default config(
8
+ * ...configs.react,
9
+ * ...configs.jest,
10
+ * ...configs.jestDom,
11
+ * ...configs.testingLibraryReact
12
+ * );
13
+ * ```
14
+ *
3
15
  * NOTE: Only choose this or the {@link testingLibraryDom}. Do not use
4
16
  * both.
5
17
  */
6
18
  export declare const testingLibraryReact: TSESLint.FlatConfig.ConfigArray;
7
19
  /**
20
+ * @example
21
+ * ```ts
22
+ * import { config, configs } from "@mlaursen/eslint-config";
23
+ *
24
+ * export default config(
25
+ * ...configs.jest,
26
+ * ...configs.jestDom,
27
+ * ...configs.testingLibraryDom
28
+ * );
29
+ * ```
30
+ *
8
31
  * NOTE: Only choose this or the {@link testingLibraryReact}. Do not use
9
32
  * both.
10
33
  */
@@ -26,16 +26,39 @@ var testingLibrary = {
26
26
  },
27
27
  };
28
28
  /**
29
+ * @example
30
+ * ```ts
31
+ * import { config, configs } from "@mlaursen/eslint-config";
32
+ *
33
+ * export default config(
34
+ * ...configs.react,
35
+ * ...configs.jest,
36
+ * ...configs.jestDom,
37
+ * ...configs.testingLibraryReact
38
+ * );
39
+ * ```
40
+ *
29
41
  * NOTE: Only choose this or the {@link testingLibraryDom}. Do not use
30
42
  * both.
31
43
  */
32
44
  exports.testingLibraryReact = [
33
- __assign(__assign({}, testingLibrary), { rules: __assign({}, eslint_plugin_testing_library_1.default.configs["flat/react"].rules) }),
45
+ __assign(__assign({}, testingLibrary), { name: "".concat(constants_1.BASE_NAME, "/testing-library/react"), rules: __assign({}, eslint_plugin_testing_library_1.default.configs["flat/react"].rules) }),
34
46
  ];
35
47
  /**
48
+ * @example
49
+ * ```ts
50
+ * import { config, configs } from "@mlaursen/eslint-config";
51
+ *
52
+ * export default config(
53
+ * ...configs.jest,
54
+ * ...configs.jestDom,
55
+ * ...configs.testingLibraryDom
56
+ * );
57
+ * ```
58
+ *
36
59
  * NOTE: Only choose this or the {@link testingLibraryReact}. Do not use
37
60
  * both.
38
61
  */
39
62
  exports.testingLibraryDom = [
40
- __assign(__assign({}, testingLibrary), { rules: __assign({}, eslint_plugin_testing_library_1.default.configs["flat/dom"].rules) }),
63
+ __assign(__assign({}, testingLibrary), { name: "".concat(constants_1.BASE_NAME, "/testing-library/dom"), rules: __assign({}, eslint_plugin_testing_library_1.default.configs["flat/dom"].rules) }),
41
64
  ];
@@ -1,12 +1,20 @@
1
1
  import { type TSESLint } from "@typescript-eslint/utils";
2
+ /**
3
+ * @example
4
+ * ```ts
5
+ * import { config, configs, gitignore } from "@mlaursen/eslint-config";
6
+ *
7
+ * export default config(gitignore(import.meta.url), ...configs.typescript);
8
+ * ```
9
+ */
2
10
  export declare const typescript: TSESLint.FlatConfig.ConfigArray;
3
11
  /**
4
12
  * @example
5
13
  * ```ts
6
14
  * // @ts-check
7
- * import { config, configs } from "@mlaursen/eslint-config";
15
+ * import { config, configs, gitignore } from "@mlaursen/eslint-config";
8
16
  *
9
- * export default config(...configs.typescriptTypeChecking(import.meta.dirname));
17
+ * export default config(gitignore(import.meta.url), ...configs.typescriptTypeChecking(import.meta.dirname));
10
18
  * ```
11
19
  */
12
20
  export declare const typescriptTypeChecking: (tsconfigRootDir: string) => TSESLint.FlatConfig.ConfigArray;
@@ -32,9 +32,18 @@ exports.typescriptTypeChecking = exports.typescript = void 0;
32
32
  var typescript_eslint_1 = __importDefault(require("typescript-eslint"));
33
33
  var base_1 = require("./base");
34
34
  var constants_1 = require("./constants");
35
+ /**
36
+ * @example
37
+ * ```ts
38
+ * import { config, configs, gitignore } from "@mlaursen/eslint-config";
39
+ *
40
+ * export default config(gitignore(import.meta.url), ...configs.typescript);
41
+ * ```
42
+ */
35
43
  exports.typescript = __spreadArray(__spreadArray(__spreadArray([], __read(base_1.base), false), __read(typescript_eslint_1.default.configs.strict), false), [
36
44
  {
37
- files: ["**/*.{ts,tsx}"],
45
+ name: "".concat(constants_1.BASE_NAME, "/typescript"),
46
+ files: constants_1.TS_FILES,
38
47
  rules: {
39
48
  // I prefer specifying when something is used only as a type
40
49
  "@typescript-eslint/consistent-type-imports": [
@@ -63,6 +72,7 @@ exports.typescript = __spreadArray(__spreadArray(__spreadArray([], __read(base_1
63
72
  varsIgnorePattern: "^_",
64
73
  },
65
74
  ],
75
+ "no-use-before-define": "off",
66
76
  "@typescript-eslint/no-use-before-define": [
67
77
  "warn",
68
78
  { ignoreTypeReferences: true },
@@ -70,6 +80,7 @@ exports.typescript = __spreadArray(__spreadArray(__spreadArray([], __read(base_1
70
80
  },
71
81
  },
72
82
  {
83
+ name: "".concat(constants_1.BASE_NAME, "/typescript/tests"),
73
84
  files: constants_1.TEST_FILES,
74
85
  rules: {
75
86
  // allow tests to be less strict
@@ -86,19 +97,52 @@ exports.typescript = __spreadArray(__spreadArray(__spreadArray([], __read(base_1
86
97
  * @example
87
98
  * ```ts
88
99
  * // @ts-check
89
- * import { config, configs } from "@mlaursen/eslint-config";
100
+ * import { config, configs, gitignore } from "@mlaursen/eslint-config";
90
101
  *
91
- * export default config(...configs.typescriptTypeChecking(import.meta.dirname));
102
+ * export default config(gitignore(import.meta.url), ...configs.typescriptTypeChecking(import.meta.dirname));
92
103
  * ```
93
104
  */
94
105
  var typescriptTypeChecking = function (tsconfigRootDir) { return __spreadArray(__spreadArray(__spreadArray([], __read(exports.typescript), false), __read(typescript_eslint_1.default.configs.strictTypeCheckedOnly), false), [
95
106
  {
107
+ name: "".concat(constants_1.BASE_NAME, "/typescript-type-checking"),
108
+ files: constants_1.TS_FILES,
96
109
  languageOptions: {
97
110
  parserOptions: {
98
111
  projectService: true,
99
112
  tsconfigRootDir: tsconfigRootDir,
100
113
  },
101
114
  },
115
+ rules: {
116
+ // I do not enable the `noUncheckedIndexedAccess` tsconfig option, so I
117
+ // still need to verify that stuff exists. There are other cases where I
118
+ // know it exists, so I can ignore those as well
119
+ "@typescript-eslint/no-unnecessary-condition": "off",
120
+ // I never use `this`
121
+ "@typescript-eslint/unbound-method": "off",
122
+ "@typescript-eslint/restrict-template-expressions": [
123
+ "error",
124
+ {
125
+ allowNumber: true,
126
+ },
127
+ ],
128
+ // I want to allow `onClick={async (event) => { ... }}`
129
+ "@typescript-eslint/no-misused-promises": [
130
+ "error",
131
+ {
132
+ checksVoidReturn: false,
133
+ },
134
+ ],
135
+ },
136
+ },
137
+ {
138
+ name: "".concat(constants_1.BASE_NAME, "/typescript-type-checking/tests"),
139
+ files: constants_1.TEST_FILES,
140
+ rules: {
141
+ // like base typescript, can be less strict in tests
142
+ "@typescript-eslint/no-unsafe-return": "off",
143
+ "@typescript-eslint/no-unsafe-assignment": "off",
144
+ "@typescript-eslint/restrict-template-expressions": "off",
145
+ },
102
146
  },
103
147
  ], false); };
104
148
  exports.typescriptTypeChecking = typescriptTypeChecking;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlaursen/eslint-config",
3
- "version": "5.1.1",
3
+ "version": "5.1.3",
4
4
  "description": "An eslint config used by mlaursen for most projects.",
5
5
  "repository": "https://github.com/mlaursen/eslint-config.git",
6
6
  "author": "Mikkel Laursen <mlaursen03@gmail.com>",
@@ -31,6 +31,7 @@
31
31
  "eslint-plugin-react": "^7.37.1",
32
32
  "eslint-plugin-react-hooks": "^5.0.0",
33
33
  "eslint-plugin-testing-library": "^6.3.0",
34
+ "globals": "^15.11.0",
34
35
  "typescript-eslint": "^8.8.1"
35
36
  },
36
37
  "devDependencies": {