Skip to content

Commit faa91ef

Browse files
authored
enable prettier (#4518)
* enable prettier * fix prop * fix lint staged * run prettier * prettify more files
1 parent 85225d4 commit faa91ef

File tree

196 files changed

+5541
-5648
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+5541
-5648
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
root: true,
3-
extends: ['eslint:recommended', 'plugin:react/recommended'],
3+
extends: ['eslint:recommended', 'plugin:react/recommended', 'prettier'],
44
parser: '@babel/eslint-parser',
55
env: {
66
browser: true,

.markdownlint.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"default": true,
33
"MD002": false,
44
"MD004": { "style": "dash" },
5-
"MD007": { "indent": 4 },
5+
"MD007": { "indent": 2 },
66
"MD013": { "line_length": 600 },
77
"MD026": false,
88
"MD029": { "style": "ordered" },
@@ -11,6 +11,5 @@
1111
"MD036": false,
1212
"MD041": false,
1313
"no-hard-tabs": false,
14-
"whitespace": false,
15-
"emphasis-style": { "style": "_" }
14+
"whitespace": false
1615
}

.prettierignore

Whitespace-only changes.

.vale/proselint/meta.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
"issues": "https://github.com/errata-ai/proselint/issues/new",
99
"license": "BSD-3-Clause",
1010
"name": "proselint",
11-
"sources": [
12-
"https://github.com/amperser/proselint"
13-
],
11+
"sources": ["https://github.com/amperser/proselint"],
1412
"vale_version": ">=1.0.0",
1513
"coverage": 0.0,
1614
"version": "0.1.0"

cypress/integration/scroll_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const sizes = ['iphone-6', 'macbook-15'];
22
describe('Scroll Test', () => {
3-
sizes.forEach(size => {
3+
sizes.forEach((size) => {
44
it(`scroll to top when accessing new page on ${size}`, () => {
55
cy.viewport(size);
66
cy.visit('/guides/getting-started');

cypress/support/commands.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Cypress.Commands.add('isNotInViewport', element => {
2-
cy.get(element).then($el => {
1+
Cypress.Commands.add('isNotInViewport', (element) => {
2+
cy.get(element).then(($el) => {
33
// we won't have horizontal scollbar
44
const rect = $el[0].getBoundingClientRect();
55
if (rect.top < 0) {
@@ -10,8 +10,8 @@ Cypress.Commands.add('isNotInViewport', element => {
1010
});
1111
});
1212

13-
Cypress.Commands.add('isInViewport', element => {
14-
cy.get(element).then($el => {
13+
Cypress.Commands.add('isInViewport', (element) => {
14+
cy.get(element).then(($el) => {
1515
const rect = $el[0].getBoundingClientRect();
1616

1717
expect(rect.top).to.be.at.least(0);

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"lint:js": "npm run lint-js .",
4545
"lint-js": "eslint --cache --cache-location .cache/.eslintcache",
4646
"lint:markdown": "npm run lint-markdown *.md ./src/content/**/*.md",
47-
"lint-markdown": "markdownlint --rules markdownlint-rule-emphasis-style --config ./.markdownlint.json --ignore './src/content/**/_*.md' --ignore '.vale/**/*.md' --ignore '.github/**/*.md'",
47+
"lint-markdown": "markdownlint --config ./.markdownlint.json --ignore './src/content/**/_*.md' --ignore '.vale/**/*.md' --ignore '.github/**/*.md'",
4848
"lint:social": "alex . -q",
4949
"lint:prose": "vale --config='.vale.ini' src/content",
5050
"lint:links": "hyperlink -c 8 --root dist -r dist/index.html --canonicalroot https://webpack.js.org/ --internal --skip /plugins/extract-text-webpack-plugin/ --skip /printable --skip https:// --skip http:// --skip sw.js > internal-links.tap; cat internal-links.tap | tap-spot",
@@ -55,7 +55,8 @@
5555
"jest": "jest",
5656
"cypress:open": "cypress open",
5757
"cypress:run": "cypress run",
58-
"cypress:ci": "start-server-and-test build-test http://localhost:4200 cypress:run"
58+
"cypress:ci": "start-server-and-test build-test http://localhost:4200 cypress:run",
59+
"prettier": "prettier --write 'src/**/*.{js,jsx,css,scss,md,mdx}' '**/*.{js,json}'"
5960
},
6061
"husky": {
6162
"hooks": {
@@ -68,6 +69,9 @@
6869
],
6970
"*.md": [
7071
"npm run lint-markdown"
72+
],
73+
"*.{js,jsx,css,scss,md,mdx,json}": [
74+
"prettier --write"
7175
]
7276
},
7377
"devDependencies": {
@@ -92,6 +96,7 @@
9296
"directory-tree-webpack-plugin": "^1.0.2",
9397
"duplexer": "^0.1.1",
9498
"eslint": "^7.19.0",
99+
"eslint-config-prettier": "^7.2.0",
95100
"eslint-plugin-cypress": "^2.11.2",
96101
"eslint-plugin-markdown": "^2.0.0-rc.2",
97102
"eslint-plugin-react": "^7.22.0",
@@ -106,14 +111,14 @@
106111
"lodash": "^4.17.19",
107112
"markdownlint": "^0.22.0",
108113
"markdownlint-cli": "^0.26.0",
109-
"markdownlint-rule-emphasis-style": "^1.0.0",
110114
"mini-css-extract-plugin": "^1.3.5",
111115
"mkdirp": "^1.0.4",
112116
"modularscale-sass": "^3.0.3",
113117
"node-fetch": "^2.6.1",
114118
"npm-run-all": "^4.1.1",
115119
"postcss": "^8.2.4",
116120
"postcss-loader": "^5.0.0",
121+
"prettier": "^2.2.1",
117122
"react-refresh": "^0.9.0",
118123
"redirect-webpack-plugin": "^1.0.0",
119124
"remark": "^13.0.0",

prettier.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
singleQuote: true,
3+
semi: true,
4+
trailingComma: 'es5',
5+
};

sitemap-ignore.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[
2-
"app-shell/index.html",
2+
"app-shell/index.html",
33
"appcache/manifest.html",
44
"printable/index.html",
55
"api/printable/index.html",
Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,79 @@
11
import { Children, isValidElement } from 'react';
22
import { Details } from './components';
33

4-
const detailComponentsList = ['link', 'mode', 'entry', 'path', 'filename', 'publicPath', 'library', 'libraryType', 'libraryName', 'advancedLibrary', 'advancedOutput', 'expertOutput', 'expertOutputB', 'expert', 'advancedConditions', 'moduleType', 'advancedActions', 'advancedModule', 'modules', 'alias', 'advancedResolve', 'expertResolve', 'hints', 'devtool', 'target', 'externals', 'externalsType', 'externalsPresets', 'ignoreWarnings', 'stats', 'preset', 'advancedGlobal', 'advancedAssets', 'advancedChunkGroups', 'advancedChunks', 'advancedModules', 'expertModules', 'advancedStatsOptimization', 'advancedOptimization', 'cacheGroupAdvancedSelectors', 'cacheGroupAdvancedEffects', 'advancedSelectors', 'advancedEffects', 'fallbackCacheGroup', 'advanced', 'advancedCaching', 'advancedBuild'];
5-
export const Pre = props => {
4+
const detailComponentsList = [
5+
'link',
6+
'mode',
7+
'entry',
8+
'path',
9+
'filename',
10+
'publicPath',
11+
'library',
12+
'libraryType',
13+
'libraryName',
14+
'advancedLibrary',
15+
'advancedOutput',
16+
'expertOutput',
17+
'expertOutputB',
18+
'expert',
19+
'advancedConditions',
20+
'moduleType',
21+
'advancedActions',
22+
'advancedModule',
23+
'modules',
24+
'alias',
25+
'advancedResolve',
26+
'expertResolve',
27+
'hints',
28+
'devtool',
29+
'target',
30+
'externals',
31+
'externalsType',
32+
'externalsPresets',
33+
'ignoreWarnings',
34+
'stats',
35+
'preset',
36+
'advancedGlobal',
37+
'advancedAssets',
38+
'advancedChunkGroups',
39+
'advancedChunks',
40+
'advancedModules',
41+
'expertModules',
42+
'advancedStatsOptimization',
43+
'advancedOptimization',
44+
'cacheGroupAdvancedSelectors',
45+
'cacheGroupAdvancedEffects',
46+
'advancedSelectors',
47+
'advancedEffects',
48+
'fallbackCacheGroup',
49+
'advanced',
50+
'advancedCaching',
51+
'advancedBuild',
52+
];
53+
export const Pre = (props) => {
654
// eslint-disable-next-line
7-
const newChildren = Children.map(props.children.props.children, child => {
55+
const newChildren = Children.map(props.children.props.children, (child) => {
856
if (isValidElement(child)) {
957
if (child.props.className.includes('keyword')) {
10-
if (!detailComponentsList.includes(child.props.componentname)) return child;
11-
// eslint-disable-next-line
12-
return <Details children={child.props.children.slice(4, Children.count(child.props.children) - 4)} url={child.props.url} />;
58+
if (!detailComponentsList.includes(child.props.componentname))
59+
return child;
60+
return (
61+
<Details
62+
myChilds={child.props.children.slice(
63+
4,
64+
Children.count(child.props.children) - 4
65+
)}
66+
url={child.props.url}
67+
/>
68+
);
1369
}
1470
}
1571

1672
return child;
1773
});
1874

1975
const newProps = {
20-
children: newChildren
76+
children: newChildren,
2177
};
2278

2379
return (
@@ -26,6 +82,4 @@ export const Pre = props => {
2682
</pre>
2783
);
2884
};
29-
Pre.propTypes = {
30-
31-
};
85+
Pre.propTypes = {};

src/components/Configuration/components.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import PropTypes from 'prop-types';
55

66
const DEFAULT_CHILDREN_SIZE = 4;
77

8-
const isFirstChild = child => typeof child === 'string' && child !== ' ';
8+
const isFirstChild = (child) => typeof child === 'string' && child !== ' ';
99

10-
const removeSpaces = child => (isFirstChild(child) ? child.trim() : child);
10+
const removeSpaces = (child) => (isFirstChild(child) ? child.trim() : child);
1111

1212
const addLink = (child, i, url) => {
1313
return isFirstChild(child) ? (
@@ -28,17 +28,17 @@ const Card = ({ body }) => {
2828
);
2929
};
3030
Card.propTypes = {
31-
body: PropTypes.node
31+
body: PropTypes.node,
3232
};
3333
export class Details extends Component {
3434
static propTypes = {
3535
url: PropTypes.string,
36-
children: PropTypes.arrayOf(PropTypes.node)
37-
}
36+
myChilds: PropTypes.arrayOf(PropTypes.node),
37+
};
3838
constructor(props) {
3939
super(props);
4040
this.state = {
41-
open: false
41+
open: false,
4242
};
4343
}
4444

@@ -51,10 +51,10 @@ export class Details extends Component {
5151
};
5252

5353
render() {
54-
const { children, url } = this.props;
54+
const { myChilds, url } = this.props;
5555

5656
// Find the index of </default>
57-
const closeDefaultTagIndex = children.findIndex(child => {
57+
const closeDefaultTagIndex = myChilds.findIndex((child) => {
5858
if (isValidElement(child)) {
5959
return (
6060
child.props.className.includes('tag') &&
@@ -63,7 +63,7 @@ export class Details extends Component {
6363
}
6464
});
6565

66-
const content = children.slice();
66+
const content = myChilds.slice();
6767

6868
// Summary is the part of the snippet that would be shown in the code snippet,
6969
// to get it we need to cut the <default></default> enclosing tags
@@ -85,7 +85,7 @@ export class Details extends Component {
8585
content={<Card body={content} />}
8686
>
8787
<span
88-
className='code-details-summary-span'
88+
className="code-details-summary-span"
8989
onClick={this.toggleVisibility}
9090
>
9191
{summary}

src/components/Container/Container.jsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@ import './Container.scss';
22
import PropTypes from 'prop-types';
33
Container.propTypes = {
44
className: PropTypes.string,
5-
children: PropTypes.node
5+
children: PropTypes.node,
66
};
7-
export default function Container (props = {}) {
7+
export default function Container(props = {}) {
88
let { className = '' } = props;
99

10-
return (
11-
<div className={ `container ${className}` }>
12-
{ props.children }
13-
</div>
14-
);
10+
return <div className={`container ${className}`}>{props.children}</div>;
1511
}

src/components/Contributors/Contributors.jsx

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ import PropTypes from 'prop-types';
66

77
export default class Contributors extends Component {
88
static propTypes = {
9-
contributors: PropTypes.array
10-
}
9+
contributors: PropTypes.array,
10+
};
1111
state = {
12-
inView: false
13-
}
12+
inView: false,
13+
};
1414

1515
handleInView = (inView) => {
1616
if (!inView) {
1717
return;
1818
}
1919
this.setState({ inView });
20-
}
20+
};
2121

2222
render() {
2323
const { inView } = this.state;
@@ -28,23 +28,31 @@ export default class Contributors extends Component {
2828
}
2929

3030
return (
31-
<VisibilitySensor delayedCall
31+
<VisibilitySensor
32+
delayedCall
3233
partialVisibility
33-
intervalDelay={ 300 }
34-
onChange={ this.handleInView }>
34+
intervalDelay={300}
35+
onChange={this.handleInView}
36+
>
3537
<div className="contributors">
3638
<div className="contributors__list">
37-
{
38-
contributors.map(contributor => (
39-
<a key={ contributor }
40-
className="contributor"
41-
href={ `https://github.com/${contributor}` }>
42-
<img alt={ contributor }
43-
src={ inView ? `https://github.com/${contributor}.png?size=90` : SmallIcon } />
44-
<span className="contributor__name"> {contributor}</span>
45-
</a>
46-
))
47-
}
39+
{contributors.map((contributor) => (
40+
<a
41+
key={contributor}
42+
className="contributor"
43+
href={`https://github.com/${contributor}`}
44+
>
45+
<img
46+
alt={contributor}
47+
src={
48+
inView
49+
? `https://github.com/${contributor}.png?size=90`
50+
: SmallIcon
51+
}
52+
/>
53+
<span className="contributor__name"> {contributor}</span>
54+
</a>
55+
))}
4856
</div>
4957
</div>
5058
</VisibilitySensor>

0 commit comments

Comments
 (0)