Skip to content

Commit ac7a1b7

Browse files
committed
chore: update configuration files and documentation
Various configuration files and documentation have been updated to align with the latest changes.
1 parent ffa8033 commit ac7a1b7

File tree

6 files changed

+127
-49
lines changed

6 files changed

+127
-49
lines changed

demos/basic-flat-config/eslint.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import tseslint from "typescript-eslint";
55

66
export default tseslint.config(
77
...tseslint.configs.recommendedTypeCheckedOnly,
8+
{
9+
languageOptions: {
10+
parserOptions: {
11+
projectService: true,
12+
},
13+
},
14+
},
815
safeql.configs.connections({
916
databaseUrl: "postgres://postgres:postgres@localhost:5432/safeql_basic_flat_config",
1017
targets: [{ tag: "sql", transform: "{type}[]" }],

demos/config-file-flat-config/eslint.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,12 @@ import tseslint from "typescript-eslint";
55

66
export default tseslint.config(
77
...tseslint.configs.recommendedTypeCheckedOnly,
8+
{
9+
languageOptions: {
10+
parserOptions: {
11+
projectService: true,
12+
},
13+
},
14+
},
815
safeql.configs.useConfigFile,
916
);

docs/guide/configuration.md

Lines changed: 104 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,24 @@ Check out [@ts-safeql-demos/basic-flat-config](https://github.com/ts-safeql/safe
1717

1818
```js
1919
// eslint.config.js
20-
21-
export default [
22-
// ...
20+
import tseslint from "typescript-eslint";
21+
import safeql from "@ts-safeql/eslint-plugin/config";
22+
23+
export default tseslint.config(
24+
{
25+
languageOptions: {
26+
parserOptions: {
27+
projectService: true,
28+
},
29+
},
30+
},
2331
safeql.configs.connections({
2432
// The URL of the database:
2533
databaseUrl: "postgres://postgres:postgres@localhost:5432/my_database",
2634
// Check all of the queries that are used with the `sql` tag:
2735
targets: [{ tag: "sql" }],
28-
}),
29-
];
36+
})
37+
);
3038
```
3139

3240
== Legacy Config
@@ -87,9 +95,17 @@ Check out [@ts-safeql-demos/multi-connections](https://github.com/ts-safeql/safe
8795

8896
```js
8997
// eslint.config.js
90-
91-
export default [
92-
// ...
98+
import tseslint from "typescript-eslint";
99+
import safeql from "@ts-safeql/eslint-plugin/config";
100+
101+
export default tseslint.config(
102+
{
103+
languageOptions: {
104+
parserOptions: {
105+
projectService: true,
106+
},
107+
},
108+
},
93109
safeql.configs.connections({
94110
connections: [
95111
{
@@ -109,8 +125,8 @@ export default [
109125
],
110126
},
111127
],
112-
}),
113-
];
128+
})
129+
);
114130
```
115131

116132
== Legacy Config
@@ -165,9 +181,17 @@ Check out [@ts-safeql-demos/basic-migrations-raw](https://github.com/ts-safeql/s
165181

166182
```js
167183
// eslint.config.js
168-
169-
export default [
170-
// ...
184+
import tseslint from "typescript-eslint";
185+
import safeql from "@ts-safeql/eslint-plugin/config";
186+
187+
export default tseslint.config(
188+
{
189+
languageOptions: {
190+
parserOptions: {
191+
projectService: true,
192+
},
193+
},
194+
},
171195
safeql.configs.connections({
172196
connections: [
173197
{
@@ -180,8 +204,8 @@ export default [
180204
// "connectionUrl": "postgres://pguser:password@localhost:5432/postgres"
181205
},
182206
],
183-
}),
184-
];
207+
})
208+
);
185209
```
186210

187211
== Legacy Config
@@ -250,9 +274,17 @@ Check out [@ts-safeql-demos/multi-connections](https://github.com/ts-safeql/safe
250274

251275
```js
252276
// eslint.config.js
253-
254-
export default [
255-
// ...
277+
import tseslint from "typescript-eslint";
278+
import safeql from "@ts-safeql/eslint-plugin/config";
279+
280+
export default tseslint.config(
281+
{
282+
languageOptions: {
283+
parserOptions: {
284+
projectService: true,
285+
},
286+
},
287+
},
256288
safeql.configs.connections({
257289
connections: [
258290
{
@@ -270,8 +302,8 @@ export default [
270302
],
271303
},
272304
],
273-
}),
274-
];
305+
})
306+
);
275307
```
276308

277309
== Legacy Config
@@ -316,9 +348,17 @@ export default [
316348

317349
```js
318350
// eslint.config.js
319-
320-
export default [
321-
// ...
351+
import tseslint from "typescript-eslint";
352+
import safeql from "@ts-safeql/eslint-plugin/config";
353+
354+
export default tseslint.config(
355+
{
356+
languageOptions: {
357+
parserOptions: {
358+
projectService: true,
359+
},
360+
},
361+
},
322362
safeql.configs.connections({
323363
connections: [
324364
{
@@ -343,8 +383,8 @@ export default [
343383
],
344384
},
345385
],
346-
}),
347-
];
386+
})
387+
);
348388
```
349389

350390
== Legacy Config
@@ -399,9 +439,17 @@ SafeQL uses [minimatch](https://github.com/isaacs/minimatch) to match the glob p
399439

400440
```js
401441
// eslint.config.js
402-
403-
export default [
404-
// ...
442+
import tseslint from "typescript-eslint";
443+
import safeql from "@ts-safeql/eslint-plugin/config";
444+
445+
export default tseslint.config(
446+
{
447+
languageOptions: {
448+
parserOptions: {
449+
projectService: true,
450+
},
451+
},
452+
},
405453
safeql.configs.connections({
406454
// The URL of the database:
407455
databaseUrl: "postgres://postgres:postgres@localhost:5432/my_database",
@@ -410,8 +458,8 @@ export default [
410458
// either `db.$queryRaw` or `db.$executeRaw` // [!code focus]
411459
{ tag: "db.+($queryRaw|$executeRaw)" }, // [!code focus]
412460
],
413-
}),
414-
];
461+
})
462+
);
415463
```
416464

417465
== Legacy Config
@@ -453,9 +501,17 @@ SafeQL can also use regex to match the sql tags.
453501

454502
```js
455503
// eslint.config.js
456-
457-
export default [
458-
// ...
504+
import tseslint from "typescript-eslint";
505+
import safeql from "@ts-safeql/eslint-plugin/config";
506+
507+
export default tseslint.config(
508+
{
509+
languageOptions: {
510+
parserOptions: {
511+
projectService: true,
512+
},
513+
},
514+
},
459515
safeql.configs.connections({
460516
// The URL of the database:
461517
databaseUrl: "postgres://postgres:postgres@localhost:5432/my_database",
@@ -464,8 +520,8 @@ export default [
464520
// either `db.$queryRaw` or `db.$executeRaw` // [!code focus]
465521
{ tag: { regex: 'db\.($queryRaw|$executeRaw)' } }, // [!code focus]
466522
],
467-
}),
468-
];
523+
})
524+
);
469525
```
470526

471527
== Legacy Config
@@ -519,9 +575,17 @@ function getName() {
519575
520576
```js
521577
// eslint.config.js
522-
523-
export default [
524-
// ...
578+
import tseslint from "typescript-eslint";
579+
import safeql from "@ts-safeql/eslint-plugin/config";
580+
581+
export default tseslint.config(
582+
{
583+
languageOptions: {
584+
parserOptions: {
585+
projectService: true,
586+
},
587+
},
588+
},
525589
safeql.configs.connections({
526590
connections: [
527591
{
@@ -532,8 +596,8 @@ export default [
532596
],
533597
},
534598
],
535-
}),
536-
];
599+
})
600+
);
537601
```
538602
539603
== Legacy Config

docs/guide/getting-started.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ import safeql from "@ts-safeql/eslint-plugin/config";
4545
import tseslint from "typescript-eslint";
4646

4747
export default tseslint.config(
48-
// ...
48+
{
49+
languageOptions: {
50+
parserOptions: {
51+
projectService: true,
52+
},
53+
},
54+
},
4955
safeql.configs.connections({
5056
// read more about configuration in the next section
5157
databaseUrl: "postgres://postgres:postgres@localhost:5432/my_database",
@@ -55,7 +61,7 @@ export default tseslint.config(
5561
```
5662

5763
== Legacy Config
58-
1. Add `@ts-safeql/eslint-plugin` to your plugins and set [`parserOptions.project`](https://typescript-eslint.io/docs/linting/typed-linting):
64+
1. Add `@ts-safeql/eslint-plugin` to your plugins and set [`parserOptions.project`](https://typescript-eslint.io/docs/linting/typed-linting) (or `parserOptions.projectService` for typescript-eslint v8+):
5965

6066
```json
6167
// .eslintrc.json

packages/eslint-plugin/src/config.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ export default {
1414
rules: {
1515
"@ts-safeql/check-sql": ["error", { useConfigFile: true }],
1616
},
17-
languageOptions: {
18-
parserOptions: { project: true },
19-
},
2017
} satisfies FlatConfig.Config,
2118

2219
/**
@@ -29,9 +26,6 @@ export default {
2926
rules: {
3027
"@ts-safeql/check-sql": ["error", { connections }],
3128
},
32-
languageOptions: {
33-
parserOptions: { project: true },
34-
},
3529
}),
3630
},
3731
};

packages/eslint-plugin/src/rules/check-sql.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const ruleTester = new RuleTester({
2222
languageOptions: {
2323
parser: parser,
2424
parserOptions: {
25-
project: true,
25+
projectService: true,
2626
tsconfigRootDir: path.resolve(__dirname, "./ts-fixture"),
2727
},
2828
},

0 commit comments

Comments
 (0)