Skip to content

Commit

Permalink
chore: add github problem matcher for PR linting (#8161)
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan authored Jan 3, 2025
1 parent 466c6fa commit 323d1b1
Show file tree
Hide file tree
Showing 27 changed files with 63 additions and 43 deletions.
14 changes: 14 additions & 0 deletions .github/eslint-compact.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@
"code": 6
}
]
},
{
"owner": "turbo-eslint-compact",
"pattern": [
{
"regexp": "^(?:[^:]+: )?([^:]+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)\\.?$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5,
"code": 6
}
]
}
]
}
5 changes: 4 additions & 1 deletion .github/workflows/lintPr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ jobs:
- name: Install project dependencies
run: pnpm install

- name: Register Problem Matcher for ESLint that handles -f compact and shows warnings inline on PRs
run: echo "::add-matcher::.github/eslint-compact.json"

- name: Lint files
run: pnpm lint
run: pnpm turbo run lint --output-logs=full --continue -- -f compact
2 changes: 1 addition & 1 deletion dev/design-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"build": "../.bin/sanity build",
"clean": "rimraf .sanity dist",
"dev": "../.bin/sanity dev --port 4000",
"lint": "eslint .",
"lint": "eslint --cache .",
"start": "../.bin/sanity start --port 4000"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion dev/page-building-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "../.bin/sanity build",
"clean": "rimraf .sanity dist",
"dev": "../.bin/sanity dev",
"lint": "eslint .",
"lint": "eslint --cache .",
"start": "../.bin/sanity start"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion dev/starter-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "../.bin/sanity build",
"clean": "rimraf .sanity dist",
"dev": "../.bin/sanity dev --port 3337",
"lint": "eslint .",
"lint": "eslint --cache .",
"start": "../.bin/sanity start --port 3337"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion dev/strict-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "../.bin/sanity build",
"clean": "rimraf .sanity dist",
"dev": "../.bin/sanity dev",
"lint": "eslint .",
"lint": "eslint --cache .",
"start": "../.bin/sanity start"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion dev/studio-e2e-testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"build": "sanity build",
"dev": "sanity dev --port 3339",
"lint": "eslint .",
"lint": "eslint --cache .",
"preview": "sanity preview --port 3339",
"start": "sanity preview --port 3339"
},
Expand Down
2 changes: 1 addition & 1 deletion dev/test-create-integration-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"clean": "rimraf .sanity dist",
"deploy": "npx sanity deploy",
"dev": "../.bin/sanity dev",
"lint": "eslint .",
"lint": "eslint --cache .",
"start": "../.bin/sanity start"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion dev/test-next-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"build": "next build",
"dev": "next dev -p 3333",
"lint": "eslint .",
"lint": "eslint --cache .",
"start": "next start"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion dev/test-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "run-s workshop:build sanity:build",
"clean": "rimraf .sanity dist",
"dev": "run-p workshop:dev sanity:dev",
"lint": "eslint .",
"lint": "eslint --cache .",
"sanity:build": "../.bin/sanity build --source-maps",
"sanity:dev": "../.bin/sanity dev",
"start": "../.bin/sanity start",
Expand Down
2 changes: 1 addition & 1 deletion examples/blog-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"author": "Sanity.io <[email protected]>",
"main": "package.json",
"scripts": {
"lint": "eslint .",
"lint": "eslint --cache .",
"start": "sanity dev --port 3336"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/clean-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"author": "Sanity.io <[email protected]>",
"main": "package.json",
"scripts": {
"lint": "eslint .",
"lint": "eslint --cache .",
"start": "sanity dev --port 3338"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/ecommerce-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"main": "package.json",
"scripts": {
"clean": "rimraf lib dest",
"lint": "eslint .",
"lint": "eslint --cache .",
"start": "sanity dev --port 3337"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/movies-studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"main": "package.json",
"scripts": {
"clean": "rimraf lib dest",
"lint": "eslint .",
"lint": "eslint --cache .",
"start": "sanity dev --port 3334"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"prepublishOnly": "pnpm build",
"example:movies-studio": "cd examples/blog-studio && pnpm start",
"install:deps": "pnpm install",
"lint": "run-s check:lint",
"lint": "pnpm check:lint",
"lint:fix": "run-s chore:lint:fix",
"list:deps-updates": "npm-check-updates --workspaces --root -m",
"normalize-pkgfields": "node -r esbuild-register scripts/normalizePackageFields",
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/block-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"check:types": "tsc --project tsconfig.lib.json",
"clean": "rimraf lib",
"coverage": "NODE_ENV=test vitest --coverage",
"lint": "eslint .",
"lint": "eslint --cache .",
"prepublishOnly": "turbo run build",
"test": "vitest run",
"watch": "pkg-utils watch"
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"build": "pkg-utils build --strict --check --clean",
"check:types": "tsc --project tsconfig.lib.json",
"clean": "rimraf lib",
"lint": "eslint .",
"lint": "eslint --cache .",
"prepublishOnly": "turbo run build",
"test": "vitest",
"ts": "node -r esbuild-register",
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"build": "pkg-utils build --strict --check --clean",
"check:types": "tsc --project tsconfig.lib.json",
"clean": "rimraf lib coverage",
"lint": "eslint .",
"lint": "eslint --cache .",
"prepublishOnly": "turbo run build",
"test": "vitest",
"watch": "pkg-utils watch"
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/diff/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"build": "pkg-utils build --strict --check --clean",
"check:types": "tsc --project tsconfig.lib.json",
"clean": "rimraf lib coverage",
"lint": "eslint .",
"lint": "eslint --cache .",
"prepublishOnly": "turbo run build",
"watch": "pkg-utils watch"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"build": "pkg-utils build --strict --check --clean",
"check:types": "tsc --project tsconfig.lib.json",
"clean": "rimraf lib coverage",
"lint": "eslint .",
"lint": "eslint --cache .",
"prepublishOnly": "turbo run build",
"test": "vitest",
"watch": "pkg-utils watch"
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/mutator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"build": "pkg-utils build --strict --check --clean",
"check:types": "tsc --project tsconfig.lib.json",
"clean": "rimraf lib",
"lint": "eslint .",
"lint": "eslint --cache .",
"perf": "node ./perf/run.js",
"prepublishOnly": "turbo run build",
"test": "vitest run",
Expand Down
2 changes: 1 addition & 1 deletion packages/@sanity/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"build": "pkg-utils build --strict --check --clean",
"check:types": "tsc --project tsconfig.lib.json",
"clean": "rimraf _internal.js lib",
"lint": "eslint .",
"lint": "eslint --cache .",
"prepublishOnly": "turbo run build",
"test": "vitest run",
"test:watch": "vitest watch",
Expand Down
2 changes: 1 addition & 1 deletion packages/groq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"build": "pkg-utils build --strict --check --clean",
"check:types": "tsc --project tsconfig.lib.json",
"clean": "rimraf lib",
"lint": "eslint .",
"lint": "eslint --cache .",
"prepublishOnly": "turbo run build",
"pretest": "run-s build",
"test": "node --test",
Expand Down
2 changes: 1 addition & 1 deletion packages/sanity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"check:types": "tsc --project tsconfig.lib.json",
"clean": "rimraf _internal.js _singletons.js _createContext.js cli.js desk.js migrate.js presentation.js router.js structure.js lib",
"coverage": "vitest --coverage",
"lint": "eslint .",
"lint": "eslint --cache .",
"prepublishOnly": "turbo run build",
"test": "vitest run",
"test:ct": "rimraf playwright-ct/template/.cache && playwright test -c playwright-ct.config.ts",
Expand Down
39 changes: 21 additions & 18 deletions packages/sanity/src/core/form/studio/assetSource/file/AssetRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const STYLES_ASSETMENU_WRAPPER = {
marginBottom: '-0.5rem',
}

export const AssetRow = (props: RowProps) => {
export const AssetRow = (props: RowProps): React.JSX.Element => {
const versionedClient = useClient(DEFAULT_STUDIO_CLIENT_OPTIONS)
const toast = useToast()
const deleteRef$ = useRef<Subscription>()
Expand Down Expand Up @@ -195,36 +195,39 @@ export const AssetRow = (props: RowProps) => {
versionedClient.observable,
])

const handleDialogClose = () => {
const handleDialogClose = useCallback(() => {
setShowUsageDialog(false)
setShowDeleteDialog(false)
}
}, [])

const handleToggleUsageDialog = () => {
const handleToggleUsageDialog = useCallback(() => {
setShowUsageDialog(true)
}
}, [])

const handleToggleOpen = () => {
setIsOpen(!isOpen)
}
const handleToggleOpen = useCallback(() => {
setIsOpen((prev) => !prev)
}, [])

const handleMenuAction = (action: AssetMenuAction) => {
if (action.type === 'delete') {
handleConfirmDelete()
}
const handleMenuAction = useCallback(
(action: AssetMenuAction) => {
if (action.type === 'delete') {
handleConfirmDelete()
}

if (action.type === 'showUsage') {
handleToggleUsageDialog()
}
}
if (action.type === 'showUsage') {
handleToggleUsageDialog()
}
},
[handleConfirmDelete, handleToggleUsageDialog],
)

const usageDialog = useMemo(() => {
return (
showUsageDialog && (
<AssetUsageDialog assetType="file" asset={asset} onClose={handleDialogClose} />
)
)
}, [asset, showUsageDialog])
}, [asset, handleDialogClose, showUsageDialog])

const deleteDialog = useMemo(() => {
return (
Expand All @@ -238,7 +241,7 @@ export const AssetRow = (props: RowProps) => {
/>
)
)
}, [asset, handleDeleteAsset, isDeleting, showDeleteDialog])
}, [asset, handleDeleteAsset, handleDialogClose, isDeleting, showDeleteDialog])

if (isMobile) {
return (
Expand Down
2 changes: 1 addition & 1 deletion perf/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "sanity build",
"clean": "rimraf .sanity dist",
"dev": "sanity dev --port 3300",
"lint": "eslint .",
"lint": "eslint --cache .",
"preview": "pnpm build && pnpm start",
"start": "sanity start --port 3300"
},
Expand Down
2 changes: 1 addition & 1 deletion perf/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"author": "Sanity.io <[email protected]>",
"scripts": {
"build": "pnpm build:cli && (cd studio && pnpm build)",
"lint": "eslint .",
"lint": "eslint --cache .",
"perf:codegen": "ts-node --files -r dotenv/config codegen",
"perf:test": "ts-node --files cli",
"perf:test:ci": "ts-node --files cli",
Expand Down

0 comments on commit 323d1b1

Please sign in to comment.