Skip to content

Commit

Permalink
chore(project): update prettier to v2 (#6196)
Browse files Browse the repository at this point in the history
* chore(project): update prettier to v2

* chore(project): format files

* chore(project): sync offline mirror

Co-authored-by: TJ Egan <tw15egan@gmail.com>
  • Loading branch information
joshblack and tw15egan authored Jun 8, 2020
1 parent 7e19776 commit f1c92af
Show file tree
Hide file tree
Showing 400 changed files with 2,215 additions and 2,477 deletions.
Binary file added .yarn/offline-mirror/prettier-2.0.5.tgz
Binary file not shown.
14 changes: 7 additions & 7 deletions actions/add-review-labels/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async function run() {
reviews.push(review);
}

const approved = reviews.filter(review => {
const approved = reviews.filter((review) => {
return review.state === 'APPROVED';
});

Expand All @@ -93,7 +93,7 @@ async function run() {
const needsReviewLabels = new Set([visualReviewLabel, contentReviewLabel]);

if (approved.length > 0) {
const hasReadyLabel = pullRequest.labels.find(label => {
const hasReadyLabel = pullRequest.labels.find((label) => {
return label.name === readyForReviewLabel;
});
if (hasReadyLabel) {
Expand All @@ -107,7 +107,7 @@ async function run() {
}

if (approved.length === 1) {
const hasAdditionalReviewLabel = pullRequest.labels.find(label => {
const hasAdditionalReviewLabel = pullRequest.labels.find((label) => {
return label.name === additionalReviewLabel;
});
if (!hasAdditionalReviewLabel) {
Expand All @@ -122,7 +122,7 @@ async function run() {
}

if (approved.length >= 2) {
const hasAdditionalReviewLabel = pullRequest.labels.find(label => {
const hasAdditionalReviewLabel = pullRequest.labels.find((label) => {
return label.name === additionalReviewLabel;
});
if (hasAdditionalReviewLabel) {
Expand All @@ -134,14 +134,14 @@ async function run() {
});
}

const allNeedsReviewLabels = pullRequest.labels.filter(label => {
const allNeedsReviewLabels = pullRequest.labels.filter((label) => {
return needsReviewLabels.has(label.name);
});
if (allNeedsReviewLabels.length > 0) {
return;
}

const shouldAutoLabel = autoLabelUsers.find(user => {
const shouldAutoLabel = autoLabelUsers.find((user) => {
return user === pullRequest.user.login;
});
if (shouldAutoLabel) {
Expand All @@ -156,7 +156,7 @@ async function run() {
}
}

run().catch(error => {
run().catch((error) => {
console.log(error);
process.exit(1);
});
4 changes: 2 additions & 2 deletions docs/guides/building-an-icon-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ high-level, the pattern for this file matches:
const path = require('path');
const build = require('../src/build');

build({ cwd: path.resolve(__dirname, '../') }).catch(error => {
build({ cwd: path.resolve(__dirname, '../') }).catch((error) => {
console.error(error);
});
```
Expand Down Expand Up @@ -177,7 +177,7 @@ async function build({ cwd }) {
await Promise.all(
// `meta` is a map that provides a hash of information about the current
// icon to build
meta.map(async info => {
meta.map(async (info) => {
// Typically, implementations will have a way to create a source module
// from a source file and use that to write to the ESM path.
const source = createModuleFromInfo(info);
Expand Down
2 changes: 1 addition & 1 deletion e2e/icons-handlebars/handlebars-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('icons-handlebars', () => {
}).toThrow();
});

test.each(Object.keys(CarbonIcons))('%s should compile', name => {
test.each(Object.keys(CarbonIcons))('%s should compile', (name) => {
expect(() => {
hbs.compile(`{{ carbon-icon "${name}" }}`)();
hbs.compile(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"jest-junit": "^10.0.0",
"lerna": "^3.20.2",
"lint-staged": "^9.5.0",
"prettier": "^1.19.1",
"prettier": "^2.0.5",
"prettier-config-carbon": "^0.0.0",
"react": "^16.8.6",
"react-dom": "^16.8.6",
Expand Down
4 changes: 2 additions & 2 deletions packages/bundler/bin/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on('unhandledRejection', err => {
process.on('unhandledRejection', (err) => {
console.error(err);
});

Expand All @@ -40,7 +40,7 @@ if (major < 8) {

var bundler = require('../src/bundler');

bundler(process).catch(error => {
bundler(process).catch((error) => {
console.error(error);
process.exit(1);
});
2 changes: 1 addition & 1 deletion packages/bundler/src/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async function bundler({ argv, cwd: getWorkingDirectory }) {
'the directory to output inlined sass dependencies',
'scss'
)
.action(cmd =>
.action((cmd) =>
inline(cleanArgs(cmd), {
cwd,
})
Expand Down
2 changes: 1 addition & 1 deletion packages/bundler/src/bundlers/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async function bundle(entrypoint, options) {
}

function formatGlobals(string) {
const mappings = string.split(',').map(mapping => {
const mappings = string.split(',').map((mapping) => {
return mapping.split('=');
});
return mappings.reduce(
Expand Down
4 changes: 2 additions & 2 deletions packages/bundler/src/commands/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function check(pattern, { ignore, cwd, list } = {}) {
reporter.info(`Compiling ${files.length} files...`);

const results = await Promise.all(
compile(files.map(file => path.join(cwd, file)))
compile(files.map((file) => path.join(cwd, file)))
);

const errors = results.reduce((acc, result) => {
Expand All @@ -37,7 +37,7 @@ async function check(pattern, { ignore, cwd, list } = {}) {
}, []);

if (errors.length > 0) {
errors.forEach(error => {
errors.forEach((error) => {
const { formatted, file } = error;
reporter.error(`Error compiling ${path.relative(cwd, file)}`);
console.log(chalk.gray(formatted));
Expand Down
4 changes: 2 additions & 2 deletions packages/bundler/src/commands/inline.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function inlineSassDependencies(
];
const inlinedDependencies = (
await Promise.all(
allPossibleDependencies.map(async dependency => {
allPossibleDependencies.map(async (dependency) => {
const modules = await findSassModule(dependency, cwd);
if (modules) {
const [scssFolder] = modules;
Expand Down Expand Up @@ -106,7 +106,7 @@ async function inlineSassDependencies(
'gm'
);
await Promise.all(
paths.map(async file => {
paths.map(async (file) => {
const relativeImportPath = path.relative(
path.dirname(file.path),
vendorFolder
Expand Down
10 changes: 5 additions & 5 deletions packages/bundler/src/commands/measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function measure(pattern, { cwd, output, ignore = [] }) {
});

const results = await Promise.all(
compile(files.map(file => path.join(cwd, file)))
compile(files.map((file) => path.join(cwd, file)))
);

const errors = results.reduce((acc, result) => {
Expand All @@ -45,7 +45,7 @@ async function measure(pattern, { cwd, output, ignore = [] }) {
}, []);

if (errors.length > 0) {
errors.forEach(error => {
errors.forEach((error) => {
const { formatted, filepath } = error;
reporter.error(`Error compiling ${path.relative(cwd, filepath)}`);
console.log(chalk.gray(formatted));
Expand Down Expand Up @@ -113,12 +113,12 @@ function printResults(prevResults, results) {
];

const table = new Table({
head: resultsHeaders.map(label => chalk.gray.yellow(label)),
head: resultsHeaders.map((label) => chalk.gray.yellow(label)),
});

results.forEach(result => {
results.forEach((result) => {
const prevResult =
prevResults.find(prevResult => {
prevResults.find((prevResult) => {
return (
prevResult.filename === result.filename &&
prevResult.package === result.package
Expand Down
4 changes: 2 additions & 2 deletions packages/bundler/src/tools/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const defaultOptions = {

function compile(filepaths, options) {
return filepaths.map(
filepath =>
new Promise(resolve => {
(filepath) =>
new Promise((resolve) => {
sass.render(
{
file: filepath,
Expand Down
33 changes: 17 additions & 16 deletions packages/bundler/src/tools/sassdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const prettierOptions = {
* Custom slugify for markdown-toc to not include escaped emoji characters
* @param {string} title - the anchor link
*/
const slugify = title => {
const slugify = (title) => {
return [...toc.slugify(title)].reduce((acc, ch) => {
if (ch.charCodeAt(0) > 255) {
return acc;
Expand All @@ -45,10 +45,10 @@ async function createJson(sourceDir, config) {
config = config || {};

return sassdoc.parse(sourceDir, config).then(
data => {
(data) => {
return data;
},
err => {
(err) => {
console.error(err);
}
);
Expand Down Expand Up @@ -161,7 +161,7 @@ $${item.context.name}: ${item.context.value};
let paramStr = '';

if (item.parameter) {
item.parameter.forEach(param => {
item.parameter.forEach((param) => {
if (paramStr) paramStr += `, `;
paramStr += `$${param.name}`;
if (param.default) paramStr += `: ${param.default}`;
Expand All @@ -188,14 +188,15 @@ $${item.context.name}: ${item.context.value};
| Name | Description | Type | Default value |
| --- | --- | --- | --- |`;

item.parameter.forEach(param => {
item.parameter.forEach((param) => {
const paramType = param.type
? `\`${param.type.replace(/\|/g, `\\|`)}\``
: '—';
const paramDefault = param.default ? `\`${param.default}\`` : '—';

const row = `\n| \`$${param.name}\` | ${param.description ||
'—'} | ${paramType} | ${paramDefault} |`;
const row = `\n| \`$${param.name}\` | ${
param.description || '—'
} | ${paramType} | ${paramDefault} |`;

str += row;
});
Expand Down Expand Up @@ -254,7 +255,7 @@ ${item.example[0].code}
if (item.aliased) {
let subbullets = '';

item.aliased.forEach(aliased => {
item.aliased.forEach((aliased) => {
subbullets += `\n - \`${aliased}\``;
});

Expand All @@ -274,7 +275,7 @@ ${item.example[0].code}
if (item.require && item.require.length) {
let subbullets = '';

dedupeArray(item.require).forEach(requires => {
dedupeArray(item.require).forEach((requires) => {
subbullets += `\n - ${createAnchorLink(
`${requires.name} [${requires.type}]`,
createUniqueName(requires.name, requires.type)
Expand All @@ -290,7 +291,7 @@ ${item.example[0].code}
if (item.usedBy && item.usedBy.length) {
let subbullets = '';

dedupeArray(item.usedBy).forEach(usedBy => {
dedupeArray(item.usedBy).forEach((usedBy) => {
subbullets += `\n - ${createAnchorLink(
`${usedBy.context.name} [${usedBy.context.type}]`,
createUniqueName(usedBy.context.name, usedBy.context.type)
Expand All @@ -313,7 +314,7 @@ ${item.example[0].code}
if (item.link && item.link.length) {
let subbullets = '';

item.link.forEach(link => {
item.link.forEach((link) => {
subbullets += `\n - [${link.caption || 'Link'}](${link.url})`;
});

Expand All @@ -333,7 +334,7 @@ ${item.example[0].code}
if (metadata.length) {
str += '\n';

metadata.forEach(meta => {
metadata.forEach((meta) => {
str += `\n- **${meta.key}**: ${meta.value}`;
});
}
Expand All @@ -352,11 +353,11 @@ async function createMarkdown(sourceDir, config) {
config = config || {};

return sassdoc.parse(sourceDir, config).then(
data => {
(data) => {
let markdownFile = '';

const documentedItems = data.filter(
item => item.access === 'public' || item.access === 'private'
(item) => item.access === 'public' || item.access === 'private'
);

markdownFile += `# Sass API
Expand All @@ -372,7 +373,7 @@ async function createMarkdown(sourceDir, config) {

let currentGroup = '';

documentedItems.forEach(item => {
documentedItems.forEach((item) => {
const itemGroup = createGroupName(item.group);

if (itemGroup !== currentGroup) {
Expand All @@ -388,7 +389,7 @@ async function createMarkdown(sourceDir, config) {
prettierOptions
);
},
err => {
(err) => {
console.error(err);
}
);
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/bin/carbon-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on('unhandledRejection', error => {
process.on('unhandledRejection', (error) => {
console.error(error);
});

Expand All @@ -40,7 +40,7 @@ if (major < 8) {

var main = require('../src/cli');

main(process).catch(error => {
main(process).catch((error) => {
console.error(error);
process.exit(1);
});
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"fast-glob": "^3.2.2",
"fs-extra": "^8.0.1",
"inquirer": "^6.4.1",
"prettier": "^1.19.1",
"prettier": "^2.0.5",
"prettier-config-carbon": "^0.0.0",
"progress-estimator": "^0.2.2",
"remark": "^10.0.1",
Expand Down
Loading

0 comments on commit f1c92af

Please sign in to comment.