From 64c45b04d422ab29e34058012f0b3daf351dc2cf Mon Sep 17 00:00:00 2001 From: Victor Fernandez de Alba Date: Thu, 23 Jan 2025 12:15:12 +0100 Subject: [PATCH 1/2] Fix lint-staged throwing warnings when a file is checked-in and ignored --- .lintstagedrc | 18 ------------------ lint-staged.config.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 18 deletions(-) delete mode 100644 .lintstagedrc create mode 100644 lint-staged.config.js diff --git a/.lintstagedrc b/.lintstagedrc deleted file mode 100644 index e2d1cf31903..00000000000 --- a/.lintstagedrc +++ /dev/null @@ -1,18 +0,0 @@ -{ - "packages/!(volto)/**/*.{js,jsx,ts,tsx}": [ - "pnpm eslint --max-warnings=0 --fix", - "pnpm prettier --single-quote --write" - ], - "packages/volto/**/*.{js,jsx,ts,tsx}": [ - "pnpm --filter @plone/volto lint:husky", - "pnpm --filter @plone/volto prettier:husky" - ], - "packages/volto/src/**/*.{jsx, tsx}": ["pnpm --filter @plone/volto i18n"], - "packages/!(volto)/**/*.{css,less,scss}": ["pnpm stylelint --fix"], - "packages/volto/**/*.{css,less,scss}": [ - "pnpm --filter @plone/volto stylelint --fix" - ], - "packages/volto/**/*.overrides": [ - "pnpm --filter @plone/volto stylelint --fix" - ] -} diff --git a/lint-staged.config.js b/lint-staged.config.js new file mode 100644 index 00000000000..1b1d2ec7aef --- /dev/null +++ b/lint-staged.config.js @@ -0,0 +1,31 @@ +const { ESLint } = require('eslint'); + +const removeIgnoredFiles = async (files) => { + const eslint = new ESLint(); + const ignoredFiles = await Promise.all( + files.map((file) => eslint.isPathIgnored(file)), + ); + const filteredFiles = files.filter((_, i) => !ignoredFiles[i]); + return filteredFiles.join(' '); +}; +module.exports = { + 'packages/!(volto)/**/*.{js,jsx,ts,tsx}': async (files) => { + const filesToLint = await removeIgnoredFiles(files); + return [ + `eslint --max-warnings=0 ${filesToLint}`, + 'pnpm prettier --single-quote --write', + ]; + }, + 'packages/volto/**/*.{js,jsx,ts,tsx}': [ + 'pnpm --filter @plone/volto lint:husky', + 'pnpm --filter @plone/volto prettier:husky', + ], + 'packages/volto/src/**/*.{jsx, tsx}': ['pnpm --filter @plone/volto i18n'], + 'packages/!(volto)/**/*.{css,less,scss}': ['pnpm stylelint --fix'], + 'packages/volto/**/*.{css,less,scss}': [ + 'pnpm --filter @plone/volto stylelint --fix', + ], + 'packages/volto/**/*.overrides': [ + 'pnpm --filter @plone/volto stylelint --fix', + ], +}; From 1bf1291e9a722e55cf6852570b4fdf6443ed0dd0 Mon Sep 17 00:00:00 2001 From: Victor Fernandez de Alba Date: Thu, 23 Jan 2025 12:16:23 +0100 Subject: [PATCH 2/2] Changelog --- packages/volto/news/6614.internal | 1 + 1 file changed, 1 insertion(+) create mode 100644 packages/volto/news/6614.internal diff --git a/packages/volto/news/6614.internal b/packages/volto/news/6614.internal new file mode 100644 index 00000000000..b4614b7da0b --- /dev/null +++ b/packages/volto/news/6614.internal @@ -0,0 +1 @@ +Fix lint-staged throwing warnings when a file is checked-in and ignored. @sneridagh