-
-
Notifications
You must be signed in to change notification settings - Fork 121
Cache doesn't bust when .eslintrc changes #214
Comments
I did meet this problem, and it took me two days to find this problem! |
Related to #190. |
I have the same issue but I can suggest a temp workaround. I did some digging in the source to find the following code that builds the var config = assign(
// loader defaults
{
formatter: formatter,
cacheIdentifier: JSON.stringify({
"eslint-loader": pkg.version,
eslint: require(userEslintPath || "eslint").version,
}),
eslintPath: "eslint",
},
userOptions
) Apparently, we can provide our own I have used the last modified time of my EDIT: See below for a better hashing // Get the file last modified time to use as a cache identifier
const eslintCacheIdentifier = JSON.stringify(fs.statSync(PATH_TO_ESLINT_RC).mtimeMs);
module.exports = {
module: {
// ...
rules: [
// ...
{
test: /\.(js|jsx)$/,
enforce: 'pre',
use: {
loader: 'eslint-loader',
options: {
cache: true,
cacheIdentifer: eslintCacheIdentifier,
},
},
},
// ...
],
},
}
} If someone will suggest a better cache identifier or a different suggestion on how to fix this, I may PR. I am wondering, maybe the solution would be to hash the EDIT: A safer As I have mentioned above, the last modified time is not a strong We'll use + const objectHash = require('object-hash');
- // Get the file last modified time to use as a cache identifier
- const eslintCacheIdentifier = JSON.stringify(fs.statSync(PATH_TO_ESLINT_RC).mtimeMs);
+ // Get the object hash for our single eslintrc to use as a cache identifier
+ const eslintCacheIdentifier = objectHash(require(PATH_TO_ESLINT_RC)); |
Encountered this problem today! @mati-o's comment really helped! |
This really messed my morning up 😆 I guess a manual procedure would be: |
FYI, this also is the case using |
Hi @swrobel |
Just did run into this. Hashing the eslintrc config might no be enough if that config is extending other configs (we are having a company wide eslint-config-*). |
Please use |
If I have a failure, then change eslintrc to change the rule, then run eslint, it comes up clean, however webpack keeps complaining until I
rm node_modules/.cache/eslint-loader/
The text was updated successfully, but these errors were encountered: