Skip to content

Commit

Permalink
Lint TypeScript
Browse files Browse the repository at this point in the history
Uses ESLint (https://eslint.org/) to lint the TypeScript code.
  • Loading branch information
thewilkybarkid committed Dec 4, 2023
1 parent fd9355b commit 8144a03
Show file tree
Hide file tree
Showing 6 changed files with 2,963 additions and 124 deletions.
Empty file added .eslintignore
Empty file.
36 changes: 36 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "no-comments"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/strict-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"rules": {
"@typescript-eslint/array-type": ["error", { "default": "generic" }],
"@typescript-eslint/consistent-type-imports": ["error", { "fixStyle": "inline-type-imports" }],
"@typescript-eslint/no-confusing-void-expression": "off",
"@typescript-eslint/no-import-type-side-effects": "error",
"@typescript-eslint/prefer-nullish-coalescing": ["error", { "ignoreConditionalTests": true }],
"@typescript-eslint/strict-boolean-expressions": "error",
"import/no-cycle": "error",
"import/no-duplicates": ["error", { "prefer-inline": true }],
"import/no-extraneous-dependencies": ["error"],
"import/no-internal-modules": ["error"],
"import/no-named-as-default": "off",
"import/no-named-as-default-member": "off",
"no-comments/disallowComments": ["error"],
"quotes": ["error", "single", { "avoidEscape": true }]
},
"settings": {
"import/resolver": {
"typescript": true
}
}
}
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,27 @@ jobs:
- name: 'Run formatter'
run: npx prettier --ignore-unknown --check '**'

lint:
name: 'Lint'
runs-on: ubuntu-22.04
timeout-minutes: 30

steps:
- name: 'Checkout code'
uses: actions/checkout@v4.1.1

- name: 'Set up Node.js'
uses: actions/setup-node@v4.0.0
with:
node-version-file: package.json
cache: ${{ !env.ACT && 'npm' || '' }}

- name: 'Install dependencies'
run: npm ci

- name: 'Run the linter'
run: npx eslint . --max-warnings 0

typecheck:
name: 'Typecheck'
runs-on: ubuntu-22.04
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
.PHONY: check fix format start typecheck
.PHONY: check fix format lint start typecheck

node_modules: package.json package-lock.json
npm install
touch node_modules

check: format typecheck
check: format lint typecheck

fix: node_modules
npx eslint . --fix --max-warnings 0
npx prettier --ignore-unknown --write '**'

format: node_modules
npx prettier --ignore-unknown --check '**'

lint: node_modules
npx eslint . --max-warnings 0

typecheck: node_modules
npx tsc --noEmit

Expand Down
Loading

0 comments on commit 8144a03

Please sign in to comment.