@exadev/eslint-config 1.1.2 → 1.2.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 CHANGED
@@ -12,7 +12,7 @@ Only the *rules* are centralized here, not a consumer's whole `eslint.config.ts`
12
12
 
13
13
  ## Getting started
14
14
 
15
- Consumers need `eslint >=10.0.0` as a peer dependency.
15
+ Consumers need `eslint >=10.0.0` as a peer dependency. `typescript-eslint >=8.0.0` is also a peer dependency, but an *optional* one (`peerDependenciesMeta`) -- it's only needed by the `recommended-type-checked` entry point described below, not by the package as a whole. A plain-JS project with no TypeScript at all can install and use this package with nothing else added.
16
16
 
17
17
  ```sh
18
18
  pnpm add -D @exadev/eslint-config
@@ -46,13 +46,39 @@ export default defineConfig([
46
46
  {
47
47
  files: ['**/*.ts'],
48
48
  plugins: { exadev },
49
- extends: ['exadev/recommended'], // every rule this plugin defines, plus no-inline-config and no-type-assertions
49
+ extends: ['exadev/recommended'], // this plugin's own four rules, plus linterOptions.noInlineConfig -- no TypeScript involvement at all
50
50
  // or: extends: ['exadev/barrel'], // just the barrel-discipline trio (no-non-barrel-index, no-non-barrel-reexport, no-side-effects-in-index)
51
51
  },
52
52
  ]);
53
53
  ```
54
54
 
55
- `recommended` also turns on two general code-quality settings every current consumer already wires independently: `linterOptions.noInlineConfig` (no `eslint-disable` comments anywhere -- an exception belongs in the config, scoped to where it applies, not hidden inline in the source it's disabling a rule for) and `@typescript-eslint/consistent-type-assertions` set to `never` (no `as`/angle-bracket type assertions -- narrow with a guard or parse with Zod instead). The type-assertions rule is `@typescript-eslint`'s own, not one this plugin defines, so `recommended` assumes the consumer already has `typescript-eslint` registered under the `@typescript-eslint` namespace -- true for every consumer this plugin currently has. A consumer with no typescript-eslint at all should use `barrel`, or wire the four `exadev/*` rules directly, instead of taking `recommended` wholesale.
55
+ Both `recommended` and `barrel` are usable in a plain JavaScript project with no TypeScript and no `typescript-eslint` installed: this plugin's own four rules operate on plain ESTree import/export/declaration nodes, nothing TypeScript-specific, and neither config references `typescript-eslint` at all.
56
+
57
+ ### The typed-linting bundle: `@exadev/eslint-config/recommended-type-checked`
58
+
59
+ For a TypeScript project that wants the full typed-linting baseline bundled in, import the separate `recommended-type-checked` entry point instead of using `configs.recommended`:
60
+
61
+ ```ts
62
+ // eslint.config.ts
63
+ import exadevRecommendedTypeChecked from '@exadev/eslint-config/recommended-type-checked';
64
+ import tseslint from 'typescript-eslint';
65
+
66
+ export default tseslint.config(
67
+ {
68
+ languageOptions: {
69
+ parserOptions: { project: './tsconfig.json', tsconfigRootDir: import.meta.dirname },
70
+ },
71
+ },
72
+ ...exadevRecommendedTypeChecked,
73
+ // ...your own config on top...
74
+ );
75
+ ```
76
+
77
+ This bundles `typescript-eslint`'s own `recommendedTypeChecked` and `stylisticTypeChecked` presets (`recommendedTypeChecked` already subsumes plain `recommended` outright -- every one of its 46 rules is a strict subset of `recommendedTypeChecked`'s 73, confirmed by inspecting the actual rule maps) alongside this plugin's own four rules, `linterOptions.noInlineConfig`, and `@typescript-eslint/consistent-type-assertions` set to `never` (no `as`/angle-bracket type assertions -- narrow with a guard or parse with Zod instead).
78
+
79
+ It's a real bundling, not a rule reference that assumes the consumer already has `typescript-eslint` set up: `recommendedTypeChecked`'s own base config registers the `@typescript-eslint` plugin and sets `languageOptions.parser` itself. **A consumer adopting this bundle must remove its own `...tseslint.configs.recommended`/`recommendedTypeChecked`/`stylisticTypeChecked` spreads** rather than keep them alongside it -- ESLint flat config rejects two different plugin object instances registered under the same namespace. What a consumer still supplies itself is `languageOptions.parserOptions.project`/`projectService` pointing at its own tsconfig(s); `recommendedTypeChecked`'s base config never sets that, since it's genuinely project-specific.
80
+
81
+ This lives in its own module, separate from the main `@exadev/eslint-config` entry point, specifically so importing the main package never attempts to resolve `typescript-eslint`. A plain object property (or a lazy getter) on the base plugin's own `configs` map can't achieve that: ESLint's `extends` resolution is synchronous, so a dynamic `import()` doesn't help either -- it just hides the same requirement behind an unawaited promise. Splitting into a genuinely separate module sidesteps the problem at the right layer: Node's own module resolution only loads a module when something actually imports it.
56
82
 
