Skip to content

Commit

Permalink
Chore(all): Enforce usage of replaceAll instead of replace
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Apr 25, 2024
1 parent 018d4d5 commit fe0ebdb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"prettier/prettier": "error",
"unicorn/no-abusive-eslint-disable": "error",
"unicorn/prefer-module": "error",
"unicorn/prefer-node-protocol": "error"
"unicorn/prefer-node-protocol": "error",
"unicorn/prefer-string-replace-all": "error"
},
"overrides": [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/lib/prompts/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function renderChoices(choices, pointer) {
output += '\n';
});

return output.replace(/\n$/, '');
return output.replaceAll(/\n$/g, '');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/inquirer/lib/prompts/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,5 @@ function listRender(choices, pointer) {
output += line + ' \n';
});

return output.replace(/\n$/, '');
return output.replaceAll(/\n$/g, '');
}
4 changes: 2 additions & 2 deletions tools/fix-ext.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mjsFiles.forEach(async (pathname) => {
const fileContent = await fs.readFile(pathname, 'utf-8');
await fs.writeFile(
pathname,
fileContent.replace(/require\(['"]([^'"]*)\.mjs['"]\)/g, "require('$1.js')"),
fileContent.replaceAll(/require\(['"]([^'"]*)\.mjs['"]\)/g, "require('$1.js')"),
);

// 2. Rename files
Expand All @@ -32,7 +32,7 @@ dmtsFiles.forEach(async (pathname) => {
const fileContent = await fs.readFile(pathname, 'utf-8');
await fs.writeFile(
pathname,
fileContent.replace(/from '([^']*)\.mjs'/g, "from '$1.js'"),
fileContent.replaceAll(/from '([^']*)\.mjs'/g, "from '$1.js'"),
);

// 2. Rename files
Expand Down

0 comments on commit fe0ebdb

Please sign in to comment.