diff --git a/.gitignore b/.gitignore index 8e0c70c..f7a9961 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist # when working with contributors package-lock.json yarn.lock +.jest-cache/ diff --git a/lint-staged.config.js b/lint-staged.config.js new file mode 100644 index 0000000..085411b --- /dev/null +++ b/lint-staged.config.js @@ -0,0 +1,15 @@ +const {resolveKcdScripts, resolveBin} = require('kcd-scripts/dist/utils') + +const kcdScripts = resolveKcdScripts() +const doctoc = resolveBin('doctoc') + +// Custom lint-staged config to work around Jest --findRelatedTests unreliability: +// https://github.com/facebook/jest/issues/11527 +module.exports = { + 'README.md': [`${doctoc} --maxlevel 3 --notitle`], + '*.+(js|jsx|json|yml|yaml|css|less|scss|ts|tsx|md|gql|graphql|mdx|vue)': [ + `${kcdScripts} format`, + `${kcdScripts} lint`, + () => `${kcdScripts} test`, + ], +} diff --git a/tests/jest.config.dom.js b/tests/jest.config.dom.js index e3c4c59..d2cc9ef 100644 --- a/tests/jest.config.dom.js +++ b/tests/jest.config.dom.js @@ -1,8 +1,10 @@ const path = require('path') const config = require('kcd-scripts/jest') +const {watchPlugins, ...configWithoutWatchPlugins} = config + module.exports = { - ...config, + ...configWithoutWatchPlugins, rootDir: path.resolve(__dirname, '..'), displayName: 'jsdom', testEnvironment: 'jsdom', diff --git a/tests/jest.config.node.js b/tests/jest.config.node.js index 0c3f389..edb3aa6 100644 --- a/tests/jest.config.node.js +++ b/tests/jest.config.node.js @@ -1,8 +1,10 @@ const path = require('path') const config = require('kcd-scripts/jest') +const {watchPlugins, ...configWithoutWatchPlugins} = config + module.exports = { - ...config, + ...configWithoutWatchPlugins, rootDir: path.resolve(__dirname, '..'), displayName: 'node', testEnvironment: 'node',