diff --git a/.eslintignore b/.eslintignore index 3a4f3989dbcdf..e6c2203b7bb13 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,2 @@ -interfaces \ No newline at end of file +interfaces +**/__tests__/fixtures/ diff --git a/.eslintrc b/.eslintrc index 6ecc7c48c5e5e..960579931c9e8 100644 --- a/.eslintrc +++ b/.eslintrc @@ -69,5 +69,20 @@ "ignore": ["children"] } ] - } + }, + "overrides": [ + { + "files": [ + "packages/**/gatsby-browser.js", + "pacakges/gatsby/cache-dir/**/*" + ], + "env": { + "browser": true + }, + "globals": { + "___loader": false, + "___emitter": false + } + } + ] } diff --git a/.travis.yml b/.travis.yml index 15d374da163f3..24e4651bcd3a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,4 +17,4 @@ install: - yarn run bootstrap script: - - npm test + - yarn test diff --git a/examples/using-gatsby-image/src/pages/index.js b/examples/using-gatsby-image/src/pages/index.js index c4046c236cc4c..74b2be6e084b7 100644 --- a/examples/using-gatsby-image/src/pages/index.js +++ b/examples/using-gatsby-image/src/pages/index.js @@ -26,7 +26,7 @@ class IndexComponent extends React.Component {

gatsby-image - {" "} + {` `} is the official Image component for use in building Gatsby websites. It provides the fastest, most optimized image loading performance possible for Gatsby (and other React) websites. @@ -39,7 +39,7 @@ class IndexComponent extends React.Component {

See the site source - {" "} + {` `} on how to start using gatsby-image on your site. Full documentation coming soon.

diff --git a/package.json b/package.json index 41d99e75ae713..5a0231eb0dc8a 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "format-scripts": "prettier-eslint --write \"scripts/**/*.js\"", "format-www": "prettier-eslint --write \"www/*.js\" \"www/src/**/*.js\"", "lerna": "lerna", - "lint": "npm run check-versions && eslint --ext .js,.jsx --ignore-path .gitignore .", + "lint": "eslint --ext .js,.jsx packages/**/src", "lint:flow": "babel-node scripts/flow-check.js", "plop": "plop", "bootstrap": "yarn && npm run check-versions && lerna run prepublish", @@ -56,7 +56,7 @@ "publish-canary": "lerna publish --canary --yes", "publish-next": "lerna publish --npm-tag=next", "remotedev": "remotedev --hostname=localhost --port=19999", - "test": "jest", + "test": "yarn run lint && jest", "test:update": "jest --updateSnapshot", "test:watch": "jest --watch", "test_bkup": "npm run lint && npm run test-node && npm run test-integration", diff --git a/packages/gatsby-dev-cli/src/watch.js b/packages/gatsby-dev-cli/src/watch.js index 4db686cee6baa..47d87cf287703 100644 --- a/packages/gatsby-dev-cli/src/watch.js +++ b/packages/gatsby-dev-cli/src/watch.js @@ -13,7 +13,8 @@ const debouncedQuit = _.debounce(() => { const copyPath = (oldPath, newPath, quiet) => { fs.copy(oldPath, newPath, err => { if (err) { - return console.error(err) + console.error(err) + return } numCopied += 1 @@ -28,7 +29,7 @@ function watch(root, packages, { scanOnce, quiet }) { const prefix = syspath.join(root, `/packages/`, p) const ignoreRegs = [ - /[\/\\]node_modules[\/\\]/i, + /[/\\]node_modules[/\\]/i, /\.git/i, new RegExp(`${p}[\\/\\\\]src[\\/\\\\]`, `i`), ] diff --git a/packages/gatsby-image/.eslintrc b/packages/gatsby-image/.eslintrc new file mode 100644 index 0000000000000..5c9fc4c255341 --- /dev/null +++ b/packages/gatsby-image/.eslintrc @@ -0,0 +1,2 @@ +env: + browser: true diff --git a/packages/gatsby-image/src/index.js b/packages/gatsby-image/src/index.js index 01740af2656c5..aa5dd5e57a791 100644 --- a/packages/gatsby-image/src/index.js +++ b/packages/gatsby-image/src/index.js @@ -49,7 +49,7 @@ const Img = props => { Img.propTypes = { opacity: PropTypes.number, - onLoad: PropTypes.func + onLoad: PropTypes.func, } class Image extends React.Component { diff --git a/packages/gatsby-link/.eslintrc b/packages/gatsby-link/.eslintrc new file mode 100644 index 0000000000000..6f3b6683ff79e --- /dev/null +++ b/packages/gatsby-link/.eslintrc @@ -0,0 +1,4 @@ +env: + browser: true +globals: + ___loader: false diff --git a/packages/gatsby-link/src/__tests__/index.js b/packages/gatsby-link/src/__tests__/index.js index 3ccbc7629320d..dbc70acff3916 100644 --- a/packages/gatsby-link/src/__tests__/index.js +++ b/packages/gatsby-link/src/__tests__/index.js @@ -1,5 +1,3 @@ -import React from "react" - const getInstance = (props, pathPrefix = ``) => { Object.assign(global.window, { __PREFIX_PATHS__: pathPrefix ? true : false, diff --git a/packages/gatsby-link/src/index.js b/packages/gatsby-link/src/index.js index 2c58f5c435024..1560cfbdb2fd9 100644 --- a/packages/gatsby-link/src/index.js +++ b/packages/gatsby-link/src/index.js @@ -28,11 +28,6 @@ class GatsbyLink extends React.Component { to: normalizePath(pathPrefix + props.to), } } - propTypes: { - ...NavLinkPropTypes, - to: PropTypes.string.isRequired, - onClick: PropTypes.func, - } componentWillReceiveProps(nextProps) { if (this.props.to !== nextProps.to) { @@ -49,16 +44,19 @@ class GatsbyLink extends React.Component { render() { const { onClick, ...rest } = this.props + let El if (Object.keys(NavLinkPropTypes).some(propName => this.props[propName])) { - var El = NavLink + El = NavLink } else { - var El = Link + El = Link } return ( { + // eslint-disable-line onClick && onClick(e) + if ( e.button === 0 && // ignore right clicks !this.props.target && // let browser handle "target=_blank" @@ -104,6 +102,12 @@ class GatsbyLink extends React.Component { } } +GatsbyLink.propTypes = { + ...NavLinkPropTypes, + to: PropTypes.string.isRequired, + onClick: PropTypes.func, +} + GatsbyLink.contextTypes = { router: PropTypes.object, } diff --git a/packages/gatsby-module-loader/src/patch.js b/packages/gatsby-module-loader/src/patch.js index d4383d2e52ab2..9f6595f4aa1d4 100644 --- a/packages/gatsby-module-loader/src/patch.js +++ b/packages/gatsby-module-loader/src/patch.js @@ -1,3 +1,4 @@ +/* global document: false, __webpack_require__: false */ patch() function patch() { diff --git a/packages/gatsby-plugin-catch-links/.eslintrc b/packages/gatsby-plugin-catch-links/.eslintrc new file mode 100644 index 0000000000000..5c9fc4c255341 --- /dev/null +++ b/packages/gatsby-plugin-catch-links/.eslintrc @@ -0,0 +1,2 @@ +env: + browser: true diff --git a/packages/gatsby-plugin-glamor/src/gatsby-ssr.js b/packages/gatsby-plugin-glamor/src/gatsby-ssr.js index ffb5d658f056d..0bc84f63b7338 100644 --- a/packages/gatsby-plugin-glamor/src/gatsby-ssr.js +++ b/packages/gatsby-plugin-glamor/src/gatsby-ssr.js @@ -14,9 +14,14 @@ exports.replaceRenderer = ({ replaceBodyHTMLString(html) setHeadComponents([ -