Skip to content

Commit c895629

Browse files
authored
chore(repo): Extend linting (clerk#1906)
* chore(repo): Extend linting * fix(repo): Add backend dep to integation tests * chore(repo): Run Prettier * chore(repo): Update rules to be more in-line with current expectations * chore(repo): Run Prettier * chore(repo): Update precommit call to eslint fix * chore(repo): Test without local dependencies * chore(repo): Update ESLint dependencies * chore(repo): Remove integration from eslint * fix(*): Rebase formatting issues * chore(clerk-js): Temp disable typeof issue * chore(repo): ESLint auto-fix (clerk#1978) * refactor(repo): Speed up linting staged files * chore(repo): Temp disable @typescript-eslint/no-duplicate-type-constituents * chore(repo): Include mjs in precommit hook * chore(repo): Remove integration from npm workspaces
1 parent f5d55bb commit c895629

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+3408
-2921
lines changed

.changeset/metal-olives-press.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-config-custom': minor
3+
---
4+
5+
Extends ESLint capabilities for individual packages

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
**/coverage/**
22
**/node_modules/**
33
packages/*/dist/**
4+
packages/eslint-config-custom/**
45
**/dist/*
56
**/build/*
67
playground

.eslintrc.js

-4
This file was deleted.

.husky/pre-commit

+38
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,42 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4+
##############################
5+
# Determine Staged Packages
6+
##############################
7+
8+
staged_files=$(git diff --name-only --cached --diff-filter=ACM)
9+
10+
# Initialize an empty string to hold the unique folder paths
11+
unique_folders=""
12+
13+
# Loop through each staged file
14+
for file in $staged_files; do
15+
# Extract the first two folders from the file path
16+
folder=$(echo $file | awk -F'/' '{print $1 "/" $2}')
17+
18+
# Filter files which end with .mjs, .js, .jsx, .ts, or .tsx [NOTE: Should match ./.lintstagedrc.json]
19+
if [[ $file =~ \.(mjs|js|jsx|ts|tsx)$ ]]; then
20+
# Check if this folder is already in the list of unique folders
21+
if [[ $folder == packages/* ]] && [[ ! " $unique_folders " =~ "$folder" ]]; then
22+
# Append the folder to the list of unique folders
23+
unique_folders="$unique_folders --filter={./$folder}^..."
24+
fi
25+
fi
26+
done
27+
28+
##############################
29+
# Build Staged Packages
30+
##############################
31+
32+
if [ -n "$unique_folders" ]; then
33+
npx turbo run build --output-logs=errors-only $unique_folders
34+
else
35+
echo "SKIPPING: No packages to build"
36+
fi
37+
38+
##############################
39+
# Run Lint Staged
40+
##############################
41+
442
npx lint-staged

.lintstagedrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"*.{mjs,js,jsx,ts,tsx}": ["npx prettier --write", "npx eslint --fix"],
2+
"*.{mjs,js,jsx,ts,tsx}": ["npx eslint --fix", "npx prettier --write"],
33
"*.{json,md,mdx}": ["npx prettier --write"]
44
}

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
"editor.codeActionsOnSave": {
66
"source.fixAll.eslint": true,
77
"source.organizeImports": true
8-
}
8+
},
9+
"eslint.workingDirectories": [{ "mode": "auto" }],
910
}

integration/.eslintrc.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// TODO: All rules below should be set to their defaults
2+
// when we're able to make the appropriate changes.
3+
const disabledRules = {
4+
'playwright/expect-expect': 'off',
5+
'playwright/no-skipped-test': 'off',
6+
'playwright/no-page-pause': 'warn',
7+
};
8+
9+
module.exports = {
10+
root: true,
11+
ignorePatterns: ['!.*.js', '*.snap', 'templates/**'],
12+
extends: ['custom/node', 'custom/typescript', 'custom/playwright'],
13+
rules: {
14+
...disabledRules,
15+
},
16+
overrides: [
17+
{
18+
files: ['./models/deployment.ts', './testUtils/emailService.ts'],
19+
rules: {
20+
'@typescript-eslint/no-unnecessary-type-assertion': 'warn', // TODO: Remove when we able to update tests
21+
},
22+
},
23+
{
24+
files: ['./testUtils/testAgainstRunningApps.ts', './presets/longRunningApps.ts'],
25+
rules: {
26+
'@typescript-eslint/no-redundant-type-constituents': 'warn', // TODO: Remove when we able to update tests
27+
},
28+
},
29+
],
30+
};

integration/templates/next-app-router/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"dev": "next dev",
76
"build": "next build",
8-
"start": "next start",
9-
"lint": "next lint"
7+
"dev": "next dev",
8+
"lint": "next lint",
9+
"start": "next start"
1010
},
1111
"dependencies": {
1212
"@types/node": "20.3.2",

integration/templates/react-cra/package.json

+23-23
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,11 @@
22
"name": "react-cra",
33
"version": "0.1.0",
44
"private": true,
5-
"dependencies": {
6-
"@testing-library/jest-dom": "^5.16.5",
7-
"@testing-library/react": "^13.4.0",
8-
"@testing-library/user-event": "^13.5.0",
9-
"@types/jest": "^27.5.2",
10-
"@types/node": "^16.18.37",
11-
"@types/react": "^18.2.14",
12-
"@types/react-dom": "^18.2.6",
13-
"react": "^18.2.0",
14-
"react-dom": "^18.2.0",
15-
"react-scripts": "5.0.1",
16-
"typescript": "^4.9.5",
17-
"web-vitals": "^2.1.4"
18-
},
195
"scripts": {
20-
"start": "BROWSER=none react-scripts start",
216
"build": "react-scripts build",
22-
"test": "react-scripts test",
23-
"eject": "react-scripts eject"
24-
},
25-
"eslintConfig": {
26-
"extends": [
27-
"react-app",
28-
"react-app/jest"
29-
]
7+
"eject": "react-scripts eject",
8+
"start": "BROWSER=none react-scripts start",
9+
"test": "react-scripts test"
3010
},
3111
"browserslist": {
3212
"production": [
@@ -39,5 +19,25 @@
3919
"last 1 firefox version",
4020
"last 1 safari version"
4121
]
22+
},
23+
"eslintConfig": {
24+
"extends": [
25+
"react-app",
26+
"react-app/jest"
27+
]
28+
},
29+
"dependencies": {
30+
"@testing-library/jest-dom": "^5.16.5",
31+
"@testing-library/react": "^13.4.0",
32+
"@testing-library/user-event": "^13.5.0",
33+
"@types/jest": "^27.5.2",
34+
"@types/node": "^16.18.37",
35+
"@types/react": "^18.2.14",
36+
"@types/react-dom": "^18.2.6",
37+
"react": "^18.2.0",
38+
"react-dom": "^18.2.0",
39+
"react-scripts": "5.0.1",
40+
"typescript": "^4.9.5",
41+
"web-vitals": "^2.1.4"
4242
}
4343
}

integration/templates/react-vite/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "react-vite",
3-
"private": true,
43
"version": "0.0.0",
4+
"private": true,
55
"type": "module",
66
"scripts": {
7-
"dev": "vite --port $PORT --no-open",
87
"build": "tsc && vite build",
8+
"dev": "vite --port $PORT --no-open",
99
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
1010
"preview": "vite preview --port $PORT --no-open"
1111
},

integration/tsconfig.lint.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": ["./*.ts", "deployments", "presets", "scripts", "tests", "testUtils"],
4+
"exclude": ["templates"]
5+
}

0 commit comments

Comments
 (0)