Skip to content
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

chore: change lint config #970

Merged
merged 2 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"arrowParens": "always",
"semi": false,
"singleQuote": true,
"trailingComma": "none"
"trailingComma": "es5"
}
36 changes: 15 additions & 21 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
// @ts-check
/* eslint-disable @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access */
import eslint from '@eslint/js'
import eslintConfigPrettier from 'eslint-config-prettier'
import prettier from 'eslint-config-prettier'
import node from 'eslint-plugin-n'
import simpleImportSort from 'eslint-plugin-simple-import-sort'
import vitest from 'eslint-plugin-vitest'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{ ignores: ['node_modules/**', 'dist/**'] },
eslint.configs.recommended,
// eslint-plugin-n
// Node.js
{
...node.configs['flat/recommended-script'],
rules: {
'n/no-missing-import': ['off']
}
rules: { 'n/no-missing-import': ['off'] },
},
// typescript-eslint
// TypeScript
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
languageOptions: {
parserOptions: {
project: './tsconfig.lint.json'
}
}
},
{ languageOptions: { parserOptions: { project: './tsconfig.lint.json' } } },
// Prettier
eslintConfigPrettier,
// vitest
prettier,
// Vitest
{ ...vitest.configs.recommended, files: ['test/**'] },
// simple-import-sort
{
files: ['test/**'],
plugins: {
vitest
},
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
plugins: { 'simple-import-sort': simpleImportSort },
rules: {
...vitest.configs.recommended.rules
}
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
},
}
)
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"fix": "run-p \"lint:eslint -- --fix\" \"lint:prettier -- --write\"",
"lint": "run-p lint:*",
"lint:eslint": "eslint .",
"lint:prettier": "prettier --ignore-path .gitignore -l \"**/*.{ts,json,md,yml}\"",
"lint:prettier": "prettier --ignore-path .gitignore -l \"**/*.{ts,mjs,json,md,yml}\"",
"test": "vitest run"
},
"lint-staged": {
"*.ts": [
"*.{ts,mjs}": [
"eslint --fix",
"prettier --write"
],
Expand Down
8 changes: 4 additions & 4 deletions src/event.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { context } from '@actions/github'
import type {
IssueCommentEvent,
PullRequestReviewEvent
PullRequestReviewEvent,
} from '@octokit/webhooks-types'

const supportedEvent = new Set([
'issue_comment',
'pull_request_review'
'pull_request_review',
] as const)
type SupportedEvent =
typeof supportedEvent extends Iterable<infer U> ? U : never
Expand Down Expand Up @@ -36,14 +36,14 @@ export function getEventWebhook(eventName: SupportedEvent): EventWebhook {
const payload = context.payload as IssueCommentEvent
return {
comment: payload.comment.body,
issueNumber: payload.issue.number
issueNumber: payload.issue.number,
}
}
case 'pull_request_review': {
const payload = context.payload as PullRequestReviewEvent
return {
comment: payload.review.body,
issueNumber: payload.pull_request.number
issueNumber: payload.pull_request.number,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/input-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ export function getInputParams(): InputParameter {
imageUrl,
searchPattern: pattern.length
? pattern.map((x) => new RegExp(x, 'm'))
: [/^(lgtm|LGTM)$/m]
: [/^(lgtm|LGTM)$/m],
}
}
2 changes: 1 addition & 1 deletion src/send-comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export async function sendCommentAsync(
owner,
repo,
issue_number: issueNumber,
body: comment
body: comment,
})
}
6 changes: 3 additions & 3 deletions test/event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ vi.mock('@actions/github', () => ({
comment: { body: 'comment.body' },
issue: { number: 9 },
review: { body: 'review.body' },
pull_request: { number: 10 }
}
}
pull_request: { number: 10 },
},
},
}))

describe('event.ts', () => {
Expand Down
6 changes: 3 additions & 3 deletions test/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ vi.mock('@actions/core')
vi.mock('@actions/github', () => ({
context: {
eventName: 'event_name',
repo: { owner: 'owner', repo: 'repo' }
}
repo: { owner: 'owner', repo: 'repo' },
},
}))
vi.mock('../src/event')
vi.mock('../src/input-helper')
Expand All @@ -28,7 +28,7 @@ describe('main.ts', () => {
vi.mocked(getInputParams).mockReturnValue({
token: 'token',
imageUrl: 'imageUrl',
searchPattern: [/^(lgtm|LGTM)$/m]
searchPattern: [/^(lgtm|LGTM)$/m],
})
})

Expand Down
2 changes: 1 addition & 1 deletion test/send-comment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('send-comment.ts', () => {
owner,
repo,
issue_number: issueNumber,
body: comment
body: comment,
})
})
})
Expand Down
6 changes: 3 additions & 3 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
coverage: {
reporter: ['text', 'lcov']
}
}
reporter: ['text', 'lcov'],
},
},
})
Loading