Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint-loader should not cache, when process.env.EXTEND_ESLINT === 'true' #9085

Open
tobiaskraus opened this issue May 29, 2020 · 3 comments

Comments

@tobiaskraus
Copy link

Is your proposal related to a problem?

When I change my .eslintrc.js the changes are not reflected in react-scripts start. I found a workaround in #9007 described by @Josema to disable the cache in node_modules/react-scripts/config/webpack.config.js:

this is caused by how react-scripts handles ESLint cache. By default, cache is set to true. If you set it to false, any change to eslint rules will be honoured every time. The setting is in node_modules/react-scripts/config/webpack.config.js

Describe the solution you'd like

Similar to what @Josema wrote (sadly this issue #9007 got closed)

So my suggestion is to make this cache option configurable, and by default set it to false, to avoid confusion.

Currently the webpack.config.js looks like that:

// First, run the linter.
// It's important to do this before Babel processes the JS.
{
  test: /\.(js|mjs|jsx|ts|tsx)$/,
  enforce: 'pre',
  use: [
    {
      options: {
        cache: false,
        formatter: require.resolve('react-dev-utils/eslintFormatter'),
        eslintPath: require.resolve('eslint'),
        resolvePluginsRelativeTo: __dirname,
        // @remove-on-eject-begin
        ignore: isExtendingEslintConfig,
        baseConfig: isExtendingEslintConfig
          ? undefined
          : {
              extends: [require.resolve('eslint-config-react-app')],
            },
        useEslintrc: isExtendingEslintConfig,
        // @remove-on-eject-end
      },
      loader: require.resolve('eslint-loader'),
    },
  ],

I suggest:

cache: !isExtendingEslintConfig,

As it only needs to be disabled when isExtendingEslintConfig is true (process.env.EXTEND_ESLINT === 'true')

@skaindl
Copy link

skaindl commented Jun 4, 2020

Agreed! I'm also having this problem, and additionally would like to turn off caching because I'm using yarn 2 and don't want to have a node_modules directory automatically created just for the cache files.

@croraf
Copy link

croraf commented Aug 18, 2020

I like the workaround described here: #9154 (comment) (to delete the eslint cache file). Perhaps this can be automated so that any time the eslint config is updated the cache is deleted. But what if the extended config is updated (eslint-config-react-app). Perhaps there is a proper solution.

Also, let me mention EXTEND_ESLINT so the issue search picks it (it doesnt pick it if it is only mentioned as process.env.EXTEND_ESLINT ).

@konekoya
Copy link

konekoya commented Nov 6, 2020

Just wondering if this has been fixed in v4 or not? We're about to migrate to v4 because of various issues we encountered in v3 but not sure if this issue is also included?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants