@mlaursen/eslint-config 5.1.0 → 5.1.1

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 CHANGED
@@ -16,17 +16,22 @@ Then create an `eslint.config.mjs` with the following:
16
16
  // @ts-check
17
17
  import { config, configs, gitignore } from "@mlaursen/eslint-config";
18
18
 
19
- // choose the config you want to use
19
+ // choose the config you want to use:
20
+ // somewhat strict type checking
20
21
  export default config(gitignore(import.meta.url), ...configs.frontend);
22
+
23
+ // strict type checking
21
24
  export default config(gitignore(import.meta.url), ...configs.frontendTypeChecking(import.meta.dirname));
22
25
  ```
23
26
 
24
- The `config` export is the `typescript-eslint.config()` function to provide
25
- type definitions.
27
+ The `config` export is the `typescript-eslint.config()` function to provide type
28
+ definitions and `gitignore` automatically ignores files from linting based on
29
+ your `.gitignore` rules.
26
30
 
27
31
  ## Configs
28
32
 
29
- I normally just use the `frontend` or `frontendTypeChecking` configs, but the others can be used individually if needed.
33
+ I normally just use the `frontend` or `frontendTypeChecking` configs, but the
34
+ others can be used individually if needed.
30
35
 
31
36
  <!--toc:start-->
32
37
 
@@ -37,6 +42,9 @@ I normally just use the `frontend` or `frontendTypeChecking` configs, but the ot
37
42
  - [jestDom](#jestdom)
38
43
  - [testingLibraryReact](#testinglibraryreact)
39
44
  - [testingLibraryDom](#testinglibrarydom)
45
+ - [react](#react)
46
+ - [jsxA11y](#jsxa11y)
47
+ - [next](#next)
40
48
  - [frontend](#frontend)
41
49
  - [frontendTypeChecking](#frontendtypechecking)
42
50
 
@@ -128,6 +136,28 @@ import { config, configs } from "@mlaursen/eslint-config";
128
136
  export default config(...configs.testingLibraryDom);
129
137
  ```
130
138
 
139
+ ### react
140
+
141
+ This enables the `eslint-plugin-react` and `eslint-plugin-react-hooks`:
142
+
143
+ ```js
144
+ // @ts-check
145
+ import { config, configs } from "@mlaursen/eslint-config";
146
+
147
+ export default config(...configs.react);
148
+ ```
149
+
150
+ ### jsxA11y
151
+
152
+ This enables `eslint-plugin-jsx-a11y`:
153
+
154
+ ```js
155
+ // @ts-check
156
+ import { config, configs } from "@mlaursen/eslint-config";
157
+
158
+ export default config(...configs.jsxA11y);
159
+ ```
160
+
131
161
  ### next
132
162
 
133
163
  This is a small wrapper around the `@next/eslint-plugin-next` that works with eslint v9.
@@ -141,7 +171,8 @@ export default config(...configs.next);
141
171
 
142
172
  ### frontend
143
173
 
144
- This is my normal frontend repo setup with `jest`, `jest-dom`, `typescript`, `react`, `testing-library/react`.
174
+ This is my normal frontend repo setup with `react`, `jsxA11y`, `jest`,
175
+ `jest-dom`, `typescript`, `testing-library/react`.
145
176
 
146
177
  ```js
147
178
  // @ts-check
@@ -1,2 +1,3 @@
1
1
  export declare const DEV_WARNING_PROD_ERROR: string;
2
2
  export declare const TEST_FILES: string[];
3
+ export declare const JSX_FILES: string[];
package/dist/constants.js CHANGED
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TEST_FILES = exports.DEV_WARNING_PROD_ERROR = void 0;
3
+ exports.JSX_FILES = exports.TEST_FILES = exports.DEV_WARNING_PROD_ERROR = void 0;
4
4
  exports.DEV_WARNING_PROD_ERROR = process.env.NODE_ENV !== "production" ? "warn" : "error";
5
5
  exports.TEST_FILES = [
6
6
  "**/__tests__/**",
7
7
  "**/*.{spec,test}.{ts,tsx,js,jsx}",
8
8
  ];
9
+ exports.JSX_FILES = ["**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}"];
package/dist/frontend.js CHANGED
@@ -27,8 +27,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
28
  exports.frontendTypeChecking = exports.frontend = void 0;
29
29
  var jest_1 = require("./jest");
30
+ var jsxA11y_1 = require("./jsxA11y");
31
+ var react_1 = require("./react");
30
32
  var testing_library_1 = require("./testing-library");
31
33
  var typescript_1 = require("./typescript");
32
- exports.frontend = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(typescript_1.typescript), false), __read(jest_1.jest), false), __read(jest_1.jestDom), false), __read(testing_library_1.testingLibraryReact), false);
33
- var frontendTypeChecking = function (tsconfigRootDir) { return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, typescript_1.typescriptTypeChecking)(tsconfigRootDir)), false), __read(jest_1.jest), false), __read(jest_1.jestDom), false), __read(testing_library_1.testingLibraryReact), false); };
34
+ exports.frontend = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(typescript_1.typescript), false), __read(react_1.react), false), __read(jsxA11y_1.jsxA11y), false), __read(jest_1.jest), false), __read(jest_1.jestDom), false), __read(testing_library_1.testingLibraryReact), false);
35
+ var frontendTypeChecking = function (tsconfigRootDir) { return __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((0, typescript_1.typescriptTypeChecking)(tsconfigRootDir)), false), __read(react_1.react), false), __read(jsxA11y_1.jsxA11y), false), __read(jest_1.jest), false), __read(jest_1.jestDom), false), __read(testing_library_1.testingLibraryReact), false); };
34
36
  exports.frontendTypeChecking = frontendTypeChecking;
package/dist/index.d.ts CHANGED
@@ -4,11 +4,13 @@ export declare const configs: {
4
4
  readonly base: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
5
5
  readonly jest: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
6
6
  readonly jestDom: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
7
+ readonly react: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
7
8
  readonly typescript: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
8
9
  readonly typescriptTypeChecking: (tsconfigRootDir: string) => import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
9
10
  readonly testingLibraryDom: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
10
11
  readonly testingLibraryReact: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
11
12
  readonly frontend: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
12
13
  readonly frontendTypeChecking: (tsconfigRootDir: string) => import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
14
+ readonly jsxA11y: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
13
15
  readonly next: import("@typescript-eslint/utils/ts-eslint").FlatConfig.ConfigArray;
14
16
  };
package/dist/index.js CHANGED
@@ -4,7 +4,9 @@ exports.configs = exports.gitignore = exports.config = void 0;
4
4
  var base_1 = require("./base");
5
5
  var frontend_1 = require("./frontend");
6
6
  var jest_1 = require("./jest");
7
+ var jsxA11y_1 = require("./jsxA11y");
7
8
  var next_1 = require("./next");
9
+ var react_1 = require("./react");
8
10
  var testing_library_1 = require("./testing-library");
9
11
  var typescript_1 = require("./typescript");
10
12
  var typescript_eslint_1 = require("typescript-eslint");
@@ -15,11 +17,13 @@ exports.configs = {
15
17
  base: base_1.base,
16
18
  jest: jest_1.jest,
17
19
  jestDom: jest_1.jestDom,
20
+ react: react_1.react,
18
21
  typescript: typescript_1.typescript,
19
22
  typescriptTypeChecking: typescript_1.typescriptTypeChecking,
20
23
  testingLibraryDom: testing_library_1.testingLibraryDom,
21
24
  testingLibraryReact: testing_library_1.testingLibraryReact,
22
25
  frontend: frontend_1.frontend,
23
26
  frontendTypeChecking: frontend_1.frontendTypeChecking,
27
+ jsxA11y: jsxA11y_1.jsxA11y,
24
28
  next: next_1.next,
25
29
  };
@@ -0,0 +1,2 @@
1
+ import { type TSESLint } from "@typescript-eslint/utils";
2
+ export declare const jsxA11y: TSESLint.FlatConfig.ConfigArray;
@@ -14,14 +14,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.reactHooks = void 0;
18
- var eslint_plugin_react_hooks_1 = __importDefault(require("eslint-plugin-react-hooks"));
19
- exports.reactHooks = [
20
- {
21
- files: ["**/*.{ts,tsx,js,jsx}"],
22
- plugins: {
23
- "react-hooks": eslint_plugin_react_hooks_1.default,
24
- },
25
- rules: __assign({}, eslint_plugin_react_hooks_1.default.configs.recommended.rules),
26
- },
17
+ exports.jsxA11y = void 0;
18
+ var eslint_plugin_jsx_a11y_1 = __importDefault(require("eslint-plugin-jsx-a11y"));
19
+ var globals_1 = __importDefault(require("globals"));
20
+ var constants_1 = require("./constants");
21
+ exports.jsxA11y = [
22
+ __assign(__assign({ files: constants_1.JSX_FILES }, eslint_plugin_jsx_a11y_1.default.flatConfigs.recommended), { languageOptions: {
23
+ globals: __assign({}, globals_1.default.browser),
24
+ } }),
27
25
  ];
@@ -0,0 +1,10 @@
1
+ import { type TSESLint } from "@typescript-eslint/utils";
2
+ /**
3
+ * Enables:
4
+ * - `eslint-plugin-react` with:
5
+ * - flat.recommended
6
+ * - flat['jsx-runtime']
7
+ * - `eslint-plugin-react-hooks` with:
8
+ * - recommended rules
9
+ */
10
+ export declare const react: TSESLint.FlatConfig.ConfigArray;
package/dist/react.js ADDED
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.react = void 0;
18
+ var eslint_plugin_react_1 = __importDefault(require("eslint-plugin-react"));
19
+ var eslint_plugin_react_hooks_1 = __importDefault(require("eslint-plugin-react-hooks"));
20
+ var globals_1 = __importDefault(require("globals"));
21
+ var constants_1 = require("./constants");
22
+ var flat = eslint_plugin_react_1.default.configs.flat;
23
+ var reactPlugins = flat.recommended.plugins;
24
+ var recommendedRules = flat.recommended.rules;
25
+ var jsxRuntimeRules = flat["jsx-runtime"].rules;
26
+ /**
27
+ * Enables:
28
+ * - `eslint-plugin-react` with:
29
+ * - flat.recommended
30
+ * - flat['jsx-runtime']
31
+ * - `eslint-plugin-react-hooks` with:
32
+ * - recommended rules
33
+ */
34
+ exports.react = [
35
+ {
36
+ files: constants_1.JSX_FILES,
37
+ settings: {
38
+ react: {
39
+ version: "detect",
40
+ },
41
+ },
42
+ 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),
44
+ languageOptions: __assign(__assign({}, flat.recommended.languageOptions), { globals: __assign({}, globals_1.default.browser) }),
45
+ },
46
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlaursen/eslint-config",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
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>",
@@ -27,6 +27,8 @@
27
27
  "@typescript-eslint/utils": "^8.8.1",
28
28
  "eslint-plugin-jest": "^28.8.3",
29
29
  "eslint-plugin-jest-dom": "^5.4.0",
30
+ "eslint-plugin-jsx-a11y": "^6.10.0",
31
+ "eslint-plugin-react": "^7.37.1",
30
32
  "eslint-plugin-react-hooks": "^5.0.0",
31
33
  "eslint-plugin-testing-library": "^6.3.0",
32
34
  "typescript-eslint": "^8.8.1"
@@ -1,2 +0,0 @@
1
- import { type TSESLint } from "@typescript-eslint/utils";
2
- export declare const reactHooks: TSESLint.FlatConfig.ConfigArray;