Skip to content

Commit

Permalink
Fix lint errors from unicorn/better-regex rule
Browse files Browse the repository at this point in the history
  • Loading branch information
codykaup committed Sep 23, 2024
1 parent ddc6391 commit ab21fb0
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions node-src/git/getParentCommits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function createClient({
const mockIndex = createMockIndex(repository, builds, prs);
return {
runQuery(query, variables) {
const queryName = query.match(/query ([a-zA-Z]+)/)[1];
const queryName = query.match(/query ([A-Za-z]+)/)[1];
return mockIndex(queryName, variables);
},
};
Expand Down Expand Up @@ -403,7 +403,7 @@ describe('getParentCommits', () => {
};
const client = {
runQuery(query, variables) {
const queryName = query.match(/query ([a-zA-Z]+)/)[1];
const queryName = query.match(/query ([A-Za-z]+)/)[1];
return mockIndexWithNullFirstBuildCommittedAt(queryName, variables);
},
};
Expand Down
4 changes: 2 additions & 2 deletions node-src/git/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export async function findMergeBase(headRef: string, baseRef: string) {
const branchNames = await Promise.all(
mergeBases.map(async (sha) => {
const name = await execGitCommand(`git name-rev --name-only --exclude="tags/*" ${sha}`);
return name.replace(/~[0-9]+$/, ''); // Drop the potential suffix
return name.replace(/~\d+$/, ''); // Drop the potential suffix
})
);
const baseRefIndex = branchNames.indexOf(baseRef);
Expand Down Expand Up @@ -299,7 +299,7 @@ export async function findFilesFromRepositoryRoot(...patterns: string[]) {
}

export async function mergeQueueBranchMatch(branch) {
const mergeQueuePattern = new RegExp(/gh-readonly-queue\/.*\/pr-(\d+)-[a-f0-9]{30}/);
const mergeQueuePattern = new RegExp(/gh-readonly-queue\/.*\/pr-(\d+)-[\da-f]{30}/);
const match = branch.match(mergeQueuePattern);

return match ? Number(match[1]) : null;
Expand Down
2 changes: 1 addition & 1 deletion node-src/lib/getDependencies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('getDependencies', () => {
});

const [dep] = dependencies;
expect(dep).toMatch(/^[\w@/-]+@@[\d.]+$/);
expect(dep).toMatch(/^[\w/@-]+@@[\d.]+$/);

const dependencyNames = [...dependencies].map((dependency) => dependency.split('@@')[0]);
expect(dependencyNames).toEqual(
Expand Down
2 changes: 1 addition & 1 deletion node-src/lib/getStorybookConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function getStorybookConfiguration(
longName?: string
) {
if (!storybookScript) return null;
const parts = storybookScript.split(/[\s='"]+/);
const parts = storybookScript.split(/[\s"'=]+/);
let index = parts.indexOf(longName);
if (index === -1) {
index = parts.indexOf(shortName);
Expand Down
2 changes: 1 addition & 1 deletion node-src/tasks/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const generateReport = async (ctx: Context) => {
const suffix = parameters.viewportIsDefault ? '' : testSuffixName;
const testCase = suite
.testCase()
.className(spec.component.name.replaceAll(/[|/]/g, '.')) // transform story path to class path
.className(spec.component.name.replaceAll(/[/|]/g, '.')) // transform story path to class path
.name(`${spec.name} ${suffix}`);

switch (status) {
Expand Down
2 changes: 1 addition & 1 deletion node-src/tasks/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface PathSpec {
}
// These are the special characters that need to be escaped in the filename
// because they are used as special characters in picomatch
const SPECIAL_CHARS_REGEXP = /([$^*+?()[\]])/g;
const SPECIAL_CHARS_REGEXP = /([$()*+?[\]^])/g;

// Get all paths in rootDir, starting at dirname.
// We don't want the paths to include rootDir -- so if rootDir = storybook-static,
Expand Down
2 changes: 1 addition & 1 deletion node-src/ui/messages/warnings/deviatingOutputDir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const getHint = (buildScriptName: string, buildScript: string) => {
You can fix this by invoking {bold build-storybook} from your {bold "${buildScriptName}"} script directly.
`);

const invokesBuild = /(^|[ ])build-storybook([ ]|;|&&)/.test(buildScript);
const invokesBuild = /(^| )build-storybook( |;|&&)/.test(buildScript);
const isChained = /build-storybook.*(&&|;)/.test(buildScript);
if (invokesBuild && isChained)
return dedent(chalk`
Expand Down

0 comments on commit ab21fb0

Please sign in to comment.