Skip to content

Commit

Permalink
Ensure lint and lint staged use same extensions (#821)
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis authored May 30, 2023
1 parent b3e1aaf commit 51186f3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/cold-worms-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sku': patch
---

Ensure `sku pre-commit` lints the same files as `sku lint`
5 changes: 3 additions & 2 deletions packages/sku/config/lintStaged/lintStagedConfig.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
const isYarn = require('../../lib/isYarn');
const { lintExtensions } = require('../../lib/lint');

const steps = {};

// Yarn lock integrity check
if (isYarn) {
steps['+(package.json|yarn.lock)'] = [() => 'yarn check --integrity'];
steps['+(package.json|yarn.lock)'] = [() => 'yarn install --check-files'];
}

// Format & lint
steps['**/*.{js,ts,tsx,md,less}'] = ['sku format', 'sku lint'];
steps[`**/*.{${lintExtensions},md,less}`] = ['sku format', 'sku lint'];

module.exports = steps;
8 changes: 8 additions & 0 deletions packages/sku/lib/lint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const {
js: jsExtensions,
ts: tsExtensions,
} = require('eslint-config-seek/extensions');

const lintExtensions = [...tsExtensions, ...jsExtensions];

module.exports = { lintExtensions };
7 changes: 2 additions & 5 deletions packages/sku/lib/runESLint.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
const { yellow, cyan, gray } = require('chalk');
const { ESLint } = require('eslint');
const eslintConfig = require('../config/eslint/eslintConfig');
const {
js: jsExtensions,
ts: tsExtensions,
} = require('eslint-config-seek/extensions');
const { lintExtensions } = require('./lint');

const extensions = [...tsExtensions, ...jsExtensions].map((ext) => `.${ext}`);
const extensions = lintExtensions.map((ext) => `.${ext}`);

/**
* @param {{ fix?: boolean, paths?: string[] }}
Expand Down

0 comments on commit 51186f3

Please sign in to comment.