Skip to content

Commit

Permalink
example of how to solve facebook#1752 with a custom loader
Browse files Browse the repository at this point in the history
  • Loading branch information
nfcampos committed Mar 8, 2017
1 parent db008e6 commit 7a2f756
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
15 changes: 15 additions & 0 deletions packages/react-dev-utils/eslint-loader-watch-package-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

const eslintLoader = require('eslint-loader')
const loaderUtils = require("loader-utils")

function eslintLoaderWatchPackageJson() {
const { packageJsonPath } = loaderUtils.getOptions(this)
if (packageJsonPath) {
this.addDependency(packageJsonPath)
}

return eslintLoader.apply(this, arguments)
}

module.exports = eslintLoaderWatchPackageJson
2 changes: 2 additions & 0 deletions packages/react-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
"babel-code-frame": "6.20.0",
"chalk": "1.1.3",
"escape-string-regexp": "1.0.5",
"eslint-loader": "1.6.3",
"filesize": "3.3.0",
"gzip-size": "3.0.0",
"html-entities": "1.2.0",
"loader-utils": "1.0.2",
"opn": "4.0.2",
"recursive-readdir": "2.1.1",
"sockjs-client": "1.1.2",
Expand Down
9 changes: 5 additions & 4 deletions packages/react-scripts/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,15 @@ module.exports = {
enforce: 'pre',
use: [
{
// @remove-on-eject-begin
// Point ESLint to our predefined config.
options: {
packageJsonPath: paths.appPackageJson,
// @remove-on-eject-begin
// Point ESLint to our predefined config.
configFile: path.join(__dirname, '../eslintrc'),
useEslintrc: false,
// @remove-on-eject-end
},
// @remove-on-eject-end
loader: 'eslint-loader',
loader: 'react-dev-utils/eslint-loader-watch-package-json',
},
],
include: paths.appSrc,
Expand Down

0 comments on commit 7a2f756

Please sign in to comment.