Skip to content

Commit

Permalink
Reduce the chance of mistakes by linting the code
Browse files Browse the repository at this point in the history
Refs #13
  • Loading branch information
thewilkybarkid committed Jun 26, 2024
1 parent b8a1040 commit 7d1d4eb
Show file tree
Hide file tree
Showing 5 changed files with 3,031 additions and 43 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.dev/
/dist/
/node_modules/
/src/.observablehq/
53 changes: 53 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/strict-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:markdown/recommended-legacy",
"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/restrict-template-expressions": ["error", { "allowNumber": 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", { "allow": ["*/lib/*"] }],
"import/no-named-as-default": "off",
"import/no-named-as-default-member": "off",
"quotes": ["error", "single", { "avoidEscape": true }]
},
"overrides": [
{
"extends": ["plugin:@typescript-eslint/disable-type-checked"],
"files": ["**/*.js"]
},
{
"files": ["**/*.md"],
"processor": "markdown/markdown"
},
{
"files": ["./**/*.md/*.js"],
"rules": {
"@typescript-eslint/no-unused-vars": "off"
}
}
],
"settings": {
"import/resolver": {
"typescript": true
}
}
}
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,28 @@ jobs:
- name: 'Run formatter'
run: npx prettier --ignore-unknown --check '**'

lint:
name: 'Lint'
runs-on: ubuntu-22.04
timeout-minutes: 30
if: github.event_name != 'schedule'

steps:
- name: 'Checkout code'
uses: actions/[email protected]

- name: 'Set up Node.js'
uses: actions/[email protected]
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 Expand Up @@ -103,6 +125,7 @@ jobs:
needs:
- build-image
- format
- lint
- typecheck

steps:
Expand Down
Loading

0 comments on commit 7d1d4eb

Please sign in to comment.