Skip to content

Commit

Permalink
ci: update ci
Browse files Browse the repository at this point in the history
  • Loading branch information
tianyingchun committed May 29, 2024
1 parent 7347a81 commit 2721c7e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 29 deletions.
19 changes: 0 additions & 19 deletions lint-staged.common.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import path from 'path';
import { quote } from 'shell-quote';

const isWin = process.platform === 'win32';

const eslintGlobalRulesForFix = [
// react-hooks/eslint and react in general is very strict about exhaustively
Expand Down Expand Up @@ -62,19 +59,3 @@ export const getEslintFixCmd = ({
].join(' ');
return `eslint ${args}`;
};

/**
* Concatenate and escape a list of filenames that can be passed as args to prettier cli
*
* Prettier has an issue with special characters in filenames,
* such as the ones uses for nextjs dynamic routes (ie: [id].tsx...)
*
* @link https://github.com/okonet/lint-staged/issues/676
*
* @param {string[]} filenames
* @returns {string} Return concatenated and escaped filenames
*/
export const concatFilesForPrettier = (filenames) =>
filenames
.map((filename) => `"${isWin ? filename : quote([filename])}"`)
.join(' ');
10 changes: 1 addition & 9 deletions lint-staged.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { fileURLToPath } from 'node:url';
* A good practice is to override this base configuration in each package and/or application
* where we are able to add customization depending on the nature of the project (eslint...).
*/
import {
concatFilesForPrettier,
getEslintFixCmd,
} from './lint-staged.common.mjs';
import { getEslintFixCmd } from './lint-staged.common.mjs';

/**
* @type {Record<string, (filenames: string[]) => string | string[] | Promise<string | string[]>>}
Expand All @@ -26,11 +23,6 @@ const rules = {
files: filenames,
});
},
'**/*.{json,md,mdx,css,html,yml,yaml,scss,ts,js,tsx,jsx,mjs}': (
filenames
) => {
return [`prettier --write ${concatFilesForPrettier(filenames)}`];
},
};

export default rules;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"lint-staged-files": "lint-staged --allow-empty",
"changeset": "changeset",
"release": "yarn build && changeset publish",
"cz": "cz"
"cz": "cz",
"postinstall": "is-ci || husky"
},
"config": {
"commitizen": {
Expand Down

0 comments on commit 2721c7e

Please sign in to comment.