Skip to content

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

Open

Description

@tobiaskraus

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')

Activity

  1. skaindl commented on Jun 4, 2020

    @skaindl

    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.

  2. croraf commented on Aug 18, 2020

    @croraf

    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 ).

  3. konekoya commented on Nov 6, 2020

    @konekoya

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions