diff --git a/.eslintrc.js b/.eslintrc.js index 152622784940..7223f8117ea1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -16,53 +16,23 @@ module.exports = { 'no-console': OFF, // require radix argument in parseInt radix: ERROR, + 'class-methods-use-this': OFF, + 'react/no-multi-comp': OFF, + 'import/no-extraneous-dependencies': OFF, + 'react/no-danger': OFF, + 'no-empty': [ERROR, {allowEmptyCatch: true}], + // Existing ESLint errors sorted by frequency, silencing first. 'react/button-has-type': OFF, // 1 - null: OFF, // 1 - 'react/no-unused-state': OFF, // 1 - 'vars-on-top': OFF, // 1 'react/forbid-prop-types': OFF, // 1 'react/require-default-props': OFF, // 1 - 'lines-between-class-members': OFF, // 1 - strict: OFF, // 1 - 'no-restricted-syntax': OFF, // 1 - 'no-path-concat': OFF, // 2 - 'one-var': OFF, // 2 - 'no-unused-expressions': OFF, // 2 - 'react/jsx-boolean-value': OFF, // 2 - 'jsx-a11y/html-has-lang': OFF, // 2 - 'no-var': OFF, // 2 - 'no-useless-return': OFF, // 2 - 'jsx-a11y/anchor-has-content': OFF, // 2 - 'react/jsx-no-comment-textnodes': OFF, // 3 - 'no-continue': OFF, // 3 - 'jsx-a11y/alt-text': OFF, // 3 - 'react/jsx-tag-spacing': OFF, // 3 - 'no-lonely-if': OFF, // 3 - 'react/sort-comp': OFF, // 4 - 'no-cond-assign': OFF, // 4 - 'no-use-before-define': OFF, // 4 - 'no-empty': OFF, // 4 - 'no-shadow': OFF, // 4 - 'class-methods-use-this': OFF, // 5 - eqeqeq: OFF, // 5 - 'react/no-multi-comp': OFF, // 5 - 'react/no-array-index-key': OFF, // 6 - 'no-underscore-dangle': OFF, // 6 - 'array-callback-return': OFF, // 6 - 'import/no-extraneous-dependencies': OFF, // 7 - 'no-else-return': OFF, // 9 'jsx-a11y/anchor-is-valid': OFF, // 9 - 'import/order': OFF, // 10 'arrow-body-style': OFF, // 10 - camelcase: OFF, // 10 'react/jsx-curly-brace-presence': OFF, // 11 'react/no-unescaped-entities': OFF, // 12 'no-param-reassign': OFF, // 12 - 'no-unused-vars': OFF, // 13 'spaced-comment': OFF, // 14 'import/no-unresolved': OFF, // 15 - 'react/no-danger': OFF, // 16 'object-shorthand': OFF, // 16 'dot-notation': OFF, // 19 'react/prefer-stateless-function': OFF, // 22 diff --git a/examples/basics/core/Footer.js b/examples/basics/core/Footer.js index 22d90f1492ef..41fbc0ff6f78 100644 --- a/examples/basics/core/Footer.js +++ b/examples/basics/core/Footer.js @@ -72,7 +72,7 @@ class Footer extends React.Component { href={this.props.config.repoUrl} data-icon="octicon-star" data-count-href="/facebook/docusaurus/stargazers" - data-show-count={true} + data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star this project on GitHub"> Star diff --git a/examples/basics/pages/en/index.js b/examples/basics/pages/en/index.js index d6db81ee8f65..0afae4234ebe 100755 --- a/examples/basics/pages/en/index.js +++ b/examples/basics/pages/en/index.js @@ -52,11 +52,11 @@ const SplashContainer = props => ( const Logo = props => (
- + Project Logo
); -const ProjectTitle = props => ( +const ProjectTitle = () => (

{siteConfig.title} {siteConfig.tagline} @@ -99,7 +99,7 @@ const Block = props => ( ); -const Features = props => ( +const Features = () => ( {[ { @@ -118,7 +118,7 @@ const Features = props => ( ); -const FeatureCallout = props => ( +const FeatureCallout = () => (
@@ -127,7 +127,7 @@ const FeatureCallout = props => (
); -const LearnHow = props => ( +const LearnHow = () => ( {[ { @@ -140,7 +140,7 @@ const LearnHow = props => ( ); -const TryOut = props => ( +const TryOut = () => ( {[ { @@ -153,7 +153,7 @@ const TryOut = props => ( ); -const Description = props => ( +const Description = () => ( {[ { @@ -170,21 +170,16 @@ const Showcase = props => { if ((siteConfig.users || []).length === 0) { return null; } - const showcase = siteConfig.users - .filter(user => { - return user.pinned; - }) - .map((user, i) => { - return ( - - {user.caption} - - ); - }); + + const showcase = siteConfig.users.filter(user => user.pinned).map(user => ( + + {user.caption} + + )); return (
-

{"Who's Using This?"}

+

Who's Using This?

This project is used by all these people

{showcase}
diff --git a/examples/basics/pages/en/users.js b/examples/basics/pages/en/users.js index c113bf5c7264..458eb9757094 100644 --- a/examples/basics/pages/en/users.js +++ b/examples/basics/pages/en/users.js @@ -17,14 +17,13 @@ class Users extends React.Component { if ((siteConfig.users || []).length === 0) { return null; } + const editUrl = siteConfig.repoUrl + '/edit/master/website/siteConfig.js'; - const showcase = siteConfig.users.map((user, i) => { - return ( - - {user.caption} - - ); - }); + const showcase = siteConfig.users.map(user => ( + + {user.caption} + + )); return (
diff --git a/lib/__tests__/build-files.test.js b/lib/__tests__/build-files.test.js index 9a0048359b8b..7651848fe561 100644 --- a/lib/__tests__/build-files.test.js +++ b/lib/__tests__/build-files.test.js @@ -52,7 +52,6 @@ beforeAll(() => { inputAssetsFiles, outputAssetsFiles, ] = results; - return; }); }); diff --git a/lib/core/BlogPageLayout.js b/lib/core/BlogPageLayout.js index 588bf0c6d609..6c1d07d179b7 100644 --- a/lib/core/BlogPageLayout.js +++ b/lib/core/BlogPageLayout.js @@ -5,11 +5,11 @@ * LICENSE file in the root directory of this source tree. */ +const React = require('react'); const BlogPost = require('./BlogPost.js'); const BlogSidebar = require('./BlogSidebar.js'); const Container = require('./Container.js'); const MetadataBlog = require('./MetadataBlog.js'); -const React = require('react'); const Site = require('./Site.js'); const utils = require('./utils.js'); @@ -46,7 +46,7 @@ class BlogPageLayout extends React.Component { - - {post.author} - -
- ); - } else if (post.authorImageURL) { + if (post.authorFBID || post.authorImageURL) { + const authorImageURL = post.authorFBID + ? `https://graph.facebook.com/${ + post.authorFBID + }/picture/?height=200&width=200` + : post.authorImageURL; return (
- + {post.author}
); - } else { - return null; } + return null; } renderTitle() { diff --git a/lib/core/BlogPostLayout.js b/lib/core/BlogPostLayout.js index 799ae3e60253..aa58b55b9a58 100644 --- a/lib/core/BlogPostLayout.js +++ b/lib/core/BlogPostLayout.js @@ -5,19 +5,31 @@ * LICENSE file in the root directory of this source tree. */ +const classNames = require('classnames'); const React = require('react'); + const BlogPost = require('./BlogPost.js'); const BlogSidebar = require('./BlogSidebar.js'); const Container = require('./Container.js'); const Site = require('./Site.js'); const OnPageNav = require('./nav/OnPageNav.js'); const utils = require('./utils.js'); -const classNames = require('classnames'); // used for entire blog posts, i.e., each written blog article with sidebar with site header/footer class BlogPostLayout extends React.Component { + getDescription() { + const descLines = this.props.children.trim().split('\n'); + for (let i = 0; i < descLines.length; i++) { + // Don't want blank lines or descriptions that are raw image rendering strings. + if (descLines[i] && !descLines[i].startsWith('![')) { + return descLines[i]; + } + } + return null; + } + renderSocialButtons() { - let post = this.props.metadata; + const post = this.props.metadata; post.path = utils.getPath(post.path, this.props.config.cleanUrl); const fbComment = this.props.config.facebookAppId && @@ -72,8 +84,9 @@ class BlogPostLayout extends React.Component { } data-related={this.props.config.twitter} data-via={post.authorTwitter} - data-show-count="false" - /> + data-show-count="false"> + Tweet +
); @@ -86,17 +99,6 @@ class BlogPostLayout extends React.Component { ); } - getDescription() { - const descLines = this.props.children.trim().split('\n'); - for (var i = 0; i < descLines.length; i++) { - // Don't want blank lines or descriptions that are raw image rendering strings - if (descLines[i] && !descLines[i].startsWith('![')) { - return descLines[i]; - } - } - return null; - } - render() { const hasOnPageNav = this.props.config.onPageNav === 'separate'; const post = this.props.metadata; diff --git a/lib/core/BlogSidebar.js b/lib/core/BlogSidebar.js index 5cdd2f1afea1..c730b14128ce 100644 --- a/lib/core/BlogSidebar.js +++ b/lib/core/BlogSidebar.js @@ -17,7 +17,7 @@ class BlogSidebar extends React.Component { let blogSidebarTitleConfig = this.props.config.blogSidebarTitle || {}; let blogSidebarTitle = blogSidebarTitleConfig.default || 'Recent Posts'; if (this.props.config.blogSidebarCount) { - if (this.props.config.blogSidebarCount == 'ALL') { + if (this.props.config.blogSidebarCount === 'ALL') { blogSidebarCount = MetadataBlog.length; blogSidebarTitle = blogSidebarTitleConfig.all || 'All Blog Posts'; } else { diff --git a/lib/core/Doc.js b/lib/core/Doc.js index 941078f88cd4..a9b0c7ee58cc 100644 --- a/lib/core/Doc.js +++ b/lib/core/Doc.js @@ -43,7 +43,7 @@ class Doc extends React.Component { // If internationalization is enabled, show Recruiting link instead of Edit Link. if ( this.props.language && - this.props.language != 'en' && + this.props.language !== 'en' && this.props.config.translationRecruitingLink ) { editLink = ( diff --git a/lib/core/DocsLayout.js b/lib/core/DocsLayout.js index d75336f01682..89b47198c04c 100644 --- a/lib/core/DocsLayout.js +++ b/lib/core/DocsLayout.js @@ -5,16 +5,17 @@ * LICENSE file in the root directory of this source tree. */ +const classNames = require('classnames'); +const path = require('path'); const React = require('react'); +const url = require('url'); + const Container = require('./Container.js'); const Doc = require('./Doc.js'); const DocsSidebar = require('./DocsSidebar.js'); const OnPageNav = require('./nav/OnPageNav.js'); const Site = require('./Site.js'); const translation = require('../server/translation.js'); -const classNames = require('classnames'); -const path = require('path'); -const url = require('url'); // component used to generate whole webpage for docs, including sidebar/header/footer class DocsLayout extends React.Component { diff --git a/lib/core/GridBlock.js b/lib/core/GridBlock.js index 8d728dd9c302..612dd90a15bf 100755 --- a/lib/core/GridBlock.js +++ b/lib/core/GridBlock.js @@ -48,37 +48,33 @@ class GridBlock extends React.Component { } renderBlockImage(image, imageLink, imageAlt) { - if (image) { - if (imageLink) { - return ( -
- - {imageAlt} - -
- ); - } else { - return ( -
- {imageAlt} -
- ); - } - } else { + if (!image) { return null; } + + return ( +
+ {imageLink ? ( + + {imageAlt} + + ) : ( + {imageAlt} + )} +
+ ); } renderBlockTitle(title) { - if (title) { - return ( -

- {title} -

- ); - } else { + if (!title) { return null; } + + return ( +

+ {title} +

+ ); } render() { diff --git a/lib/core/Head.js b/lib/core/Head.js index 7d61786f50be..e8bfaad84225 100644 --- a/lib/core/Head.js +++ b/lib/core/Head.js @@ -11,10 +11,7 @@ const React = require('react'); class Head extends React.Component { render() { const links = this.props.config.headerLinks; - let hasBlog = false; - links.map(link => { - if (link.blog) hasBlog = true; - }); + const hasBlog = links.some(link => link.blog); let highlight = { version: '9.12.0', @@ -137,21 +134,13 @@ class Head extends React.Component { {/* External resources */} {this.props.config.stylesheets && - this.props.config.stylesheets.map(function(source, idx) { - return ( - - ); - })} + this.props.config.stylesheets.map(source => ( + + ))} {this.props.config.scripts && - this.props.config.scripts.map(function(source, idx) { - return ( -