Skip to content

Commit

Permalink
Enable caching for ESLint and Prettier (#881)
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis committed Sep 1, 2023
1 parent a70b6a6 commit 74312ba
Show file tree
Hide file tree
Showing 23 changed files with 31 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-beds-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sku': minor
---

Enable caching for ESLint and Prettier
1 change: 1 addition & 0 deletions fixtures/assertion-removal/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# managed by sku
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
1 change: 1 addition & 0 deletions fixtures/braid-design-system/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# managed by sku
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
1 change: 1 addition & 0 deletions fixtures/custom-src-paths/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# managed by sku
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
1 change: 1 addition & 0 deletions fixtures/library-build/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# managed by sku
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
1 change: 1 addition & 0 deletions fixtures/library-file/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# managed by sku
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
1 change: 1 addition & 0 deletions fixtures/lint-format/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# managed by sku
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
1 change: 1 addition & 0 deletions fixtures/multiple-routes/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# managed by sku
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
1 change: 1 addition & 0 deletions fixtures/public-path/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# managed by sku
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
1 change: 1 addition & 0 deletions fixtures/react-css-modules/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# managed by sku
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
1 change: 1 addition & 0 deletions fixtures/sku-test/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# managed by sku
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
1 change: 1 addition & 0 deletions fixtures/sku-with-https/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# managed by sku
.eslintcache
.eslintrc
.prettierrc
.ssl
Expand Down
1 change: 1 addition & 0 deletions fixtures/source-maps/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# managed by sku
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
1 change: 1 addition & 0 deletions fixtures/ssr-hello-world/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# managed by sku
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
1 change: 1 addition & 0 deletions fixtures/storybook-config/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ node_modules
npm-debug.log

# managed by sku
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
1 change: 1 addition & 0 deletions fixtures/styling/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# managed by sku
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
1 change: 1 addition & 0 deletions fixtures/translations/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# managed by sku
**/*.vocab/index.ts
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
1 change: 1 addition & 0 deletions fixtures/typescript-css-modules/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# managed by sku
.eslintcache
.eslintrc
.prettierrc
.storybook/main.js
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test": "SKU_TELEMETRY=false SKU_DISABLE_CACHE=true OPEN_TAB=false jest --verbose",
"setup-test-hosts": "node test-utils/setupTestHosts",
"format": "prettier --cache --write '**/*.{js,ts,tsx,md,less,css}' && eslint --cache --fix .",
"format-check": "prettier --list-different '**/*.{js,ts,tsx,md,less,css}'",
"format-check": "prettier --cache --list-different '**/*.{js,ts,tsx,md,less,css}'",
"deploy-docs": "pnpm run --filter @sku-private/docs deploy",
"release": "pnpm deploy-docs && changeset publish",
"version": "changeset version && pnpm install --lockfile-only"
Expand Down
3 changes: 2 additions & 1 deletion packages/sku/lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ module.exports = async () => {

// Generate ESLint configuration
const eslintConfigFilename = '.eslintrc';
const eslintCacheFilename = '.eslintcache';
await writeFileToCWD(eslintConfigFilename, eslintConfig);
gitIgnorePatterns.push(eslintConfigFilename);
gitIgnorePatterns.push(eslintConfigFilename, eslintCacheFilename);

// Generate Prettier configuration
// NOTE: We are not generating a banner as prettier does not support the `JSON
Expand Down
1 change: 1 addition & 0 deletions packages/sku/lib/runESLint.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const runESLint = async ({ fix = false, paths }) => {
extensions,
useEslintrc: false,
fix,
cache: true,
});
const checkAll = typeof paths === 'undefined';
/* Whitelist the file extensions that our ESLint setup currently supports */
Expand Down
2 changes: 1 addition & 1 deletion packages/sku/lib/runPrettier.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const runPrettier = async ({ write, listDifferent, paths }) => {
chalk.cyan(`${write ? 'Formatting' : 'Checking'} code with Prettier`),
);

const prettierArgs = ['--config', prettierConfigPath];
const prettierArgs = ['--config', prettierConfigPath, '--cache'];

if (write) {
prettierArgs.push('--write');
Expand Down
6 changes: 4 additions & 2 deletions tests/configure.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ describe('configure', () => {

it(`should generate \`.gitignore\``, async () => {
const ignoreContents = await readIgnore(appFolder, '.gitignore');
expect(ignoreContents.length).toEqual(8);
expect(ignoreContents.length).toEqual(9);
expect(ignoreContents).toContain(`.eslintrc`);
expect(ignoreContents).toContain(`.eslintcache`);
expect(ignoreContents).toContain(`.prettierrc`);
expect(ignoreContents).toContain(`.storybook/main.js`);
expect(ignoreContents).toContain(`${defaultTargetDir}/`);
Expand Down Expand Up @@ -139,8 +140,9 @@ describe('configure', () => {

it(`should generate \`.gitignore\``, async () => {
const ignoreContents = await readIgnore(appFolderTS, '.gitignore');
expect(ignoreContents.length).toEqual(8);
expect(ignoreContents.length).toEqual(9);
expect(ignoreContents).toContain(`.eslintrc`);
expect(ignoreContents).toContain(`.eslintcache`);
expect(ignoreContents).toContain(`.prettierrc`);
expect(ignoreContents).toContain(`tsconfig.json`);
expect(ignoreContents).toContain(`.storybook/main.js`);
Expand Down

0 comments on commit 74312ba

Please sign in to comment.