Skip to content

Commit c674d65

Browse files
authored
feat: add prettier command (facebookincubator#83)
* feat: add prettier command (cherry picked from commit f47577a90c4f9210ecfbe34b491f7e618c04b6ca) * Update .prettierignore * Update .prettierrc
1 parent 8719ddc commit c674d65

31 files changed

+199
-220
lines changed

.prettierignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dist
2+
node_modules
3+
.yarn
4+
build
5+
coverage
6+
.docusaurus

.prettierrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": false,
4+
"jsxBracketSameLine": true,
5+
"printWidth": 80,
6+
"proseWrap": "never",
7+
"singleQuote": true,
8+
"trailingComma": "all"
9+
}

CODE_OF_CONDUCT.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Code of Conduct
2-
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.fb.com/codeofconduct) so that you can understand what actions will and will not be tolerated.
2+
3+
Facebook has adopted a Code of Conduct that we expect project participants to adhere to. Please [read the full text](https://code.fb.com/codeofconduct) so that you can understand what actions will and will not be tolerated.

CONTRIBUTING.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Contributing to Infima
2-
We want to make contributing to this project as easy and transparent as
3-
possible.
2+
3+
We want to make contributing to this project as easy and transparent as possible.
44

55
## Pull Requests
6+
67
We actively welcome your pull requests.
78

89
1. Fork the repo and create your branch from `master`.
@@ -13,19 +14,17 @@ We actively welcome your pull requests.
1314
6. If you haven't already, complete the Contributor License Agreement ("CLA").
1415

1516
## Contributor License Agreement ("CLA")
16-
In order to accept your pull request, we need you to submit a CLA. You only need
17-
to do this once to work on any of Facebook's open source projects.
17+
18+
In order to accept your pull request, we need you to submit a CLA. You only need to do this once to work on any of Facebook's open source projects.
1819

1920
Complete your CLA here: <https://code.facebook.com/cla>
2021

2122
## Issues
22-
We use GitHub issues to track public bugs. Please ensure your description is
23-
clear and has sufficient instructions to be able to reproduce the issue.
2423

25-
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
26-
disclosure of security bugs. In those cases, please go through the process
27-
outlined on that page and do not file a public issue.
24+
We use GitHub issues to track public bugs. Please ensure your description is clear and has sufficient instructions to be able to reproduce the issue.
25+
26+
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe disclosure of security bugs. In those cases, please go through the process outlined on that page and do not file a public issue.
2827

2928
## License
30-
By contributing to Infima, you agree that your contributions will be licensed
31-
under the LICENSE file in the root directory of this source tree.
29+
30+
By contributing to Infima, you agree that your contributions will be licensed under the LICENSE file in the root directory of this source tree.

package.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
],
99
"private": true,
1010
"scripts": {
11+
"prettier": "prettier --config .prettierrc --write \"**/*.{js,jsx,ts,tsx}\"",
12+
"prettier:docs": "prettier --config .prettierrc --write \"**/*.{md,mdx}\"",
1113
"start": "cd packages/core && npm start",
1214
"build": "yarn workspace infima build",
1315
"website:start": "yarn workspace infima-website start",
@@ -17,6 +19,15 @@
1719
},
1820
"devDependencies": {
1921
"husky": "^5.0.9",
20-
"is-ci": "^3.0.0"
22+
"is-ci": "^3.0.0",
23+
"prettier": "^2.2.1"
24+
},
25+
"lint-staged": {
26+
"*.{js,jsx,ts,tsx}": [
27+
"prettier --write"
28+
],
29+
"*.{md,mdx}": [
30+
"prettier --write"
31+
]
2132
}
2233
}

