From 5e5acc442bf479309ada4789a5c84e5faf66fcb4 Mon Sep 17 00:00:00 2001 From: Gonzalo Riestra Date: Thu, 30 Jul 2026 11:58:22 +0200 Subject: [PATCH] Decouple Prettier from ESLint --- .github/workflows/tests-main.yml | 3 +++ .github/workflows/tests-pr.yml | 2 ++ .prettierignore | 1 + dev.yml | 2 +- docs/cli/get-started.md | 6 ++++-- package.json | 11 +++++++---- packages/app/project.json | 14 +++++++------- .../app-management/generated/create-asset-url.ts | 5 +---- packages/cli-kit/project.json | 4 ++-- .../api/graphql/admin/generated/theme_delete.ts | 5 +---- .../graphql/admin/generated/theme_files_delete.ts | 6 +----- .../generated/staged-uploads-create.ts | 6 +----- packages/eslint-plugin-cli/config.js | 8 +++++++- packages/eslint-plugin-cli/package.json | 4 ---- packages/organizations/project.json | 2 +- packages/store/project.json | 4 ++-- .../generated/delete_app_development_store.ts | 5 +---- pnpm-lock.yaml | 10 +++------- 18 files changed, 45 insertions(+), 53 deletions(-) diff --git a/.github/workflows/tests-main.yml b/.github/workflows/tests-main.yml index abfd03bea07..cb3799a9516 100644 --- a/.github/workflows/tests-main.yml +++ b/.github/workflows/tests-main.yml @@ -45,6 +45,9 @@ jobs: - name: Build run: pnpm nx run-many --all --skip-nx-cache --target=build --output-style=stream if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '26.1.0' }} + - name: Check formatting + run: pnpm prettier + if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '26.1.0' }} - name: Lint run: pnpm nx run-many --all --skip-nx-cache --target=lint --output-style=stream if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '26.1.0' }} diff --git a/.github/workflows/tests-pr.yml b/.github/workflows/tests-pr.yml index d088e5ea821..302d0906da1 100644 --- a/.github/workflows/tests-pr.yml +++ b/.github/workflows/tests-pr.yml @@ -51,6 +51,8 @@ jobs: uses: ./.github/actions/setup-cli-deps with: node-version: ${{ env.DEFAULT_NODE_VERSION }} + - name: Check formatting + run: pnpm prettier - name: Lint run: pnpm nx run-many --all --skip-nx-cache --target=lint --output-style=stream diff --git a/.prettierignore b/.prettierignore index 5a9d7463312..f367bc49f9a 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,5 +2,6 @@ node_modules *.md bin dist +**/vendor/** *.d.ts ./fixtures/ diff --git a/dev.yml b/dev.yml index 6c6bffb6bfc..5b6179d0113 100644 --- a/dev.yml +++ b/dev.yml @@ -69,4 +69,4 @@ commands: check: type-check: pnpm nx affected --target=type-check - lint: pnpm nx affected --target=lint + lint: pnpm lint:affected diff --git a/docs/cli/get-started.md b/docs/cli/get-started.md index 259eabda141..06e49bdc8eb 100644 --- a/docs/cli/get-started.md +++ b/docs/cli/get-started.md @@ -68,8 +68,10 @@ You can also pass these optional flags: Besides the scripts for building and running the CLIs, there are others that might come handy when adding code to the project: - `pnpm test`: Runs the tests of all the packages. -- `pnpm lint`: Runs ESLint and Prettier checks for all the packages. -- `pnpm lint:fix`: Runs ESLint and Prettier checks for all the packages and fixes the fixable issues. +- `pnpm prettier`: Checks formatting for all linted source files. +- `pnpm prettier:fix`: Formats all linted source files. +- `pnpm lint`: Runs Prettier and ESLint checks for all the packages. +- `pnpm lint:fix`: Runs Prettier and ESLint for all the packages and fixes the fixable issues. - `pnpm type-check`: Type-checks all the packagesusing the Typescript `tsc` tool. - `pnpm clean`: Removes the `dist` directory from all the packages. diff --git a/package.json b/package.json index a4f3c4f6a41..f97831d5580 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,12 @@ "graphql-codegen:get-graphql-schemas": "bin/get-graphql-schemas.js", "graphql-codegen": "nx run-many --target=graphql-codegen --all", "knip": "knip", - "lint:affected": "nx affected --target=lint", - "lint:fix:affected": "nx affected --target=lint:fix", - "lint:fix": "nx run-many --target=lint:fix --all --skip-nx-cache", - "lint": "nx run-many --target=lint --all --skip-nx-cache", + "lint:affected": "pnpm prettier && nx affected --target=lint", + "lint:fix:affected": "pnpm prettier:fix && nx affected --target=lint:fix", + "lint:fix": "pnpm prettier:fix && nx run-many --target=lint:fix --all --skip-nx-cache", + "lint": "pnpm prettier && nx run-many --target=lint --all --skip-nx-cache", + "prettier": "prettier --check \"packages/{app,cli-kit,cli,create-app,organizations,plugin-cloudflare,plugin-did-you-mean,store,theme,ui-extensions-server-kit,ui-extensions-test-utils}/src/**/*.{js,ts,tsx}\" \"packages/cli/bin/*.js\" \"packages/e2e/{setup,helpers,tests}/**/*.ts\" \"packages/e2e/*.ts\"", + "prettier:fix": "prettier --write \"packages/{app,cli-kit,cli,create-app,organizations,plugin-cloudflare,plugin-did-you-mean,store,theme,ui-extensions-server-kit,ui-extensions-test-utils}/src/**/*.{js,ts,tsx}\" \"packages/cli/bin/*.js\" \"packages/e2e/{setup,helpers,tests}/**/*.ts\" \"packages/e2e/*.ts\"", "create-homebrew-pr": "bin/create-homebrew-pr.js", "refresh-code-documentation": "nx run-many --target=refresh-code-documentation --all --skip-nx-cache", "refresh-manifests": "nx run-many --target=refresh-manifests --all --skip-nx-cache && bin/prettify-manifests.js && pnpm refresh-readme", @@ -77,6 +79,7 @@ "octokit-plugin-create-pull-request": "^3.12.2", "pathe": "1.1.2", "pin-github-action": "^3.5.1", + "prettier": "3.8.4", "rimraf": "^6.1.3", "ts-node": "^10.9.1", "typescript": "5.9.3", diff --git a/packages/app/project.json b/packages/app/project.json index b9bda81b6d7..c09152c61e3 100644 --- a/packages/app/project.json +++ b/packages/app/project.json @@ -61,13 +61,13 @@ ], "options": { "commands": [ - "pnpm eslint 'src/cli/api/graphql/business-platform-destinations/generated/**/*.{ts,tsx}' --fix", - "pnpm eslint 'src/cli/api/graphql/business-platform-organizations/generated/**/*.{ts,tsx}' --fix", - "pnpm eslint 'src/cli/api/graphql/app-dev/generated/**/*.{ts,tsx}' --fix", - "pnpm eslint 'src/cli/api/graphql/app-management/generated/**/*.{ts,tsx}' --fix", - "pnpm eslint 'src/cli/api/graphql/webhooks/generated/**/*.{ts,tsx}' --fix", - "pnpm eslint 'src/cli/api/graphql/functions/generated/**/*.{ts,tsx}' --fix", - "pnpm eslint 'src/cli/api/graphql/admin/generated/**/*.{ts,tsx}' --fix" + "pnpm eslint 'src/cli/api/graphql/business-platform-destinations/generated/**/*.{ts,tsx}' --fix && pnpm exec prettier --write --ignore-path ../../.prettierignore 'src/cli/api/graphql/business-platform-destinations/generated/**/*.{ts,tsx}'", + "pnpm eslint 'src/cli/api/graphql/business-platform-organizations/generated/**/*.{ts,tsx}' --fix && pnpm exec prettier --write --ignore-path ../../.prettierignore 'src/cli/api/graphql/business-platform-organizations/generated/**/*.{ts,tsx}'", + "pnpm eslint 'src/cli/api/graphql/app-dev/generated/**/*.{ts,tsx}' --fix && pnpm exec prettier --write --ignore-path ../../.prettierignore 'src/cli/api/graphql/app-dev/generated/**/*.{ts,tsx}'", + "pnpm eslint 'src/cli/api/graphql/app-management/generated/**/*.{ts,tsx}' --fix && pnpm exec prettier --write --ignore-path ../../.prettierignore 'src/cli/api/graphql/app-management/generated/**/*.{ts,tsx}'", + "pnpm eslint 'src/cli/api/graphql/webhooks/generated/**/*.{ts,tsx}' --fix && pnpm exec prettier --write --ignore-path ../../.prettierignore 'src/cli/api/graphql/webhooks/generated/**/*.{ts,tsx}'", + "pnpm eslint 'src/cli/api/graphql/functions/generated/**/*.{ts,tsx}' --fix && pnpm exec prettier --write --ignore-path ../../.prettierignore 'src/cli/api/graphql/functions/generated/**/*.{ts,tsx}'", + "pnpm eslint 'src/cli/api/graphql/admin/generated/**/*.{ts,tsx}' --fix && pnpm exec prettier --write --ignore-path ../../.prettierignore 'src/cli/api/graphql/admin/generated/**/*.{ts,tsx}'" ], "cwd": "packages/app" } diff --git a/packages/app/src/cli/api/graphql/app-management/generated/create-asset-url.ts b/packages/app/src/cli/api/graphql/app-management/generated/create-asset-url.ts index 2623c03f68f..0678884dd2b 100644 --- a/packages/app/src/cli/api/graphql/app-management/generated/create-asset-url.ts +++ b/packages/app/src/cli/api/graphql/app-management/generated/create-asset-url.ts @@ -9,10 +9,7 @@ export type CreateAssetUrlMutationVariables = Types.Exact<{ }> export type CreateAssetUrlMutation = { - appRequestSourceUploadUrl: { - sourceUploadUrl?: string | null - userErrors: {field?: string[] | null; message: string}[] - } + appRequestSourceUploadUrl: {sourceUploadUrl?: string | null; userErrors: {field?: string[] | null; message: string}[]} } export const CreateAssetUrl = { diff --git a/packages/cli-kit/project.json b/packages/cli-kit/project.json index 4e3209da8db..d64b77f27b7 100644 --- a/packages/cli-kit/project.json +++ b/packages/cli-kit/project.json @@ -112,8 +112,8 @@ ], "options": { "commands": [ - "pnpm eslint 'src/cli/api/graphql/admin/generated/**/*.{ts,tsx}' --fix", - "pnpm eslint 'src/cli/api/graphql/bulk-operations/generated/**/*.{ts,tsx}' --fix" + "pnpm eslint 'src/cli/api/graphql/admin/generated/**/*.{ts,tsx}' --fix && pnpm exec prettier --write --ignore-path ../../.prettierignore 'src/cli/api/graphql/admin/generated/**/*.{ts,tsx}'", + "pnpm eslint 'src/cli/api/graphql/bulk-operations/generated/**/*.{ts,tsx}' --fix && pnpm exec prettier --write --ignore-path ../../.prettierignore 'src/cli/api/graphql/bulk-operations/generated/**/*.{ts,tsx}'" ], "cwd": "packages/cli-kit" } diff --git a/packages/cli-kit/src/cli/api/graphql/admin/generated/theme_delete.ts b/packages/cli-kit/src/cli/api/graphql/admin/generated/theme_delete.ts index 562f2fea00c..b6118f3c5a9 100644 --- a/packages/cli-kit/src/cli/api/graphql/admin/generated/theme_delete.ts +++ b/packages/cli-kit/src/cli/api/graphql/admin/generated/theme_delete.ts @@ -8,10 +8,7 @@ export type ThemeDeleteMutationVariables = Types.Exact<{ }> export type ThemeDeleteMutation = { - themeDelete?: { - deletedThemeId?: string | null - userErrors: {field?: string[] | null; message: string}[] - } | null + themeDelete?: {deletedThemeId?: string | null; userErrors: {field?: string[] | null; message: string}[]} | null } export const ThemeDelete = { diff --git a/packages/cli-kit/src/cli/api/graphql/admin/generated/theme_files_delete.ts b/packages/cli-kit/src/cli/api/graphql/admin/generated/theme_files_delete.ts index f451cddab4a..aa130a5d60c 100644 --- a/packages/cli-kit/src/cli/api/graphql/admin/generated/theme_files_delete.ts +++ b/packages/cli-kit/src/cli/api/graphql/admin/generated/theme_files_delete.ts @@ -11,11 +11,7 @@ export type ThemeFilesDeleteMutationVariables = Types.Exact<{ export type ThemeFilesDeleteMutation = { themeFilesDelete?: { deletedThemeFiles?: {filename: string}[] | null - userErrors: { - filename?: string | null - code?: Types.OnlineStoreThemeFilesUserErrorsCode | null - message: string - }[] + userErrors: {filename?: string | null; code?: Types.OnlineStoreThemeFilesUserErrorsCode | null; message: string}[] } | null } diff --git a/packages/cli-kit/src/cli/api/graphql/bulk-operations/generated/staged-uploads-create.ts b/packages/cli-kit/src/cli/api/graphql/bulk-operations/generated/staged-uploads-create.ts index c6d15becc46..86ee3a43563 100644 --- a/packages/cli-kit/src/cli/api/graphql/bulk-operations/generated/staged-uploads-create.ts +++ b/packages/cli-kit/src/cli/api/graphql/bulk-operations/generated/staged-uploads-create.ts @@ -10,11 +10,7 @@ export type StagedUploadsCreateMutationVariables = Types.Exact<{ export type StagedUploadsCreateMutation = { stagedUploadsCreate?: { stagedTargets?: - | { - url?: string | null - resourceUrl?: string | null - parameters: {name: string; value: string}[] - }[] + | {url?: string | null; resourceUrl?: string | null; parameters: {name: string; value: string}[]}[] | null userErrors: {field?: string[] | null; message: string}[] } | null diff --git a/packages/eslint-plugin-cli/config.js b/packages/eslint-plugin-cli/config.js index b01187d5f85..3786c552fe4 100644 --- a/packages/eslint-plugin-cli/config.js +++ b/packages/eslint-plugin-cli/config.js @@ -6,6 +6,11 @@ const noCatchAllPlugin = require('eslint-plugin-no-catch-all') const eslintConfigPrettier = require('eslint-config-prettier') const globals = require('globals') +const [shopifyPrettierCompatibilityConfig, shopifyPrettierPluginConfig] = shopifyPlugin.configs.prettier +const shopifyPrettierCompatibilityRules = Object.fromEntries( + Object.entries(shopifyPrettierPluginConfig.rules).filter(([ruleName]) => ruleName !== 'prettier/prettier'), +) + // Load rules directly to avoid circular dependency const rules = { 'command-flags-with-env': require('./rules/command-flags-with-env'), @@ -254,7 +259,8 @@ const config = [ // Spread the Shopify configs (these already include typescript-eslint plugin) ...shopifyPlugin.configs.typescript, ...shopifyPlugin.configs.node, - ...shopifyPlugin.configs.prettier, + shopifyPrettierCompatibilityConfig, + {rules: shopifyPrettierCompatibilityRules}, // Global ignores { diff --git a/packages/eslint-plugin-cli/package.json b/packages/eslint-plugin-cli/package.json index 82814d4d655..5bc6946d29e 100644 --- a/packages/eslint-plugin-cli/package.json +++ b/packages/eslint-plugin-cli/package.json @@ -21,7 +21,6 @@ "@typescript-eslint/parser": "8.56.1", "eslint-config-prettier": "10.1.8", "eslint-plugin-no-catch-all": "1.1.0", - "eslint-plugin-prettier": "5.5.6", "eslint-plugin-react": "7.37.5", "eslint-plugin-react-hooks": "5.2.0", "eslint-plugin-tsdoc": "0.5.2", @@ -30,9 +29,6 @@ "globals": "16.5.0", "execa": "7.2.0" }, - "devDependencies": { - "prettier": "3.8.4" - }, "peerDependencies": { "eslint": "^9.0.0" }, diff --git a/packages/organizations/project.json b/packages/organizations/project.json index c054bf2c5d1..9fa855818d0 100644 --- a/packages/organizations/project.json +++ b/packages/organizations/project.json @@ -51,7 +51,7 @@ "dependsOn": ["graphql-codegen:postfix"], "outputs": ["{projectRoot}/src/cli/api/graphql/business-platform-destinations/generated/**/*.ts"], "options": { - "commands": ["pnpm eslint 'src/cli/api/graphql/business-platform-destinations/generated/**/*.{ts,tsx}' --fix"], + "commands": ["pnpm eslint 'src/cli/api/graphql/business-platform-destinations/generated/**/*.{ts,tsx}' --fix && pnpm exec prettier --write --ignore-path ../../.prettierignore 'src/cli/api/graphql/business-platform-destinations/generated/**/*.{ts,tsx}'"], "cwd": "packages/organizations" } }, diff --git a/packages/store/project.json b/packages/store/project.json index 8482beaab9e..613be5f3d04 100644 --- a/packages/store/project.json +++ b/packages/store/project.json @@ -56,8 +56,8 @@ ], "options": { "commands": [ - "pnpm eslint 'src/cli/api/graphql/business-platform-destinations/generated/**/*.{ts,tsx}' --fix", - "pnpm eslint 'src/cli/api/graphql/business-platform-organizations/generated/**/*.{ts,tsx}' --fix" + "pnpm eslint 'src/cli/api/graphql/business-platform-destinations/generated/**/*.{ts,tsx}' --fix && pnpm exec prettier --write --ignore-path ../../.prettierignore 'src/cli/api/graphql/business-platform-destinations/generated/**/*.{ts,tsx}'", + "pnpm eslint 'src/cli/api/graphql/business-platform-organizations/generated/**/*.{ts,tsx}' --fix && pnpm exec prettier --write --ignore-path ../../.prettierignore 'src/cli/api/graphql/business-platform-organizations/generated/**/*.{ts,tsx}'" ], "cwd": "packages/store" } diff --git a/packages/store/src/cli/api/graphql/business-platform-organizations/generated/delete_app_development_store.ts b/packages/store/src/cli/api/graphql/business-platform-organizations/generated/delete_app_development_store.ts index f1d0c553aa1..632c004758f 100644 --- a/packages/store/src/cli/api/graphql/business-platform-organizations/generated/delete_app_development_store.ts +++ b/packages/store/src/cli/api/graphql/business-platform-organizations/generated/delete_app_development_store.ts @@ -8,10 +8,7 @@ export type DeleteAppDevelopmentStoreMutationVariables = Types.Exact<{ }> export type DeleteAppDevelopmentStoreMutation = { - deleteAppDevelopmentStore: { - success: boolean - userErrors: {code?: string | null; field: string[]; message: string}[] - } + deleteAppDevelopmentStore: {success: boolean; userErrors: {code?: string | null; field: string[]; message: string}[]} } export const DeleteAppDevelopmentStore = { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 90357c9c908..bfcb98806f2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -146,6 +146,9 @@ importers: pin-github-action: specifier: ^3.5.1 version: 3.5.1 + prettier: + specifier: 3.8.4 + version: 3.8.4 rimraf: specifier: ^6.1.3 version: 6.1.3 @@ -597,9 +600,6 @@ importers: eslint-plugin-no-catch-all: specifier: 1.1.0 version: 1.1.0(eslint@9.39.5(jiti@2.6.1)) - eslint-plugin-prettier: - specifier: 5.5.6 - version: 5.5.6(eslint-config-prettier@10.1.8(eslint@9.39.5(jiti@2.6.1)))(eslint@9.39.5(jiti@2.6.1))(prettier@3.8.4) eslint-plugin-react: specifier: 7.37.5 version: 7.37.5(eslint@9.39.5(jiti@2.6.1)) @@ -618,10 +618,6 @@ importers: globals: specifier: 16.5.0 version: 16.5.0 - devDependencies: - prettier: - specifier: 3.8.4 - version: 3.8.4 packages/organizations: dependencies: