@ololoepepe/eslint-config-typescript 0.1.0 → 0.1.2
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/CHANGELOG.md +24 -0
- package/README.md +158 -1
- package/package.json +1 -1
- package/src/plugins/unicorn.js +10 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,30 @@ All notable changes to this project are documented in this file. The format is
|
|
|
4
4
|
based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this
|
|
5
5
|
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.1.2] - 2026-07-02
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **base:** resolved a mutual exclusion between `unicorn/prefer-export-from` and
|
|
12
|
+
`no-duplicate-imports` ({`includeExports: true`}). A binding imported for
|
|
13
|
+
internal use **and** re-exported (`import {x} from './m'; ... use x ...;
|
|
14
|
+
export {x};`) had no valid arrangement: the former demanded `export…from`,
|
|
15
|
+
which the latter forbade, and the internal use blocked dropping the import.
|
|
16
|
+
`unicorn/prefer-export-from` is now configured with `{checkUsedVariables:
|
|
17
|
+
false}`, so it no longer rewrites re-exports of internally-used bindings; pure
|
|
18
|
+
re-exports are still pushed to `export…from`. Added re-export compatibility
|
|
19
|
+
fixtures plus `--fix` fixpoint guards over `src` and every positive fixture to
|
|
20
|
+
catch future autofix conflicts across the ruleset.
|
|
21
|
+
|
|
22
|
+
## [0.1.1] - 2026-07-01
|
|
23
|
+
|
|
24
|
+
### Documentation
|
|
25
|
+
|
|
26
|
+
- Expanded the README into full package documentation: highlights, config entry
|
|
27
|
+
points (`base` / `/node` / `/react`), installation, usage examples, a
|
|
28
|
+
type-aware linting section (project service / `tsconfig.json` requirement), and
|
|
29
|
+
the enforced conventions.
|
|
30
|
+
|
|
7
31
|
## [0.1.0] - 2026-07-01
|
|
8
32
|
|
|
9
33
|
A major modernization of the config, brought to parity with the sibling
|
package/README.md
CHANGED
|
@@ -1 +1,158 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ololoepepe/eslint-config-typescript
|
|
2
|
+
|
|
3
|
+
A shareable [ESLint](https://eslint.org/) configuration for **TypeScript**
|
|
4
|
+
projects.
|
|
5
|
+
|
|
6
|
+
It aims to **cover as many cases as possible** and to enforce a **single,
|
|
7
|
+
unambiguous code style** wherever a clear "right answer" exists — leaving a rule
|
|
8
|
+
off only when the preferred style genuinely depends on context, or when a
|
|
9
|
+
compromise is worth it for ergonomics. Every available rule is configured
|
|
10
|
+
explicitly, including the ones turned off.
|
|
11
|
+
|
|
12
|
+
It is the TypeScript-oriented sibling of
|
|
13
|
+
[`@ololoepepe/eslint-config`](https://gitea.void-walkers.com/libs/eslint-config):
|
|
14
|
+
a **standalone** config (it keeps its own copy of the core/formatting rules
|
|
15
|
+
rather than depending on the base package) that adds full **type-aware**
|
|
16
|
+
linting and TypeScript-specific rules on top.
|
|
17
|
+
|
|
18
|
+
## Highlights
|
|
19
|
+
|
|
20
|
+
- **Flat config** (ESLint's modern format) — each entry point is exported as a
|
|
21
|
+
config array.
|
|
22
|
+
- **ESLint 10** with all formatting rules provided by
|
|
23
|
+
[`@stylistic/eslint-plugin`](https://eslint.style/).
|
|
24
|
+
- **Type-aware linting** via
|
|
25
|
+
[`typescript-eslint`](https://typescript-eslint.io/) — the `@typescript-eslint`
|
|
26
|
+
rules run with full type information (`parserOptions.projectService`), and core
|
|
27
|
+
rules are replaced by their typed analogs wherever one exists.
|
|
28
|
+
- **Type / interface / enum sorting** via
|
|
29
|
+
[`eslint-plugin-perfectionist`](https://perfectionist.dev/) — the distinctive
|
|
30
|
+
feature of this package.
|
|
31
|
+
- **Import hygiene** via
|
|
32
|
+
[`eslint-plugin-import-x`](https://github.com/un-ts/eslint-plugin-import-x)
|
|
33
|
+
with the TypeScript resolver.
|
|
34
|
+
- **Promise / async correctness** via
|
|
35
|
+
[`eslint-plugin-promise`](https://github.com/eslint-community/eslint-plugin-promise).
|
|
36
|
+
- **Regex correctness & style** via
|
|
37
|
+
[`eslint-plugin-regexp`](https://github.com/ota-meshi/eslint-plugin-regexp).
|
|
38
|
+
- **Modern idioms & a large catch-all of correctness rules** via
|
|
39
|
+
[`eslint-plugin-unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn).
|
|
40
|
+
- **React** (opt-in `/react` layer) via
|
|
41
|
+
[`@eslint-react`](https://eslint-react.xyz/) and the official
|
|
42
|
+
[`eslint-plugin-react-hooks`](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks),
|
|
43
|
+
with type-aware React rules on `.tsx`.
|
|
44
|
+
- **Sorted object keys** via
|
|
45
|
+
[`eslint-plugin-sort-keys-shorthand`](https://github.com/leonardovillela/eslint-plugin-sort-keys-shorthand).
|
|
46
|
+
- **Disciplined `eslint-disable` comments** via
|
|
47
|
+
[`@eslint-community/eslint-plugin-eslint-comments`](https://github.com/eslint-community/eslint-plugin-eslint-comments).
|
|
48
|
+
|
|
49
|
+
## Config entry points
|
|
50
|
+
|
|
51
|
+
The package is **environment-neutral by default** and ships environment layers
|
|
52
|
+
on top of it:
|
|
53
|
+
|
|
54
|
+
- **`@ololoepepe/eslint-config-typescript`** — the base config. Language + style
|
|
55
|
+
+ import + promise + correctness + type-aware `@typescript-eslint` rules. No
|
|
56
|
+
environment globals beyond standard ES, no Node- or browser-specific rules.
|
|
57
|
+
Use this directly for environment-agnostic code, or as the base for an
|
|
58
|
+
environment-specific config.
|
|
59
|
+
- **`@ololoepepe/eslint-config-typescript/node`** — the base **plus** a Node
|
|
60
|
+
layer: Node globals and
|
|
61
|
+
[`eslint-plugin-n`](https://github.com/eslint-community/eslint-plugin-n). Use
|
|
62
|
+
this for Node.js libraries and applications.
|
|
63
|
+
- **`@ololoepepe/eslint-config-typescript/react`** — the base **plus** a React
|
|
64
|
+
layer: browser globals, [`@eslint-react`](https://eslint-react.xyz/),
|
|
65
|
+
`eslint-plugin-react-hooks`, and JSX formatting via `@stylistic`. Targets
|
|
66
|
+
modern function components and lints `.tsx` / `.jsx` files, with type-aware
|
|
67
|
+
React rules.
|
|
68
|
+
|
|
69
|
+
## Requirements
|
|
70
|
+
|
|
71
|
+
- ESLint `>= 10.4`
|
|
72
|
+
- TypeScript `>= 5 < 6.1` (peer dependency — you provide it)
|
|
73
|
+
- Node.js `>= 24`
|
|
74
|
+
- A `tsconfig.json` for your project (required for type-aware linting — see
|
|
75
|
+
[Type-aware linting](#type-aware-linting)).
|
|
76
|
+
|
|
77
|
+
## Installation
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
npm install --save-dev @ololoepepe/eslint-config-typescript typescript
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Usage
|
|
84
|
+
|
|
85
|
+
This package is **ESM**. Each entry point exports a flat-config array — spread it
|
|
86
|
+
into your own `eslint.config.js` and add any project-specific overrides
|
|
87
|
+
afterwards.
|
|
88
|
+
|
|
89
|
+
For a **Node.js** project:
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
// eslint.config.js
|
|
93
|
+
import ololoepepe from '@ololoepepe/eslint-config-typescript/node';
|
|
94
|
+
|
|
95
|
+
export default [
|
|
96
|
+
...ololoepepe,
|
|
97
|
+
{
|
|
98
|
+
// Your project-specific overrides.
|
|
99
|
+
rules: {}
|
|
100
|
+
}
|
|
101
|
+
];
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
For a **React** project:
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
// eslint.config.js
|
|
108
|
+
import ololoepepe from '@ololoepepe/eslint-config-typescript/react';
|
|
109
|
+
|
|
110
|
+
export default [
|
|
111
|
+
...ololoepepe,
|
|
112
|
+
{
|
|
113
|
+
// Your project-specific overrides.
|
|
114
|
+
rules: {}
|
|
115
|
+
}
|
|
116
|
+
];
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
For an **environment-agnostic** project, or as the base for another config,
|
|
120
|
+
import `@ololoepepe/eslint-config-typescript` instead and add the environment
|
|
121
|
+
globals and rules your project needs.
|
|
122
|
+
|
|
123
|
+
> CommonJS consumers on Node.js ≥ 22 can still load it via `require()`
|
|
124
|
+
> (`require(ESM)` is supported), but an ESM `eslint.config.js` is recommended.
|
|
125
|
+
|
|
126
|
+
## Type-aware linting
|
|
127
|
+
|
|
128
|
+
The `@typescript-eslint` rules in this config need **type information**. The base
|
|
129
|
+
config enables the TypeScript project service
|
|
130
|
+
(`parserOptions.projectService: true`), which discovers the nearest
|
|
131
|
+
`tsconfig.json` for each linted file automatically. In practice this means:
|
|
132
|
+
|
|
133
|
+
- Your project must have a `tsconfig.json`, and the files you lint must be
|
|
134
|
+
covered by it (via `include` / `files`).
|
|
135
|
+
- `typescript` must be installed (it is a peer dependency).
|
|
136
|
+
|
|
137
|
+
The base registers the TypeScript extensions (`.ts`, `.cts`, `.mts` — plus the
|
|
138
|
+
JavaScript ones), so `eslint .` lints your TypeScript sources out of the box. The
|
|
139
|
+
`/react` layer additionally targets `.tsx` / `.jsx`.
|
|
140
|
+
|
|
141
|
+
## Conventions
|
|
142
|
+
|
|
143
|
+
A few of the style choices the config enforces:
|
|
144
|
+
|
|
145
|
+
- 2-space indentation, Unix line endings, semicolons always, single quotes.
|
|
146
|
+
- Max line length of 120.
|
|
147
|
+
- No trailing commas, no spaces inside braces.
|
|
148
|
+
- Object keys sorted (natural, case-insensitive, shorthand first); types,
|
|
149
|
+
interfaces, enums, and union/intersection members sorted via `perfectionist`.
|
|
150
|
+
- Imports ordered and grouped, no duplicates, no unresolved (via `import-x`).
|
|
151
|
+
- Typed `@typescript-eslint` rules preferred over their core equivalents; explicit
|
|
152
|
+
function/module boundary types where they add clarity.
|
|
153
|
+
- `const` over `let`, never `var`; arrow callbacks; template strings over
|
|
154
|
+
concatenation.
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
UNLICENSED — private package.
|
package/package.json
CHANGED
package/src/plugins/unicorn.js
CHANGED
|
@@ -216,7 +216,16 @@ export default {
|
|
|
216
216
|
'unicorn/prefer-else-if': 'error',
|
|
217
217
|
'unicorn/prefer-error-is-error': 'off',
|
|
218
218
|
'unicorn/prefer-event-target': 'error',
|
|
219
|
-
'unicorn/prefer-export-from': 'error',
|
|
219
|
+
'unicorn/prefer-export-from': ['error', {
|
|
220
|
+
// Do not require `export…from` for a binding that is also used internally:
|
|
221
|
+
// `import {x} from './m'; ... use x ...; export {x};`. With the default
|
|
222
|
+
// (checkUsedVariables: true) this pattern is unsatisfiable — the rule demands
|
|
223
|
+
// `export {x} from './m'`, but `no-duplicate-imports` ({includeExports: true})
|
|
224
|
+
// forbids importing and export-from'ing the same path, and the internal use
|
|
225
|
+
// means the import cannot be dropped. Pure re-exports (binding never used
|
|
226
|
+
// internally) are still required to use `export…from`.
|
|
227
|
+
checkUsedVariables: false
|
|
228
|
+
}],
|
|
220
229
|
'unicorn/prefer-flat-math-min-max': 'error',
|
|
221
230
|
'unicorn/prefer-get-or-insert-computed': 'error',
|
|
222
231
|
'unicorn/prefer-global-number-constants': 'error',
|