Skip to content

Commit d665151

Browse files
authored
feat: upgrade plugin to v9 (#23)
1 parent 4147825 commit d665151

33 files changed

+4590
-4123
lines changed

.eslintignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
jobs:
8+
test:
9+
name: Test
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
node-version: [18]
14+
steps:
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: ${{ matrix.node-version }}
18+
- name: Setup
19+
uses: pnpm/action-setup@v4
20+
with:
21+
version: 8
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
- name: Install dependencies
25+
run: pnpm install
26+
- name: Build
27+
run: pnpm build
28+
- name: Lint
29+
run: pnpm lint
30+
- name: Test
31+
run: pnpm test

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
pnpm 9.4.0
12
nodejs 18.20.3

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "launch",
7+
"name": "Test File (Debug)",
8+
"program": "${workspaceRoot}/node_modules/.bin/vitest",
9+
"args": ["--config", "${workspaceRoot}/vitest.config.ts", "${relativeFile}"],
10+
"outputCapture": "std",
11+
"internalConsoleOptions": "openOnSessionStart",
12+
"envFile": "${workspaceRoot}/.env"
13+
}
14+
]
15+
}

docs/rules/lines-around-comment.md

Lines changed: 9 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
55
## Rule Details
66

7-
This rule extends the base [`eslint/lines-around-comment`](https://eslint.org/docs/rules/lines-around-comment) rule.
8-
It adds support for allowing comments at the start and end of `interface`'s, type literals and `enum`s.
7+
This rule extends the base [`@stylistic/ts/lines-around-comment`](https://eslint.style/rules/ts/lines-around-comment) rule.
8+
It adds support for allowing comments at the start and end of `switch` statements, and fixes a bug with enums, arrays, and object literals.
99

1010
## How to use
1111

@@ -17,93 +17,19 @@ It adds support for allowing comments at the start and end of `interface`'s, typ
1717

1818
## Options
1919

20-
See [`eslint/lines-around-comment`](https://eslint.org/docs/rules/lines-around-comment#options-50) options.
20+
See [`@stylistic/ts/lines-around-comment`](https://eslint.style/rules/ts/lines-around-comment#options) options.
2121
This rule adds the following options:
2222

2323
```ts
24-
interface Options extends BaseLinesAroundCommentOptions {
24+
interface Options extends BaseRuleOptions {
2525
allowSwitchStart?: boolean;
2626
allowSwitchEnd?: boolean;
27-
allowEnumStart?: boolean;
28-
allowEnumEnd?: boolean;
29-
allowInterfaceStart?: boolean;
30-
allowInterfaceEnd?: boolean;
31-
allowMemberCallExpression?: boolean;
27+
allowMemberCallExpressionStart?: boolean;
3228
}
3329
```
3430

3531
It also overrides `allowObjectStart` and `allowObjectEnd` to work with type object literals.
3632

37-
### `allowInterfaceStart`
38-
39-
Example of a correct code when `allowInterfaceStart` is set to `true`:
40-
41-
```ts
42-
interface InterfaceA {
43-
// some comment
44-
foo: boolean;
45-
}
46-
47-
interface InterfaceA {
48-
/**
49-
* Some multi-line comment
50-
*/
51-
foo: boolean;
52-
}
53-
```
54-
55-
### `allowInterfaceEnd`
56-
57-
Example of a correct code when `allowInterfaceEnd` is set to `true`:
58-
59-
```ts
60-
interface InterfaceA {
61-
foo: boolean; // some comment
62-
}
63-
64-
interface InterfaceA {
65-
foo: boolean /** comment */;
66-
}
67-
```
68-
69-
### `allowEnumStart`
70-
71-
Example of a correct code when `allowEnumStart` is set to `true`:
72-
73-
```ts
74-
enum MyEnum {
75-
// some comment
76-
Value,
77-
}
78-
79-
enum MyEnum {
80-
/**
81-
* Some multi-line comment
82-
*/
83-
Value,
84-
}
85-
```
86-
87-
### `allowEnumEnd`
88-
89-
Example of a correct code when `allowEnumEnd` is set to `true`:
90-
91-
```ts
92-
enum MyEnum {
93-
// some comment
94-
Value,
95-
}
96-
97-
enum MyEnum {
98-
Value /* some comment */,
99-
}
100-
101-
enum MyEnum {
102-
Value,
103-
/** comment */
104-
}
105-
```
106-
10733
### `allowSwitchStart`
10834

10935
Example of a correct code when `allowSwitchStart` is set to `true`:
@@ -167,6 +93,10 @@ switch (someValue) {
16793
Example of a correct code when `allowMemberCallExpression` is set to `true`:
16894

16995
```ts
96+
doSomething()
97+
// some comment
98+
.a.b.c.d.replace('', '');
99+
170100
doSomething()
171101
.a // some comment
172102
.b // some comment

eslint.config.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import blitzPlugin from '@blitz/eslint-plugin';
2+
3+
export default [
4+
{
5+
ignores: ['**/dist', '**/node_modules'],
6+
},
7+
...blitzPlugin.configs.recommended(),
8+
{
9+
rules: {
10+
'@typescript-eslint/no-var-requires': 0,
11+
'@typescript-eslint/no-require-imports': 0,
12+
},
13+
},
14+
];

package.json

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@blitz/eslint-plugin",
3-
"version": "0.0.45",
3+
"version": "0.1.0",
4+
"license": "MIT",
45
"description": "An ESLint config to enforce a consistent code styles across StackBlitz projects",
56
"keywords": [
67
"eslint",
@@ -9,46 +10,50 @@
910
],
1011
"author": "Dominic Elm",
1112
"main": "dist/index.js",
12-
"files": [
13-
"dist",
14-
"docs",
15-
"package.json",
16-
"README.md",
17-
"LICENSE"
18-
],
1913
"scripts": {
2014
"build": "rm -rf dist && tsc -b",
21-
"test": "jest",
15+
"test": "vitest run",
16+
"test:watch": "vitest",
2217
"lint": "eslint '{src,test}/**/*'",
23-
"preversion": "npm test",
18+
"preversion": "pnpm test",
2419
"postversion": "git push && git push --tags",
25-
"prepack": "npm run build"
20+
"prepack": "pnpm run build"
2621
},
2722
"engines": {
2823
"node": "^18.0.0 || ^20.0.0"
2924
},
25+
"files": [
26+
"dist",
27+
"docs",
28+
"package.json",
29+
"README.md",
30+
"LICENSE"
31+
],
3032
"dependencies": {
31-
"@typescript-eslint/eslint-plugin": "5.59.7",
32-
"@typescript-eslint/parser": "^5.59.7",
33-
"@typescript-eslint/utils": "^5.59.7",
34-
"common-tags": "^1.8.0",
35-
"eslint": "^8.11.0",
36-
"eslint-config-prettier": "^8.5.0",
37-
"eslint-plugin-jsonc": "^2.6.0",
38-
"eslint-plugin-prettier": "^4.0.0"
33+
"@stylistic/eslint-plugin-ts": "^2.2.2",
34+
"@typescript-eslint/eslint-plugin": "^8.0.0-alpha.30",
35+
"@typescript-eslint/parser": "^8.0.0-alpha.30",
36+
"@typescript-eslint/utils": "^8.0.0-alpha.30",
37+
"common-tags": "^1.8.2",
38+
"eslint": "^9.5.0",
39+
"eslint-config-prettier": "^9.1.0",
40+
"eslint-plugin-jsonc": "^2.16.0",
41+
"eslint-plugin-prettier": "^5.1.3",
42+
"globals": "^15.6.0",
43+
"typescript-eslint": "^8.0.0-alpha.30"
3944
},
4045
"devDependencies": {
4146
"@blitz/eslint-plugin": "link:./",
42-
"@types/common-tags": "^1.8.0",
43-
"@types/eslint": "^8.4.1",
44-
"@types/jest": "^26.0.10",
45-
"@types/node": "^14.6.0",
46-
"eslint-etc": "^5.2.1",
47-
"jest": "^29.5.0",
48-
"jest-node-exports-resolver": "^1.1.5",
49-
"prettier": "^2.5.1",
50-
"ts-jest": "^29.1.0",
51-
"typescript": "^5.0.4"
47+
"@types/common-tags": "^1.8.4",
48+
"@types/eslint": "^8.56.10",
49+
"@types/node": "^20.14.8",
50+
"@typescript-eslint/rule-tester": "^8.0.0-alpha.30",
51+
"eslint-vitest-rule-tester": "^0.3.2",
52+
"prettier": "^3.3.2",
53+
"typescript": "~5.4.5",
54+
"vitest": "^1.6.0"
5255
},
53-
"license": "MIT"
56+
"resolutions": {
57+
"@typescript-eslint/utils": "^8.0.0-alpha.30"
58+
}
5459
}

0 commit comments

Comments
 (0)