57
83
  ## Rules
58
84
 
@@ -80,7 +106,9 @@ The `lint`/`typecheck`/`build` npm scripts are thin wrappers around turbo tasks
80
106
 
81
107
  ## Architecture
82
108
 
83
- `src/plugin.ts` builds an `ESLint.Plugin` object (ESLint's own `ESLint.Plugin` type, not a hand-written interface) combining the four rule modules under `src/rules/` into a flat `rules` map. The two bundled configs (`recommended`, `barrel`) are attached via `Object.assign` after the plugin object is constructed, rather than inline in the object literal, so each config's own `plugins: { exadev }` can reference the already-built plugin object -- the same self-reference pattern ESLint's plugin-authoring guide uses. `src/index.ts` is the public entry point and is nothing but `export { default } from './plugin';` -- a genuine pure re-export barrel.
109
+ `src/plugin.ts` builds an `ESLint.Plugin` object (ESLint's own `ESLint.Plugin` type, not a hand-written interface) combining the four rule modules under `src/rules/` into a flat `rules` map. `configs.recommended` and `configs.barrel` are defined as getters directly in the object literal, not attached after construction: each needs to reference the fully-built `plugin` object itself (`plugins: { exadev: plugin }`), which a plain property initializer can't do for its own binding while it's still being constructed. A getter closes over the `plugin` binding rather than its value, so it resolves correctly the moment a consumer actually reads the property, by which point construction has finished -- no `Object.assign`, no post-construction mutation, no null-checked destructure needed. `src/index.ts` is the public entry point and is nothing but `export { default } from './plugin';` -- a genuine pure re-export barrel.
110
+
111
+ `src/recommended-type-checked.ts` is a deliberately separate module, not a third property on the base plugin's own `configs`. It imports `typescript-eslint` to bundle `recommendedTypeChecked` + `stylisticTypeChecked` alongside this plugin's own rules -- see [The typed-linting bundle](#the-typed-linting-bundle-exadeveslint-configrecommended-type-checked) above for why that has to live in its own module rather than on the shared plugin object: importing the main entry point must never attempt to resolve `typescript-eslint`, and Node's own module resolution only loads a module when something actually imports it.
84
112
 
85
113
  `pnpm-workspace.yaml` deliberately declares an empty `packages: []`. This is not a real multi-package pnpm workspace; its only purpose is giving turbo a workspace root to anchor local task caching against, matching the same single-package-workspace pattern used across this repo family.
86
114
 
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- const require_plugin = require("./plugin-DeBcMjPX.cjs");
1
+ const require_plugin = require("./plugin-Dixk0WAc.cjs");
2
2
  module.exports = require_plugin.plugin;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as plugin } from "./plugin-UsvTGA6w.js";
1
+ import { t as plugin } from "./plugin-Cq16p_yl.js";
2
2
  export { plugin as default };
@@ -0,0 +1,45 @@
1
+ import noNonBarrelIndex from "./rules/no-non-barrel-index.js";
2
+ import noNonBarrelReexport from "./rules/no-non-barrel-reexport.js";
3
+ import noPointlessReassignment from "./rules/no-pointless-reassignment.js";
4
+ import noSideEffectsInIndex from "./rules/no-side-effects-in-index.js";
5
+ //#endregion
6
+ //#region src/plugin.ts
7
+ const plugin = {
8
+ meta: {
9
+ name: "@exadev/eslint-config",
10
+ version: "1.2.0",
11
+ namespace: "exadev"
12
+ },
13
+ rules: {
14
+ "no-non-barrel-index": noNonBarrelIndex,
15
+ "no-non-barrel-reexport": noNonBarrelReexport,
16
+ "no-pointless-reassignment": noPointlessReassignment,
17
+ "no-side-effects-in-index": noSideEffectsInIndex
18
+ },
19
+ configs: {
20
+ get recommended() {
21
+ return {
22
+ plugins: { exadev: plugin },
23
+ linterOptions: { noInlineConfig: true },
24
+ rules: {
25
+ "exadev/no-non-barrel-index": "error",
26
+ "exadev/no-non-barrel-reexport": "error",
27
+ "exadev/no-pointless-reassignment": "error",
28
+ "exadev/no-side-effects-in-index": "error"
29
+ }
30
+ };
31
+ },
32
+ get barrel() {
33
+ return {
34
+ plugins: { exadev: plugin },
35
+ rules: {
36
+ "exadev/no-non-barrel-index": "error",
37
+ "exadev/no-non-barrel-reexport": "error",
38
+ "exadev/no-side-effects-in-index": "error"
39
+ }
40
+ };
41
+ }
42
+ }
43
+ };
44
+ //#endregion
45
+ export { plugin as t };
@@ -0,0 +1,46 @@
1
+ //#endregion
2
+ //#region src/plugin.ts
3
+ const plugin = {
4
+ meta: {
5
+ name: "@exadev/eslint-config",
6
+ version: "1.2.0",
7
+ namespace: "exadev"
8
+ },
9
+ rules: {
10
+ "no-non-barrel-index": require("./rules/no-non-barrel-index.cjs"),
11
+ "no-non-barrel-reexport": require("./rules/no-non-barrel-reexport.cjs"),
12
+ "no-pointless-reassignment": require("./rules/no-pointless-reassignment.cjs"),
13
+ "no-side-effects-in-index": require("./rules/no-side-effects-in-index.cjs")
14
+ },
15
+ configs: {
16
+ get recommended() {
17
+ return {
18
+ plugins: { exadev: plugin },
19
+ linterOptions: { noInlineConfig: true },
20
+ rules: {
21
+ "exadev/no-non-barrel-index": "error",
22
+ "exadev/no-non-barrel-reexport": "error",
23
+ "exadev/no-pointless-reassignment": "error",
24
+ "exadev/no-side-effects-in-index": "error"
25
+ }
26
+ };
27
+ },
28
+ get barrel() {
29
+ return {
30
+ plugins: { exadev: plugin },
31
+ rules: {
32
+ "exadev/no-non-barrel-index": "error",
33
+ "exadev/no-non-barrel-reexport": "error",
34
+ "exadev/no-side-effects-in-index": "error"
35
+ }
36
+ };
37
+ }
38
+ }
39
+ };
40
+ //#endregion
41
+ Object.defineProperty(exports, "plugin", {
42
+ enumerable: true,
43
+ get: function() {
44
+ return plugin;
45
+ }
46
+ });
package/dist/plugin.cjs CHANGED
@@ -1,2 +1,2 @@
1
- const require_plugin = require("./plugin-DeBcMjPX.cjs");
1
+ const require_plugin = require("./plugin-Dixk0WAc.cjs");
2
2
  module.exports = require_plugin.plugin;
package/dist/plugin.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as plugin } from "./plugin-UsvTGA6w.js";
1
+ import { t as plugin } from "./plugin-Cq16p_yl.js";
2
2
  export { plugin as default };
@@ -0,0 +1,43 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ const require_plugin = require("./plugin-Dixk0WAc.cjs");
24
+ let typescript_eslint = require("typescript-eslint");
25
+ typescript_eslint = __toESM(typescript_eslint, 1);
26
+ //#region src/recommended-type-checked.ts
27
+ const recommendedTypeChecked = [
28
+ ...typescript_eslint.default.configs.recommendedTypeChecked,
29
+ ...typescript_eslint.default.configs.stylisticTypeChecked,
30
+ {
31
+ plugins: { exadev: require_plugin.plugin },
32
+ linterOptions: { noInlineConfig: true },
33
+ rules: {
34
+ "exadev/no-non-barrel-index": "error",
35
+ "exadev/no-non-barrel-reexport": "error",
36
+ "exadev/no-pointless-reassignment": "error",
37
+ "exadev/no-side-effects-in-index": "error",
38
+ "@typescript-eslint/consistent-type-assertions": ["error", { assertionStyle: "never" }]
39
+ }
40
+ }
41
+ ];
42
+ //#endregion
43
+ module.exports = recommendedTypeChecked;
@@ -0,0 +1,5 @@
1
+ import { ESLint } from "eslint";
2
+ //#region src/recommended-type-checked.d.ts
3
+ type ConfigValue = NonNullable<ESLint.Plugin['configs']>[string];
4
+ declare const recommendedTypeChecked: ConfigValue;
5
+ export = recommendedTypeChecked;
@@ -0,0 +1,6 @@
1
+ import { ESLint } from "eslint";
2
+ //#region src/recommended-type-checked.d.ts
3
+ type ConfigValue = NonNullable<ESLint.Plugin['configs']>[string];
4
+ declare const recommendedTypeChecked: ConfigValue;
5
+ //#endregion
6
+ export { recommendedTypeChecked as default };
@@ -0,0 +1,20 @@
1
+ import { t as plugin } from "./plugin-Cq16p_yl.js";
2
+ import tseslint from "typescript-eslint";
3
+ //#region src/recommended-type-checked.ts
4
+ const recommendedTypeChecked = [
5
+ ...tseslint.configs.recommendedTypeChecked,
6
+ ...tseslint.configs.stylisticTypeChecked,
7
+ {
8
+ plugins: { exadev: plugin },
9
+ linterOptions: { noInlineConfig: true },
10
+ rules: {
11
+ "exadev/no-non-barrel-index": "error",
12
+ "exadev/no-non-barrel-reexport": "error",
13
+ "exadev/no-pointless-reassignment": "error",
14
+ "exadev/no-side-effects-in-index": "error",
15
+ "@typescript-eslint/consistent-type-assertions": ["error", { assertionStyle: "never" }]
16
+ }
17
+ }
18
+ ];
19
+ //#endregion
20
+ export { recommendedTypeChecked as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exadev/eslint-config",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "Shared custom ESLint rules and plugin for ExaDev projects",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -46,7 +46,13 @@
46
46
  "url": "git+https://github.com/ExaDev/eslint-config.git"
47
47
  },
48
48
  "peerDependencies": {
49
- "eslint": ">=10.0.0"
49
+ "eslint": ">=10.0.0",
50
+ "typescript-eslint": ">=8.0.0"
51
+ },
52
+ "peerDependenciesMeta": {
53
+ "typescript-eslint": {
54
+ "optional": true
55
+ }
50
56
  },
51
57
  "devDependencies": {
52
58
  "@arethetypeswrong/cli": "^0.18.5",
@@ -1,46 +0,0 @@
1
- //#endregion
2
- //#region src/plugin.ts
3
- const plugin = {
4
- meta: {
5
- name: "@exadev/eslint-config",
6
- version: "1.1.2",
7
- namespace: "exadev"
8
- },
9
- rules: {
10
- "no-non-barrel-index": require("./rules/no-non-barrel-index.cjs"),
11
- "no-non-barrel-reexport": require("./rules/no-non-barrel-reexport.cjs"),
12
- "no-pointless-reassignment": require("./rules/no-pointless-reassignment.cjs"),
13
- "no-side-effects-in-index": require("./rules/no-side-effects-in-index.cjs")
14
- },
15
- configs: {}
16
- };
17
- const { configs } = plugin;
18
- if (configs === void 0) throw new Error("Unreachable: configs was just initialized to {} in the object literal above.");
19
- Object.assign(configs, {
20
- recommended: {
21
- plugins: { exadev: plugin },
22
- linterOptions: { noInlineConfig: true },
23
- rules: {
24
- "exadev/no-non-barrel-index": "error",
25
- "exadev/no-non-barrel-reexport": "error",
26
- "exadev/no-pointless-reassignment": "error",
27
- "exadev/no-side-effects-in-index": "error",
28
- "@typescript-eslint/consistent-type-assertions": ["error", { assertionStyle: "never" }]
29
- }
30
- },
31
- barrel: {
32
- plugins: { exadev: plugin },
33
- rules: {
34
- "exadev/no-non-barrel-index": "error",
35
- "exadev/no-non-barrel-reexport": "error",
36
- "exadev/no-side-effects-in-index": "error"
37
- }
38
- }
39
- });
40
- //#endregion
41
- Object.defineProperty(exports, "plugin", {
42
- enumerable: true,
43
- get: function() {
44
- return plugin;
45
- }
46
- });
@@ -1,45 +0,0 @@
1
- import noNonBarrelIndex from "./rules/no-non-barrel-index.js";
2
- import noNonBarrelReexport from "./rules/no-non-barrel-reexport.js";
3
- import noPointlessReassignment from "./rules/no-pointless-reassignment.js";
4
- import noSideEffectsInIndex from "./rules/no-side-effects-in-index.js";
5
- //#endregion
6
- //#region src/plugin.ts
7
- const plugin = {
8
- meta: {
9
- name: "@exadev/eslint-config",
10
- version: "1.1.2",
11
- namespace: "exadev"
12
- },
13
- rules: {
14
- "no-non-barrel-index": noNonBarrelIndex,
15
- "no-non-barrel-reexport": noNonBarrelReexport,
16
- "no-pointless-reassignment": noPointlessReassignment,
17
- "no-side-effects-in-index": noSideEffectsInIndex
18
- },
19
- configs: {}
20
- };
21
- const { configs } = plugin;
22
- if (configs === void 0) throw new Error("Unreachable: configs was just initialized to {} in the object literal above.");
23
- Object.assign(configs, {
24
- recommended: {
25
- plugins: { exadev: plugin },
26
- linterOptions: { noInlineConfig: true },
27
- rules: {
28
- "exadev/no-non-barrel-index": "error",
29
- "exadev/no-non-barrel-reexport": "error",
30
- "exadev/no-pointless-reassignment": "error",
31
- "exadev/no-side-effects-in-index": "error",
32
- "@typescript-eslint/consistent-type-assertions": ["error", { assertionStyle: "never" }]
33
- }
34
- },
35
- barrel: {
36
- plugins: { exadev: plugin },
37
- rules: {
38
- "exadev/no-non-barrel-index": "error",
39
- "exadev/no-non-barrel-reexport": "error",
40
- "exadev/no-side-effects-in-index": "error"
41
- }
42
- }
43
- });
44
- //#endregion
45
- export { plugin as t };