Skip to content

Commit

Permalink
Format the codebase using Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
moroshko committed Apr 21, 2017
1 parent def0fd4 commit df1655c
Show file tree
Hide file tree
Showing 32 changed files with 493 additions and 297 deletions.
46 changes: 8 additions & 38 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,17 @@ module.exports = {
mocha: true
},
parser: 'babel-eslint',
plugins: [
'react'
],
extends: [
'eslint:recommended'
],
plugins: ['react'],
extends: ['eslint:recommended'],
rules: {
'array-callback-return': 2,
'brace-style': [2, '1tbs'],
'camelcase': [2, { 'properties': 'always' }],
'comma-dangle': [2, 'never'],
'comma-style': [2, 'last'],
'eol-last': 2,
'func-call-spacing': 2,
'indent': [2, 2, { 'SwitchCase': 1 }],
'key-spacing': [2, { 'beforeColon': false, 'afterColon': true }],
'keyword-spacing': 2,
camelcase: [2, { properties: 'always' }],
'linebreak-style': [2, 'unix'],
'no-cond-assign': [2, 'always'],
'no-console': 2,
'no-global-assign': 2,
'no-multiple-empty-lines': [2, { 'max': 1 }],
'no-restricted-properties': [2,
'no-restricted-properties': [
2,
{
object: 'describe',
property: 'only',
Expand All @@ -51,20 +39,10 @@ module.exports = {
}
],
'no-template-curly-in-string': 2,
'no-trailing-spaces': 2,
'no-unused-vars': 2,
'no-whitespace-before-property': 2,
'newline-after-var': [2, 'always'],
'object-curly-spacing': [2, 'always'],
'prefer-destructuring': [2, { array: false, object: true }],
'prefer-rest-params': 2,
'quote-props': [2, 'as-needed'],
'quotes': [2, 'single'],
'semi': [2, 'always'],
'space-before-blocks': [2, 'always'],
'space-before-function-paren': [2, 'never'],
'space-in-parens': [2, 'never'],
'template-curly-spacing': [2, 'never'],

'react/display-name': 0,
'react/forbid-prop-types': 0,
Expand All @@ -77,7 +55,7 @@ module.exports = {
'react/no-direct-mutation-state': 2,
'react/no-find-dom-node': 2,
'react/no-is-mounted': 2,
'react/no-multi-comp': [2, { 'ignoreStateless': true }],
'react/no-multi-comp': [2, { ignoreStateless: true }],
'react/no-render-return-value': 2,
'react/no-set-state': 0,
'react/no-string-refs': 2,
Expand All @@ -95,14 +73,8 @@ module.exports = {
'react/style-prop-object': 2,

'react/jsx-boolean-value': [2, 'always'],
'react/jsx-closing-bracket-location': [2, 'tag-aligned'],
'react/jsx-curly-spacing': [2, 'never', { 'allowMultiline': true }],
'react/jsx-equals-spacing': [2, 'never'],
'react/jsx-filename-extension': [2, { 'extensions': ['.js'] }],
'react/jsx-first-prop-new-line': [2, 'multiline'],
'react/jsx-filename-extension': [2, { extensions: ['.js'] }],
'react/jsx-handler-names': 0,
'react/jsx-indent': [2, 2],
'react/jsx-indent-props': [2, 2],
'react/jsx-key': 2,
'react/jsx-max-props-per-line': 0,
'react/jsx-no-bind': 2,
Expand All @@ -112,9 +84,7 @@ module.exports = {
'react/jsx-no-undef': 2,
'react/jsx-pascal-case': 2,
'react/jsx-sort-props': 0,
'react/jsx-space-before-closing': [2, 'always'],
'react/jsx-uses-react': 2,
'react/jsx-uses-vars': 2,
'react/jsx-wrap-multilines': 2
'react/jsx-uses-vars': 2
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ const getSuggestions = value => {

const getSuggestionValue = suggestion => suggestion.name;

const renderSuggestion = suggestion => (
<span>{suggestion.name}</span>
);
const renderSuggestion = suggestion => <span>{suggestion.name}</span>;

export default class Basic extends Component {
constructor() {
Expand Down Expand Up @@ -58,7 +56,7 @@ export default class Basic extends Component {
render() {
const { value, suggestions } = this.state;
const inputProps = {
placeholder: 'Type \'c\'',
placeholder: "Type 'c'",
value,
onChange: this.onChange
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const getSuggestions = value => {
return people.filter(person => regex.test(getSuggestionValue(person)));
};

const getSuggestionValue = suggestion => `${suggestion.first} ${suggestion.last}`;
const getSuggestionValue = suggestion =>
`${suggestion.first} ${suggestion.last}`;

const renderSuggestion = (suggestion, { query }) => {
const suggestionText = `${suggestion.first} ${suggestion.last}`;
Expand All @@ -34,15 +35,11 @@ const renderSuggestion = (suggestion, { query }) => {
return (
<span className={theme.suggestionContent + ' ' + theme[suggestion.twitter]}>
<span className={theme.name}>
{
parts.map((part, index) => {
const className = part.highlight ? theme.highlight : null;

return (
<span className={className} key={index}>{part.text}</span>
);
})
}
{parts.map((part, index) => {
const className = part.highlight ? theme.highlight : null;

return <span className={className} key={index}>{part.text}</span>;
})}
</span>
</span>
);
Expand Down Expand Up @@ -83,7 +80,7 @@ export default class CustomRender extends Component {
render() {
const { value, suggestions } = this.state;
const inputProps = {
placeholder: 'Type \'c\'',
placeholder: "Type 'c'",
value,
onChange: this.onChange
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,19 @@ const getSuggestions = value => {
.map(section => {
return {
title: section.title,
languages: section.languages.filter(language => regex.test(language.name))
languages: section.languages.filter(language =>
regex.test(language.name)
)
};
})
.filter(section => section.languages.length > 0);
};

const getSuggestionValue = suggestion => suggestion.name;

const renderSuggestion = suggestion => (
<span>{suggestion.name}</span>
);
const renderSuggestion = suggestion => <span>{suggestion.name}</span>;

const renderSectionTitle = section => (
<strong>{section.title}</strong>
);
const renderSectionTitle = section => <strong>{section.title}</strong>;

const getSectionSuggestions = section => section.languages;

Expand Down Expand Up @@ -72,7 +70,7 @@ export default class MultipleSections extends Component {
render() {
const { value, suggestions } = this.state;
const inputProps = {
placeholder: 'Type \'c\'',
placeholder: "Type 'c'",
value,
onChange: this.onChange
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ export default class ScrollableContainer extends Component {
contentLabel="Modal"
onRequestClose={this.closeModal}
shouldCloseOnOverlayClick={false}
closeTimeoutMS={1/* otherwise the modal is not closed when suggestion is selected by pressing Enter */}
closeTimeoutMS={
1 /* otherwise the modal is not closed when suggestion is selected by pressing Enter */
}
style={modalStyle}
>
<div className={styles.modalTitle}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export default [
},
{
code: 'ci',
name: 'Cote d\'Ivoire'
name: "Cote d'Ivoire"
},
{
code: 'hr',
Expand Down Expand Up @@ -469,7 +469,7 @@ export default [
},
{
code: 'kp',
name: 'Korea, Democratic People\'s Republic of'
name: "Korea, Democratic People's Republic of"
},
{
code: 'kr',
Expand All @@ -485,7 +485,7 @@ export default [
},
{
code: 'la',
name: 'Lao People\'s Democratic Republic'
name: "Lao People's Democratic Republic"
},
{
code: 'lv',
Expand Down
18 changes: 15 additions & 3 deletions demo/src/components/App/components/GitHub/GitHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,23 @@ const GitHub = props => {
const { user, repo } = props;

return (
<a className={styles.corner} href={`https://github.com/${user}/${repo}`} target="_blank" rel="noopener noreferrer">
<a
className={styles.corner}
href={`https://github.com/${user}/${repo}`}
target="_blank"
rel="noopener noreferrer"
>
<svg className={styles.svg} width="80" height="80" viewBox="0 0 250 250">
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z" />
<path className={styles.octoArm} d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" />
<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" />
<path
className={styles.octoArm}
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
fill="currentColor"
/>
<path
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
fill="currentColor"
/>
</svg>
</a>
);
Expand Down
4 changes: 1 addition & 3 deletions demo/src/components/utils/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions#Using_special_characters
const escapeRegexCharacters = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');

export {
escapeRegexCharacters
};
export { escapeRegexCharacters };
5 changes: 1 addition & 4 deletions demo/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ import App from 'App/App';

es6promise.polyfill(); // Required, because `Promise` is undefined in IE.

render(
<App />,
document.getElementById('demo')
);
render(<App />, document.getElementById('demo'));
7 changes: 3 additions & 4 deletions demo/standalone/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ const getSuggestions = value => {

const getSuggestionValue = suggestion => suggestion.name;

const renderSuggestion = suggestion => (
<span>{suggestion.name}</span>
);
const renderSuggestion = suggestion => <span>{suggestion.name}</span>;

// prettier-ignore
class App extends React.Component { // eslint-disable-line no-undef
constructor() {
super();
Expand Down Expand Up @@ -111,7 +110,7 @@ class App extends React.Component { // eslint-disable-line no-undef
render() {
const { value, suggestions } = this.state;
const inputProps = {
placeholder: 'Type \'c\'',
placeholder: "Type 'c'",
value,
onChange: this.onChange
};
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
"author": "Misha Moroshko <[email protected]>",
"scripts": {
"start": "mkdir -p demo/dist && npm run copy-static-files && node server",
"prettier": "prettier --single-quote --write \".*.js\" \"*.js\" \"demo/src/**/*.js\" \"demo/standalone/app.js\" \"src/**/*.js\" \"test/**/*.js\"",
"lint": "eslint src test demo/src demo/standalone/app.js server.js webpack.*.js",
"test": "nyc mocha \"test/**/*.test.js\"",
"copy-static-files": "cp demo/src/index.html demo/src/components/App/components/Examples/components/Basic/autosuggest.css demo/dist/",
"dist": "rm -rf dist && mkdir dist && babel src -d dist",
"demo-dist": "rm -rf demo/dist && mkdir demo/dist && npm run copy-static-files && cross-env BABEL_ENV=production webpack --config webpack.gh-pages.config.js",
"standalone": "cross-env BABEL_ENV=production webpack --config webpack.standalone.config.js && webpack --config webpack.standalone-demo.config.js",
"prebuild": "npm run lint && npm test",
"prebuild": "npm run prettier && npm run lint && npm test",
"build": "npm run dist && npm run standalone",
"gh-pages-build": "npm run prebuild && npm run demo-dist",
"postversion": "git push && git push --tags",
Expand Down Expand Up @@ -60,6 +61,7 @@
"nyc": "^10.1.2",
"openurl": "^1.1.1",
"postcss-loader": "^1.3.3",
"prettier": "^1.2.2",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-modal": "^1.7.7",
Expand Down
Loading

0 comments on commit df1655c

Please sign in to comment.