Skip to content

Commit 8509b8c

Browse files
feat: re-introduce @tsslint/compat-eslint as a separate package (#80)
1 parent ae27d79 commit 8509b8c

File tree

13 files changed

+588
-489
lines changed

13 files changed

+588
-489
lines changed

README.md

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,38 @@ export default defineConfig({
175175

176176
### Ecosystem Integration
177177

178-
TSSLint provides compatibility layers for existing linter ecosystems. The integration functions are available via `@tsslint/config`, and you only need to install the original linter package to use them.
178+
TSSLint provides compatibility layers for existing linter ecosystems (ESLint, TSLint, and TSL). These integrations are coordinated through `@tsslint/config`, which acts as a bridge to load rules from other linters.
179179

180-
#### ESLint
180+
To use a compatibility layer, you must install the corresponding TSSLint compatibility package. If you wish to use the original linter's built-in rules, you must also install the original linter package itself.
181+
182+
#### 1. ESLint
183+
184+
**Installation:**
185+
186+
First, install the TSSLint compatibility package for ESLint.
187+
188+
```bash
189+
npm install @tsslint/compat-eslint --save-dev
190+
```
191+
192+
If you want to use ESLint's built-in rules (e.g., `no-unused-vars`), you must also install `eslint` (optional):
181193

182194
```bash
183-
npm install eslint@9.27.0 @typescript-eslint/parser --save-dev
195+
npm install eslint --save-dev
184196
```
185197

198+
**Type Definition Update:**
199+
200+
After installing the original linter package, run the following command to update JSDoc for built-in rules, enabling better IDE support:
201+
202+
```bash
203+
npx tsslint-docgen
204+
```
205+
206+
**Usage in `tsslint.config.ts`:**
207+
208+
Use `importESLintRules` to load rules. This function automatically resolves and loads rules from ESLint plugins (e.g., `@typescript-eslint/eslint-plugin`) by searching your `node_modules`. Plugin rules are identified by their prefix (e.g., `@typescript-eslint/`).
209+
186210
```ts
187211
import { defineConfig, importESLintRules } from '@tsslint/config';
188212

@@ -196,14 +220,28 @@ export default defineConfig({
196220
});
197221
```
198222

199-
`importESLintRules` will automatically resolve and load rules from ESLint plugins (e.g., `@typescript-eslint/eslint-plugin`) by searching your `node_modules`. Plugin rules are identified by their prefix (e.g., `@typescript-eslint/`).
223+
#### 2. TSLint
224+
225+
**Installation:**
200226

201-
#### TSLint
227+
If you want to use TSLint's built-in rules, you need to install `tslint` (optional):
202228

203229
```bash
204230
npm install tslint --save-dev
205231
```
206232

233+
**Type Definition Update:**
234+
235+
After installing `tslint`, run the following command to update JSDoc for built-in rules:
236+
237+
```bash
238+
npx tsslint-docgen
239+
```
240+
241+
**Usage in `tsslint.config.ts`:**
242+
243+
Use `importTSLintRules` to load rules. This function automatically reads `rulesDirectory` from your `tslint.json` to support third-party TSLint plugins.
244+
207245
```ts
208246
import { defineConfig, importTSLintRules } from '@tsslint/config';
209247

@@ -217,14 +255,20 @@ export default defineConfig({
217255
});
218256
```
219257

220-
`importTSLintRules` will automatically read `rulesDirectory` from your `tslint.json` to support third-party TSLint plugins.
258+
#### 3. TSL
221259

222-
#### TSL
260+
**Installation:**
261+
262+
TSL rules are imported directly from the `tsl` package.
223263

224264
```bash
225265
npm install tsl --save-dev
226266
```
227267

268+
**Usage in `tsslint.config.ts`:**
269+
270+
Use `fromTSLRules` to load TSL rules.
271+
228272
```ts
229273
import { defineConfig, fromTSLRules } from '@tsslint/config';
230274
import { core } from 'tsl';

fixtures/compat-eslint/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"version": "3.0.0-alpha.0",
55
"devDependencies": {
66
"@tsslint/config": "3.0.0-alpha.0",
7-
"@typescript-eslint/parser": "^8.16.0",
8-
"eslint": "9.27.0",
7+
"@tsslint/compat-eslint": "3.0.0-alpha.0",
98
"eslint-plugin-expect-type": "^0.4.0"
109
}
1110
}

packages/cli/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"name": "@tsslint/cli",
33
"version": "3.0.0-alpha.0",
44
"license": "MIT",
5+
"engines": {
6+
"node": ">=22.6.0"
7+
},
58
"bin": {
69
"tsslint": "./bin/tsslint.js"
710
},

packages/compat-eslint/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023-present Johnson Chu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)