Skip to content

Commit

Permalink
feat: add lint check (#101)
Browse files Browse the repository at this point in the history
* feat: add lint check

* fix: workflow

* fix: add package.json
  • Loading branch information
konpeki622 committed Jun 20, 2022
1 parent 2925250 commit 5eb9bde
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 14 deletions.
5 changes: 4 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
tests/
tests
node_modules
dist
coverage
27 changes: 22 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@
module.exports = {
env: {
es2021: true,
node: true
node: true,
},
extends: ['standard'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 12,
sourceType: 'module'
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
rules: {
semi: 0,
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports' }
]
}
{ prefer: 'type-imports' },
],
// js/ts
'eol-last': 'error',
'no-trailing-spaces': 'error',
'comma-style': ['error', 'last'],
'comma-dangle': ['error', 'always-multiline'],
'no-multi-spaces': 'error',
quotes: [
'error',
'single',
{ avoidEscape: true, allowTemplateLiterals: true },
],
camelcase: ['error', { properties: 'never' }],
'object-curly-spacing': ['error', 'always'],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
},
}
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,21 @@ jobs:
run: npm run build
- name: Test
run: npm run test

lint:
name: 'Lint on Node.js 16 OS: ubuntu-latest'
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set node version to 16
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install
run: npm install
- name: Build
run: npm run build
- name: Lint
run: npm run lint
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"test": "vitest",
"test:run": "vitest run",
"test:coverage": "vitest run --coverage",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
},
"repository": {
Expand Down
10 changes: 5 additions & 5 deletions scripts/verifyCommit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ if (!releaseRE.test(msg) && !commitRE.test(msg)) {
console.log()
console.error(
` ${chalk.bgRed.white(' ERROR ')} ${chalk.red(
`invalid commit message format.`
'invalid commit message format.',
)}\n\n` +
chalk.red(
` Proper commit message format is required for automated changelog generation. Examples:\n\n`
' Proper commit message format is required for automated changelog generation. Examples:\n\n',
) +
` ${chalk.green(`feat: add 'comments' option`)}\n` +
` ${chalk.green(`fix: handle events on blur (close #28)`)}\n\n` +
chalk.red(` See .github/commit-convention.md for more details.\n`)
` ${chalk.green('feat: add \'comments\' option')}\n` +
` ${chalk.green('fix: handle events on blur (close #28)')}\n\n` +
chalk.red(' See .github/commit-convention.md for more details.\n'),
)
process.exit(1)
}
6 changes: 3 additions & 3 deletions vitest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export default defineConfig({
test: {
root: 'tests',
resolve: {
extensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
extensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
},
testTimeout: 2000,
globals: true
}
globals: true,
},
})

0 comments on commit 5eb9bde

Please sign in to comment.