Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
chore: add prettier and linting rules
Browse files Browse the repository at this point in the history
  • Loading branch information
seanwu1105 committed Aug 3, 2022
1 parent 30f3620 commit 16aecb9
Show file tree
Hide file tree
Showing 24 changed files with 1,811 additions and 287 deletions.
6 changes: 0 additions & 6 deletions .commitlintrc

This file was deleted.

6 changes: 6 additions & 0 deletions .commitlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["@commitlint/config-conventional"],
"header-max-length": 50,
"body-max-line-length": 80,
"footer-max-length": 50
}
99 changes: 79 additions & 20 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,83 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"root": true,
"ignorePatterns": ["out", "dist", "**/*.d.ts"],
"overrides": [
{
"files": ["*.ts"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["tsconfig.json"],
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
},
"ignorePatterns": [
"out",
"dist",
"**/*.d.ts"
]
},
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"no-console": "error",
"prefer-const": "error",
"func-style": ["error", "declaration", { "allowArrowFunctions": true }],
"no-param-reassign": "error",
"no-else-return": "error",
"max-len": [
"error",
{
"code": 100,
"ignoreStrings": true,
"ignoreUrls": true,
"ignoreTemplateLiterals": true,
"ignoreRegExpLiterals": true
}
],
"class-methods-use-this": "error",
"no-magic-numbers": "off", // must disable the base rule as it can report incorrect errors
"@typescript-eslint/no-magic-numbers": [
"error",
{ "ignore": [0, 1], "ignoreDefaultValues": true }
],
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_" }
],
"@typescript-eslint/array-type": "error",
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-arguments": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/prefer-optional-chain": "error",
"@typescript-eslint/prefer-readonly": "error",
"@typescript-eslint/prefer-as-const": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/prefer-ts-expect-error": "error",
"@typescript-eslint/promise-function-async": [
"error",
{ "checkArrowFunctions": false }
],
"@typescript-eslint/member-ordering": [
"error",
{
"default": [
"static-field",
"abstract-field",
"instance-field",
"decorated-field",
"constructor",
"static-method",
"abstract-method",
"instance-method",
"decorated-method"
]
}
]
}
}
]
}
34 changes: 22 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
on: [push, pull_request]

jobs:
build:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint

test:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- run: npm install
- run: xvfb-run -a npm test
if: runner.os == 'Linux'
- run: npm test
if: runner.os != 'Linux'
- name: Checkout
uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: xvfb-run -a npm test
if: runner.os == 'Linux'
- run: npm test
if: runner.os != 'Linux'
5 changes: 4 additions & 1 deletion .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ jobs:
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: vscode-qt-for-python-${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}.vsix
asset_path:
vscode-qt-for-python-${{ steps.release.outputs.major }}.${{
steps.release.outputs.minor }}.${{ steps.release.outputs.patch
}}.vsix
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ jobs:
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: vscode-qt-for-python-${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}.vsix
asset_path:
vscode-qt-for-python-${{ steps.release.outputs.major }}.${{
steps.release.outputs.minor }}.${{ steps.release.outputs.patch
}}.vsix
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
npm test
4 changes: 4 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"*.ts": "eslint --cache --fix",
"*.{js,ts,scss,css,html,md,yml,json}": "prettier --write"
}
Loading

0 comments on commit 16aecb9

Please sign in to comment.