Merge pull request #2897 from yougotwill/dx-commit-experience-revert

Dx commit experience revert
pull/2900/head
Audric Ackermann 2 years ago committed by GitHub
commit e75adaa754
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,5 @@
#!/usr/bin/env sh #!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh" . "$(dirname -- "$0")/_/husky.sh"
npx lint-staged # Disabling this hook for now because the BuildLintCommand has issues. If you have an error in a file that eslint catches the commit fails silently instead of explaining the error (Will 04/09/2023)
# npx lint-staged

@ -1,25 +1,38 @@
const ignoredFiles = [ const { ESLint } = require('eslint');
'package.json',
'yarn.lock', const removeIgnoredFiles = async files => {
'tsconfig.json', const eslint = new ESLint();
'.lintstagedrc.js', const isIgnored = await Promise.all(
'.eslintrc.js', files.map(file => {
]; return eslint.isPathIgnored(file);
})
const path = require('path'); );
const filteredFiles = files.filter((_, i) => !isIgnored[i]);
const buildFormatCommand = filenames => { return filteredFiles.join(' ');
const results = filenames };
.map(f => path.relative(process.cwd(), f))
.filter(f => !ignoredFiles.includes(f)); const buildFormatCommand = async files => {
const filesToLint = await removeIgnoredFiles(files);
return results.length ? `prettier --list-different --write ${results.join(' ')}` : '';
if (!filesToLint || !filesToLint.length) {
return '';
}
const results = filesToLint.map(f => path.relative(process.cwd(), f));
return results.length
? `prettier --ignore-unknown --list-different --write ${results.join(' ')}`
: '';
}; };
const buildLintCommand = filenames => { const buildLintCommand = async files => {
const results = filenames const filesToLint = await removeIgnoredFiles(files);
.map(f => path.relative(process.cwd(), f))
.filter(f => !ignoredFiles.includes(f)); if (!filesToLint || !filesToLint.length) {
return '';
}
const results = filesToLint.map(f => path.relative(process.cwd(), f));
return results.length ? `eslint --cache ${results.join(' ')}` : ''; return results.length ? `eslint --cache ${results.join(' ')}` : '';
}; };

Loading…
Cancel
Save