Skip to content

feat: upgrade plugin to v9 #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

10 changes: 0 additions & 10 deletions .eslintrc

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI
on:
push:
branches:
- main
pull_request:
jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Setup
uses: pnpm/action-setup@v4
with:
version: 8
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
- name: Lint
run: pnpm lint
- name: Test
run: pnpm test
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pnpm 9.4.0
nodejs 18.20.3
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Test File (Debug)",
"program": "${workspaceRoot}/node_modules/.bin/vitest",
"args": ["--config", "${workspaceRoot}/vitest.config.ts", "${relativeFile}"],
"outputCapture": "std",
"internalConsoleOptions": "openOnSessionStart",
"envFile": "${workspaceRoot}/.env"
}
]
}
88 changes: 9 additions & 79 deletions docs/rules/lines-around-comment.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

## Rule Details

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

## How to use

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

## Options

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

```ts
interface Options extends BaseLinesAroundCommentOptions {
interface Options extends BaseRuleOptions {
allowSwitchStart?: boolean;
allowSwitchEnd?: boolean;
allowEnumStart?: boolean;
allowEnumEnd?: boolean;
allowInterfaceStart?: boolean;
allowInterfaceEnd?: boolean;
allowMemberCallExpression?: boolean;
allowMemberCallExpressionStart?: boolean;
}
```

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

### `allowInterfaceStart`

Example of a correct code when `allowInterfaceStart` is set to `true`:

```ts
interface InterfaceA {
// some comment
foo: boolean;
}

interface InterfaceA {
/**
* Some multi-line comment
*/
foo: boolean;
}
```

### `allowInterfaceEnd`

Example of a correct code when `allowInterfaceEnd` is set to `true`:

```ts
interface InterfaceA {
foo: boolean; // some comment
}

interface InterfaceA {
foo: boolean /** comment */;
}
```

### `allowEnumStart`

Example of a correct code when `allowEnumStart` is set to `true`:

```ts
enum MyEnum {
// some comment
Value,
}

enum MyEnum {
/**
* Some multi-line comment
*/
Value,
}
```

### `allowEnumEnd`

Example of a correct code when `allowEnumEnd` is set to `true`:

```ts
enum MyEnum {
// some comment
Value,
}

enum MyEnum {
Value /* some comment */,
}

enum MyEnum {
Value,
/** comment */
}
```

### `allowSwitchStart`

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

```ts
doSomething()
// some comment
.a.b.c.d.replace('', '');

doSomething()
.a // some comment
.b // some comment
Expand Down
14 changes: 14 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import blitzPlugin from '@blitz/eslint-plugin';

export default [
{
ignores: ['**/dist', '**/node_modules'],
},
...blitzPlugin.configs.recommended(),
{
rules: {
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-require-imports': 0,
},
},
];
63 changes: 36 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@blitz/eslint-plugin",
"version": "0.0.44",
"version": "0.1.0",
"license": "MIT",
"description": "An ESLint config to enforce a consistent code styles across StackBlitz projects",
"keywords": [
"eslint",
Expand All @@ -9,42 +10,50 @@
],
"author": "Dominic Elm",
"main": "dist/index.js",
"scripts": {
"build": "rm -rf dist && tsc -b",
"test": "vitest run",
"test:watch": "vitest",
"lint": "eslint \"{src,test}/**/*.{js,ts,json,jsonc}\"",
"preversion": "pnpm test",
"postversion": "git push && git push --tags",
"prepack": "pnpm run build"
},
"engines": {
"node": "^18.0.0 || ^20.0.0"
},
"files": [
"dist",
"docs",
"package.json",
"README.md",
"LICENSE"
],
"scripts": {
"build": "tsc -b",
"test": "jest",
"preversion": "npm test",
"postversion": "git push && git push --tags",
"prepack": "npm run build"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "5.59.7",
"@typescript-eslint/parser": "^5.59.7",
"@typescript-eslint/utils": "^5.59.7",
"common-tags": "^1.8.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-jsonc": "^2.6.0",
"eslint-plugin-prettier": "^4.0.0"
"@stylistic/eslint-plugin-ts": "^2.2.2",
"@typescript-eslint/eslint-plugin": "^8.0.0-alpha.30",
"@typescript-eslint/parser": "^8.0.0-alpha.30",
"@typescript-eslint/utils": "^8.0.0-alpha.30",
Comment on lines +34 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the alpha versions?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea unfortunately we do need them because only those support the new flat config format.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I talked to James Henry and they will release the real version very soon, since it's already a release candidate.

"common-tags": "^1.8.2",
"eslint": "^9.5.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsonc": "^2.16.0",
"eslint-plugin-prettier": "^5.1.3",
"globals": "^15.6.0",
"typescript-eslint": "^8.0.0-alpha.30"
},
"devDependencies": {
"@blitz/eslint-plugin": "link:./",
"@types/common-tags": "^1.8.0",
"@types/eslint": "^8.4.1",
"@types/jest": "^26.0.10",
"@types/node": "^14.6.0",
"eslint-etc": "^5.2.1",
"jest": "^29.5.0",
"jest-node-exports-resolver": "^1.1.5",
"prettier": "^2.5.1",
"ts-jest": "^29.1.0",
"typescript": "^5.0.4"
"@types/common-tags": "^1.8.4",
"@types/eslint": "^8.56.10",
"@types/node": "^20.14.8",
"@typescript-eslint/rule-tester": "^8.0.0-alpha.30",
"eslint-vitest-rule-tester": "^0.3.2",
"prettier": "^3.3.2",
"typescript": "~5.4.5",
"vitest": "^1.6.0"
},
"license": "MIT"
"resolutions": {
"@typescript-eslint/utils": "^8.0.0-alpha.30"
}
}
Loading