Skip to content

Commit

Permalink
feat: upgrade plugin to v9 (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
d3lm authored Jun 25, 2024
1 parent 4147825 commit d665151
Show file tree
Hide file tree
Showing 33 changed files with 4,590 additions and 4,123 deletions.
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
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +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,
},
},
];
65 changes: 35 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@blitz/eslint-plugin",
"version": "0.0.45",
"version": "0.1.0",
"license": "MIT",
"description": "An ESLint config to enforce a consistent code styles across StackBlitz projects",
"keywords": [
"eslint",
Expand All @@ -9,46 +10,50 @@
],
"author": "Dominic Elm",
"main": "dist/index.js",
"files": [
"dist",
"docs",
"package.json",
"README.md",
"LICENSE"
],
"scripts": {
"build": "rm -rf dist && tsc -b",
"test": "jest",
"test": "vitest run",
"test:watch": "vitest",
"lint": "eslint '{src,test}/**/*'",
"preversion": "npm test",
"preversion": "pnpm test",
"postversion": "git push && git push --tags",
"prepack": "npm run build"
"prepack": "pnpm run build"
},
"engines": {
"node": "^18.0.0 || ^20.0.0"
},
"files": [
"dist",
"docs",
"package.json",
"README.md",
"LICENSE"
],
"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",
"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

0 comments on commit d665151

Please sign in to comment.