Skip to content

Commit

Permalink
Always use arrow parens
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Mar 21, 2020
1 parent 2700af2 commit ba4ebc2
Show file tree
Hide file tree
Showing 39 changed files with 274 additions and 275 deletions.
3 changes: 1 addition & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
"printWidth": 100,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"arrowParens": "avoid"
"trailingComma": "all"
}
12 changes: 6 additions & 6 deletions docs/scripts/formattedTSDemos.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function getFiles(root) {
const files = [];

await Promise.all(
(await fse.readdir(root)).map(async name => {
(await fse.readdir(root)).map(async (name) => {
const filePath = path.join(root, name);
const stat = await fse.stat(filePath);

Expand All @@ -48,7 +48,7 @@ async function getFiles(root) {
} else if (
stat.isFile() &&
filePath.endsWith('.tsx') &&
!ignoreList.some(ignorePath => filePath.endsWith(path.normalize(ignorePath)))
!ignoreList.some((ignorePath) => filePath.endsWith(path.normalize(ignorePath)))
) {
files.push(filePath);
}
Expand Down Expand Up @@ -116,8 +116,8 @@ async function main(argv) {
let successful = 0;
let failed = 0;
let skipped = 0;
(await Promise.all(tsxFiles.map(file => transpileFile(file, program, cacheDisabled)))).forEach(
result => {
(await Promise.all(tsxFiles.map((file) => transpileFile(file, program, cacheDisabled)))).forEach(
(result) => {
switch (result) {
case TranspileResult.Success: {
successful += 1;
Expand Down Expand Up @@ -157,7 +157,7 @@ async function main(argv) {
return;
}

tsxFiles.forEach(filePath => {
tsxFiles.forEach((filePath) => {
fse.watchFile(filePath, { interval: 500 }, async () => {
if ((await transpileFile(filePath, program, true)) === 0) {
console.log('Success - %s', filePath);
Expand All @@ -172,7 +172,7 @@ yargs
.command({
command: '$0',
description: 'transpile typescript demos',
builder: command => {
builder: (command) => {
return command
.option('watch', {
default: false,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/AdCarbon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { withStyles } from '@material-ui/core/styles';
import loadScript from 'docs/src/modules/utils/loadScript';

const styles = theme => ({
const styles = (theme) => ({
'@global': {
'#carbonads': {
display: 'block',
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/AdCodeFund.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { withStyles } from '@material-ui/core/styles';
import loadScript from 'docs/src/modules/utils/loadScript';

const styles = theme => ({
const styles = (theme) => ({
'@global': {
'#cf': {
display: 'block',
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/AdInHouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import propTypes from 'prop-types';
import { makeStyles } from '@material-ui/core/styles';

const useStyles = makeStyles(theme => ({
const useStyles = makeStyles((theme) => ({
root: {
display: 'block',
overflow: 'hidden',
Expand Down
20 changes: 10 additions & 10 deletions docs/src/modules/components/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function addHiddenInput(form, name, value) {
form.appendChild(input);
}

const styles = theme => ({
const styles = (theme) => ({
root: {
marginBottom: 40,
marginLeft: -theme.spacing(2),
Expand Down Expand Up @@ -164,8 +164,8 @@ function useUniqueId(prefix) {
function Demo(props) {
const { classes, demo, demoOptions, githubLocation } = props;
const dispatch = useDispatch();
const t = useSelector(state => state.options.t);
const codeVariant = useSelector(state => state.options.codeVariant);
const t = useSelector((state) => state.options.t);
const codeVariant = useSelector((state) => state.options.codeVariant);
const demoData = getDemoData(codeVariant, demo, githubLocation);

const [sourceHintSeen, setSourceHintSeen] = React.useState(false);
Expand All @@ -174,7 +174,7 @@ function Demo(props) {
}, []);

const [demoHovered, setDemoHovered] = React.useState(false);
const handleDemoHover = event => {
const handleDemoHover = (event) => {
setDemoHovered(event.type === 'mouseenter');
};

Expand Down Expand Up @@ -231,7 +231,7 @@ function Demo(props) {
};

const [anchorEl, setAnchorEl] = React.useState(null);
const handleMoreClick = event => {
const handleMoreClick = (event) => {
setAnchorEl(event.currentTarget);
};

Expand Down Expand Up @@ -260,7 +260,7 @@ function Demo(props) {
addHiddenInput(form, 'project[description]', demoConfig.description);
addHiddenInput(form, 'project[dependencies]', JSON.stringify(demoConfig.dependencies));
addHiddenInput(form, 'project[devDependencies]', JSON.stringify(demoConfig.devDependencies));
Object.keys(demoConfig.files).forEach(key => {
Object.keys(demoConfig.files).forEach((key) => {
const value = demoConfig.files[key];
addHiddenInput(form, `project[files][${key}]`, value);
});
Expand Down Expand Up @@ -289,7 +289,7 @@ function Demo(props) {
demoOptions.bg = true;
}

const createHandleCodeSourceLink = anchor => async () => {
const createHandleCodeSourceLink = (anchor) => async () => {
try {
await copy(`${window.location.href.split('#')[0]}#${anchor}`);
setSnackbarMessage(t('copiedSourceLink'));
Expand All @@ -310,11 +310,11 @@ function Demo(props) {

const handleCodeOpenClick = () => {
document.cookie = `sourceHintSeen=true;path=/;max-age=31536000`;
setCodeOpen(open => !open);
setCodeOpen((open) => !open);
setSourceHintSeen(setSourceHintSeen(true));
};

const match = useMediaQuery(theme => theme.breakpoints.up('sm'));
const match = useMediaQuery((theme) => theme.breakpoints.up('sm'));

const jsx = getJsxPreview(demoData.raw || '');
const showPreview =
Expand All @@ -330,7 +330,7 @@ function Demo(props) {
showCodeLabel = showPreview ? t('showFullSource') : t('showSource');
}

const [demoKey, resetDemo] = React.useReducer(key => key + 1, 0);
const [demoKey, resetDemo] = React.useReducer((key) => key + 1, 0);

const demoSourceId = useUniqueId(`demo-`);
const openDemoSource = codeOpen || showPreview;
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/redux/initRedux.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
import optionsReducer from 'docs/src/modules/redux/optionsReducer';

// Get the Redux DevTools extension and fallback to a no-op function
let devtools = x => x;
let devtools = (x) => x;

if (
process.env.NODE_ENV !== 'production' &&
Expand Down
6 changes: 3 additions & 3 deletions docs/src/modules/utils/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function findPagesMarkdown(
) {
const items = fs.readdirSync(directory);

items.forEach(item => {
items.forEach((item) => {
const itemPath = path.resolve(directory, item);

if (fs.statSync(itemPath).isDirectory()) {
Expand Down Expand Up @@ -51,7 +51,7 @@ const componentRegex = /^([A-Z][a-z]+)+\.js/;
function findComponents(directory, components = []) {
const items = fs.readdirSync(directory);

items.forEach(item => {
items.forEach((item) => {
const itemPath = path.resolve(directory, item);

if (fs.statSync(itemPath).isDirectory()) {
Expand Down Expand Up @@ -82,7 +82,7 @@ function findPages(
directory = path.resolve(__dirname, '../../../pages'),
pages = [],
) {
fs.readdirSync(directory).forEach(item => {
fs.readdirSync(directory).forEach((item) => {
const itemPath = path.resolve(directory, item);
const pathname = itemPath
.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
Expand Down
20 changes: 10 additions & 10 deletions docs/src/modules/utils/generateMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { SOURCE_CODE_ROOT_URL, LANGUAGES_IN_PROGRESS } from 'docs/src/modules/co

const PATH_REPLACE_REGEX = /\\/g;
const PATH_SEPARATOR = '/';
const DEMO_IGNORE = LANGUAGES_IN_PROGRESS.map(language => `-${language}.md`);
const DEMO_IGNORE = LANGUAGES_IN_PROGRESS.map((language) => `-${language}.md`);

function normalizePath(path) {
return path.replace(PATH_REPLACE_REGEX, PATH_SEPARATOR);
Expand Down Expand Up @@ -91,7 +91,7 @@ function resolveType(type) {
}

if (type.type === 'UnionType') {
return type.elements.map(t => resolveType(t)).join(' \\| ');
return type.elements.map((t) => resolveType(t)).join(' \\| ');
}

return type.name;
Expand Down Expand Up @@ -119,15 +119,15 @@ function generatePropDescription(prop) {
.replace(/(\r?\n){2}/g, '<br>')
.replace(/\r?\n/g, ' ');

if (parsed.tags.some(tag => tag.title === 'ignore')) {
if (parsed.tags.some((tag) => tag.title === 'ignore')) {
return null;
}

let signature = '';

if (type.name === 'func' && parsed.tags.length > 0) {
// Remove new lines from tag descriptions to avoid markdown errors.
parsed.tags.forEach(tag => {
parsed.tags.forEach((tag) => {
if (tag.description) {
tag.description = tag.description.replace(/\r*\n/g, ' ');
}
Expand All @@ -149,7 +149,7 @@ function generatePropDescription(prop) {

signature += '<br><br>**Signature:**<br>`function(';
signature += parsedArgs
.map(tag => {
.map((tag) => {
if (tag.type.type === 'OptionalType') {
return `${tag.name}?: ${tag.type.expression.name}`;
}
Expand All @@ -158,7 +158,7 @@ function generatePropDescription(prop) {
})
.join(', ');
signature += `) => ${parsedReturns.type.name}\`<br>`;
signature += parsedArgs.map(tag => `*${tag.name}:* ${tag.description}`).join('<br>');
signature += parsedArgs.map((tag) => `*${tag.name}:* ${tag.description}`).join('<br>');
if (parsedReturns.description) {
signature += `<br> *returns* (${parsedReturns.type.name}): ${parsedReturns.description}`;
}
Expand Down Expand Up @@ -203,7 +203,7 @@ function generatePropType(type) {

case 'shape':
return `{ ${Object.keys(type.value)
.map(subValue => {
.map((subValue) => {
const subType = type.value[subValue];
return `${subValue}${subType.required ? '' : '?'}: ${generatePropType(subType)}`;
})
Expand All @@ -213,7 +213,7 @@ function generatePropType(type) {
case 'enum': {
return (
type.value
.map(type2 => {
.map((type2) => {
if (type.name === 'enum') {
return escapeCell(type2.value);
}
Expand Down Expand Up @@ -352,7 +352,7 @@ function generateClasses(reactAPI) {
text = `| Rule name | Global class | Description |
|:-----|:-------------|:------------|\n`;
text += reactAPI.styles.classes
.map(styleRule => {
.map((styleRule) => {
if (styleRule === '@global') {
return '| <span class="prop-name">@global</span> | | Apply global styles.';
}
Expand Down Expand Up @@ -433,7 +433,7 @@ function generateDemos(reactAPI) {
return `## Demos
${pagesMarkdown
.map(page => `- [${pageToTitle(page)}](${rewriteUrlForNextExport(page.pathname)})`)
.map((page) => `- [${pageToTitle(page)}](${rewriteUrlForNextExport(page.pathname)})`)
.join('\n')}
`;
Expand Down
10 changes: 5 additions & 5 deletions docs/src/pages/components/autocomplete/GoogleMaps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function loadScript(src: string, position: HTMLElement | null, id: string) {

const autocompleteService = { current: null };

const useStyles = makeStyles(theme => ({
const useStyles = makeStyles((theme) => ({
icon: {
color: theme.palette.text.secondary,
marginRight: theme.spacing(2),
Expand Down Expand Up @@ -103,12 +103,12 @@ export default function GoogleMaps() {
<Autocomplete
id="google-map-demo"
style={{ width: 300 }}
getOptionLabel={option => (typeof option === 'string' ? option : option.description)}
filterOptions={x => x}
getOptionLabel={(option) => (typeof option === 'string' ? option : option.description)}
filterOptions={(x) => x}
options={options}
autoComplete
includeInputInList
renderInput={params => (
renderInput={(params) => (
<TextField
{...params}
label="Add a location"
Expand All @@ -117,7 +117,7 @@ export default function GoogleMaps() {
onChange={handleChange}
/>
)}
renderOption={option => {
renderOption={(option) => {
const matches = option.structured_formatting.main_text_matched_substrings;
const parts = parse(
option.structured_formatting.main_text,
Expand Down
Loading

0 comments on commit ba4ebc2

Please sign in to comment.