Skip to content

Commit

Permalink
chore: change lint config (#970)
Browse files Browse the repository at this point in the history
* style: change trailingComma config to es5

* chore: add simple-import-sort settings
  • Loading branch information
nogic1008 committed May 5, 2024
1 parent 8510191 commit afaaded
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.json
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
@@ -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
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
@@ -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
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
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
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
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
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
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
coverage: {
reporter: ['text', 'lcov']
}
}
reporter: ['text', 'lcov'],
},
},
})

0 comments on commit afaaded

Please sign in to comment.