Skip to content

Commit

Permalink
chore: configure eslint (#1896)
Browse files Browse the repository at this point in the history
  • Loading branch information
nandan-bhat authored Feb 11, 2025
2 parents 75445bd + f1312cb commit d26551b
Show file tree
Hide file tree
Showing 30 changed files with 5,293 additions and 3,087 deletions.
38 changes: 34 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
merge_group:
workflow_dispatch:
pull_request:
branches: [ main, v4 ]
branches: [main, v4]
push:
branches: [ main, v4 ]
branches: [main, v4]

permissions:
contents: read
Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile
Expand Down Expand Up @@ -75,7 +75,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
cache: "pnpm"

- name: Restore build artifacts
uses: actions/cache/restore@v4
Expand All @@ -87,3 +87,33 @@ jobs:
run: pnpm test:coverage

- uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # [email protected]

lint:
needs: build # Require build to complete before running tests

name: Lint Code
runs-on: ubuntu-latest

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

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: Setup Node.js with pnpm caching
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"

- name: Restore build artifacts
uses: actions/cache/restore@v4
with:
path: .
key: ${{ env.CACHE_KEY }}

- name: Run Lint
run: pnpm run lint
59 changes: 59 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import pluginJs from "@eslint/js";
import stylisticTs from "@stylistic/eslint-plugin-ts";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import pluginReact from "eslint-plugin-react";
import globals from "globals";
import tseslint from "typescript-eslint";

/** @type {import('eslint').Linter.Config[]} */
export default [
{ files: ["**/*.{js,mjs,cjs,ts,jsx,tsx}"] },
{ languageOptions: { globals: { ...globals.browser, ...globals.node } } },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
pluginReact.configs.flat.recommended,
eslintPluginPrettierRecommended,
{
plugins: {
"@stylistic/ts": stylisticTs
}
},
{
rules: {
"prettier/prettier": "error",
"no-console": [
1,
{
allow: ["error", "info", "warn"]
}
],
"comma-dangle": ["error", "never"],
"no-trailing-spaces": "error",
"react/display-name": 0,
"@stylistic/ts/semi": "error",
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/interface-name-prefix": 0,
"@typescript-eslint/prefer-interface": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/no-use-before-define": 0,
"@typescript-eslint/no-unused-vars": [
"error",
{
vars: "all",
args: "after-used",
caughtErrors: "none",
ignoreRestSiblings: false,
reportUsedIgnorePattern: false,
varsIgnorePattern: "^_"
}
]
}
},
{
settings: {
react: {
version: "detect"
}
}
}
];
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"test:coverage": "vitest run --coverage",
"test:e2e": "playwright test",
"prepack": "pnpm run build",
"install:examples": "pnpm install --filter ./examples/with-next-intl --shamefully-hoist && pnpm install --filter ./examples/with-shadcn --shamefully-hoist"
"install:examples": "pnpm install --filter ./examples/with-next-intl --shamefully-hoist && pnpm install --filter ./examples/with-shadcn --shamefully-hoist",
"lint": "tsc --noEmit && eslint --fix ./src"
},
"repository": {
"type": "git",
Expand All @@ -30,15 +31,23 @@
},
"homepage": "https://github.com/auth0/nextjs-auth0#readme",
"devDependencies": {
"@eslint/js": "^9.20.0",
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"@playwright/test": "^1.48.2",
"@stylistic/eslint-plugin-ts": "^3.1.0",
"@types/node": "^22.8.6",
"@types/react": "*",
"@types/react-dom": "*",
"@vitest/coverage-v8": "2.1.4",
"eslint": "^9.20.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-prettier": "^5.2.3",
"eslint-plugin-react": "^7.37.4",
"globals": "^15.14.0",
"next": "15.0.2",
"prettier": "^3.3.3",
"typescript": "^5.6.3",
"typescript-eslint": "^8.23.0",
"vite": "^5.4.11",
"vitest": "^2.1.4"
},
Expand Down
Loading

0 comments on commit d26551b

Please sign in to comment.