packages/core/dist/js/alerts.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
function alert($elements) {
9-
$elements.forEach($alert => {
9+
$elements.forEach(($alert) => {
1010
$alert.addEventListener('click', (e) => {
1111
if (e.target && e.target.classList.contains('close')) {
1212
$alert.remove();

packages/core/dist/js/alerts.min.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
function alert($elements) {
9-
$elements.forEach($alert => {
9+
$elements.forEach(($alert) => {
1010
$alert.addEventListener('click', (e) => {
1111
if (e.target && e.target.classList.contains('close')) {
1212
$alert.remove();

packages/core/dist/js/dropdowns.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
*/
77

88
function dropdowns($elements) {
9-
$elements.forEach($dropdown => {
9+
$elements.forEach(($dropdown) => {
1010
if ($dropdown.classList.contains('dropdown--hoverable')) {
1111
return;
1212
}
1313

1414
const $toggle = $dropdown.querySelector('[data-toggle="dropdown"]');
15-
$toggle.addEventListener('click', e => {
15+
$toggle.addEventListener('click', (e) => {
1616
function dismissDropdown() {
1717
$toggle.classList.remove('button--active');
1818
$dropdown.classList.remove('dropdown--show');

packages/core/dist/js/dropdowns.min.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
*/
77

88
function dropdowns($elements) {
9-
$elements.forEach($dropdown => {
9+
$elements.forEach(($dropdown) => {
1010
if ($dropdown.classList.contains('dropdown--hoverable')) {
1111
return;
1212
}
1313

1414
const $toggle = $dropdown.querySelector('[data-toggle="dropdown"]');
15-
$toggle.addEventListener('click', e => {
15+
$toggle.addEventListener('click', (e) => {
1616
function dismissDropdown() {
1717
$toggle.classList.remove('button--active');
1818
$dropdown.classList.remove('dropdown--show');

packages/core/dist/js/menu.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*/
77

88
function menu($elements) {
9-
$elements.forEach($menu => {
10-
$menu.addEventListener('click', event => {
9+
$elements.forEach(($menu) => {
10+
$menu.addEventListener('click', (event) => {
1111
let $listItem = event.target;
1212
while ($listItem) {
1313
if ($listItem.classList.contains('menu')) {
@@ -37,7 +37,7 @@ function menu($elements) {
3737

3838
$menu
3939
.querySelectorAll('.menu__link')
40-
.forEach($elItem => $elItem.classList.remove('menu__link--active'));
40+
.forEach(($elItem) => $elItem.classList.remove('menu__link--active'));
4141

4242
// Traverse parents and add active class.
4343
while ($listItem) {
@@ -58,7 +58,7 @@ function menu($elements) {
5858

5959
$button = $menu.querySelector('.menu__button');
6060
if ($button) {
61-
$button.addEventListener('click', e => {
61+
$button.addEventListener('click', (e) => {
6262
$menu.classList.toggle('menu--show');
6363
});
6464
}

packages/core/dist/js/menu.min.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*/
77

88
function menu($elements) {
9-
$elements.forEach($menu => {
10-
$menu.addEventListener('click', event => {
9+
$elements.forEach(($menu) => {
10+
$menu.addEventListener('click', (event) => {
1111
let $listItem = event.target;
1212
while ($listItem) {
1313
if ($listItem.classList.contains('menu')) {
@@ -37,7 +37,7 @@ function menu($elements) {
3737

3838
$menu
3939
.querySelectorAll('.menu__link')
40-
.forEach($elItem => $elItem.classList.remove('menu__link--active'));
40+
.forEach(($elItem) => $elItem.classList.remove('menu__link--active'));
4141

4242
// Traverse parents and add active class.
4343
while ($listItem) {
@@ -58,7 +58,7 @@ function menu($elements) {
5858

5959
$button = $menu.querySelector('.menu__button');
6060
if ($button) {
61-
$button.addEventListener('click', e => {
61+
$button.addEventListener('click', (e) => {
6262
$menu.classList.toggle('menu--show');
6363
});
6464
}

packages/core/dist/js/navbar.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
function navbar($elements) {
9-
$elements.forEach($navbar => {
9+
$elements.forEach(($navbar) => {
1010
// TODO: Use data-toggle approach.
1111
const $toggle = $navbar.querySelector('.navbar__toggle');
1212
const $sidebar = $navbar.querySelector('.navbar-sidebar');
@@ -17,12 +17,12 @@ function navbar($elements) {
1717
return;
1818
}
1919

20-
$toggle.addEventListener('click', e => {
20+
$toggle.addEventListener('click', (e) => {
2121
$navbar.classList.add('navbar-sidebar--show');
2222
});
2323

24-
[$backdrop, $sidebarClose].forEach($el =>
25-
$el.addEventListener('click', e => {
24+
[$backdrop, $sidebarClose].forEach(($el) =>
25+
$el.addEventListener('click', (e) => {
2626
$navbar.classList.remove('navbar-sidebar--show');
2727
}),
2828
);

packages/core/dist/js/navbar.min.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
function navbar($elements) {
9-
$elements.forEach($navbar => {
9+
$elements.forEach(($navbar) => {
1010
// TODO: Use data-toggle approach.
1111
const $toggle = $navbar.querySelector('.navbar__toggle');
1212
const $sidebar = $navbar.querySelector('.navbar-sidebar');
@@ -17,12 +17,12 @@ function navbar($elements) {
1717
return;
1818
}
1919

20-
$toggle.addEventListener('click', e => {
20+
$toggle.addEventListener('click', (e) => {
2121
$navbar.classList.add('navbar-sidebar--show');
2222
});
2323

24-
[$backdrop, $sidebarClose].forEach($el =>
25-
$el.addEventListener('click', e => {
24+
[$backdrop, $sidebarClose].forEach(($el) =>
25+
$el.addEventListener('click', (e) => {
2626
$navbar.classList.remove('navbar-sidebar--show');
2727
}),
2828
);

packages/core/dist/js/radio-behavior.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
function makeRadioBehavior(eventName, itemClass, activeItemClass) {
99
return function radioBehavior($elements) {
10-
$elements.forEach($element => {
11-
$element.addEventListener(eventName, event => {
10+
$elements.forEach(($element) => {
11+
$element.addEventListener(eventName, (event) => {
1212
if (event.target && event.target.classList.contains(itemClass)) {
13-
$element.querySelectorAll('.' + itemClass).forEach($elItem =>
14-
$elItem.classList.remove(activeItemClass)
15-
);
13+
$element
14+
.querySelectorAll('.' + itemClass)
15+
.forEach(($elItem) => $elItem.classList.remove(activeItemClass));
1616
event.target.classList.add(activeItemClass);
1717
}
1818
});
1919
});
20-
}
20+
};
2121
}

packages/core/dist/js/radio-behavior.min.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
function makeRadioBehavior(eventName, itemClass, activeItemClass) {
99
return function radioBehavior($elements) {
10-
$elements.forEach($element => {
11-
$element.addEventListener(eventName, event => {
10+
$elements.forEach(($element) => {
11+
$element.addEventListener(eventName, (event) => {
1212
if (event.target && event.target.classList.contains(itemClass)) {
13-
$element.querySelectorAll('.' + itemClass).forEach($elItem =>
14-
$elItem.classList.remove(activeItemClass)
15-
);
13+
$element
14+
.querySelectorAll('.' + itemClass)
15+
.forEach(($elItem) => $elItem.classList.remove(activeItemClass));
1616
event.target.classList.add(activeItemClass);
1717
}
1818
});
1919
});
20-
}
20+
};
2121
}

packages/core/gulpfile.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function transformStyles() {
2626
'**/_*/**', // Exclude entire directories starting with '_'.
2727
],
2828
})
29-
.pipe(postcss(modernPreset.plugins, { syntax: modernPreset.syntax }))
29+
.pipe(postcss(modernPreset.plugins, {syntax: modernPreset.syntax}))
3030
.pipe(gulp.dest('./dist/css'));
3131
}
3232

@@ -46,15 +46,15 @@ function transformScripts() {
4646
function minifyStyles() {
4747
return gulp
4848
.src('./dist/css/**/*.css')
49-
.pipe(rename({ suffix: '.min' }))
49+
.pipe(rename({suffix: '.min'}))
5050
.pipe(postcss([cssnano()]))
5151
.pipe(gulp.dest('./dist/css'));
5252
}
5353

5454
function minifyScripts() {
5555
return gulp
5656
.src('./dist/js/**/*.js')
57-
.pipe(rename({ suffix: '.min' }))
57+
.pipe(rename({suffix: '.min'}))
5858
.pipe(gulp.dest('./dist/js'));
5959
}
6060

@@ -79,7 +79,10 @@ function clean() {
7979
return del(['./dist/**/*', './demo/css/**', './demo/js/**']);
8080
}
8181

82-
const transformAssets = gulp.parallel(gulp.series(transformStyles, createRtlStyles), transformScripts);
82+
const transformAssets = gulp.parallel(
83+
gulp.series(transformStyles, createRtlStyles),
84+
transformScripts,
85+
);
8386
const copyAssetsToDemo = gulp.parallel(copyStylesToDemo, copyScriptsToDemo);
8487
const minifyAssets = gulp.parallel(minifyStyles, minifyScripts);
8588
const transformAndCopy = gulp.series(transformAssets, copyAssetsToDemo);

packages/core/js/alerts.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
function alert($elements) {
9-
$elements.forEach($alert => {
9+
$elements.forEach(($alert) => {
1010
$alert.addEventListener('click', (e) => {
1111
if (e.target && e.target.classList.contains('close')) {
1212
$alert.remove();

packages/core/js/dropdowns.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
*/
77

88
function dropdowns($elements) {
9-
$elements.forEach($dropdown => {
9+
$elements.forEach(($dropdown) => {
1010
if ($dropdown.classList.contains('dropdown--hoverable')) {
1111
return;
1212
}
1313

1414
const $toggle = $dropdown.querySelector('[data-toggle="dropdown"]');
15-
$toggle.addEventListener('click', e => {
15+
$toggle.addEventListener('click', (e) => {
1616
function dismissDropdown() {
1717
$toggle.classList.remove('button--active');
1818
$dropdown.classList.remove('dropdown--show');

packages/core/js/menu.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*/
77

88
function menu($elements) {
9-
$elements.forEach($menu => {
10-
$menu.addEventListener('click', event => {
9+
$elements.forEach(($menu) => {
10+
$menu.addEventListener('click', (event) => {
1111
let $listItem = event.target;
1212
while ($listItem) {
1313
if ($listItem.classList.contains('menu')) {
@@ -37,7 +37,7 @@ function menu($elements) {
3737

3838
$menu
3939
.querySelectorAll('.menu__link')
40-
.forEach($elItem => $elItem.classList.remove('menu__link--active'));
40+
.forEach(($elItem) => $elItem.classList.remove('menu__link--active'));
4141

4242
// Traverse parents and add active class.
4343
while ($listItem) {
@@ -58,7 +58,7 @@ function menu($elements) {
5858

5959
$button = $menu.querySelector('.menu__button');
6060
if ($button) {
61-
$button.addEventListener('click', e => {
61+
$button.addEventListener('click', (e) => {
6262
$menu.classList.toggle('menu--show');
6363
});
6464
}

0 commit comments

Comments
 (0)