Skip to content

Commit 59c168e

Browse files
feat: TSL Linter Compatibility Layer (Consolidated) (#79)
1 parent 7c40ee5 commit 59c168e

30 files changed

+984
-686
lines changed

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,12 @@ export default defineConfig({
175175

176176
### Ecosystem Integration
177177

178-
TSSLint provides compatibility layers for existing linter ecosystems. These are available via `@tsslint/config` but require the corresponding compatibility package to be installed.
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.
179179

180180
#### ESLint
181-
Convert ESLint rules via `@tsslint/compat-eslint`.
182181

183182
```bash
184-
npm install @tsslint/compat-eslint --save-dev
183+
npm install eslint@9.27.0 @typescript-eslint/parser --save-dev
185184
```
186185

187186
```ts
@@ -200,10 +199,9 @@ export default defineConfig({
200199
`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/`).
201200

202201
#### TSLint
203-
Convert TSLint rules via `@tsslint/compat-tslint`.
204202

205203
```bash
206-
npm install @tsslint/compat-tslint --save-dev
204+
npm install tslint --save-dev
207205
```
208206

209207
```ts
@@ -222,7 +220,19 @@ export default defineConfig({
222220
`importTSLintRules` will automatically read `rulesDirectory` from your `tslint.json` to support third-party TSLint plugins.
223221

224222
#### TSL
225-
Convert TSL rules via `@tsslint/compat-tsl`.
223+
224+
```bash
225+
npm install tsl --save-dev
226+
```
227+
228+
```ts
229+
import { defineConfig, fromTSLRules } from '@tsslint/config';
230+
import { core } from 'tsl';
231+
232+
export default defineConfig({
233+
rules: fromTSLRules(core.all()),
234+
});
235+
```
226236

227237
## Technical Notes
228238

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"private": true,
3-
"name": "@tsslint-fixtures/convert-eslint-config",
3+
"name": "@tsslint-fixtures/compat-eslint",
44
"version": "3.0.0-alpha.0",
55
"devDependencies": {
66
"@tsslint/config": "3.0.0-alpha.0",
7-
"@tsslint/compat-eslint": "3.0.0-alpha.0",
7+
88
"eslint-plugin-expect-type": "^0.4.0"
99
}
1010
}
File renamed without changes.
File renamed without changes.

fixtures/compat-tsl/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"private": true,
3+
"name": "@tsslint-fixtures/compat-tsl",
4+
"version": "3.0.0-alpha.0",
5+
"devDependencies": {
6+
"@tsslint/config": "3.0.0-alpha.0",
7+
"tsl": "^1.0.28"
8+
}
9+
}
File renamed without changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { defineConfig, fromTSLRules } from '@tsslint/config';
2+
import { core } from 'tsl';
3+
4+
export default defineConfig({
5+
rules: fromTSLRules(core.all()),
6+
});

fixtures/compat-tslint/fixture.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// @ts-nocheck
2+
// nullable numbers are considered unsafe by default
3+
let num: number | undefined = 0;
4+
if (num) {
5+
console.log('num is defined');
6+
}
7+
8+
// nullable strings are considered unsafe by default
9+
let str: string | null = null;
10+
if (!str) {
11+
console.log('str is empty');
12+
}
13+
14+
// nullable booleans are considered unsafe by default
15+
function foo(bool?: boolean) {
16+
if (bool) {
17+
bar();
18+
}
19+
}
20+
21+
// `any`, unconstrained generics and unions of more than one primitive type are disallowed
22+
const foo = <T>(arg: T) => (arg ? 1 : 0);
23+
24+
// always-truthy and always-falsy types are disallowed
25+
let obj = {};
26+
while (obj) {
27+
obj = getObj();
28+
}

0 commit comments

Comments
 (0)