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

Bug: cache doesn't invalidate on plugin version upgrade #16284

Closed
1 task done
tdeo opened this issue Sep 8, 2022 · 8 comments · Fixed by #16992
Closed
1 task done

Bug: cache doesn't invalidate on plugin version upgrade #16284

tdeo opened this issue Sep 8, 2022 · 8 comments · Fixed by #16992
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly repro:needed repro:yes
Projects

Comments

@tdeo
Copy link

tdeo commented Sep 8, 2022

Environment

Node version: v16.15.1
npm version: N/A - using yarn
Local ESLint version: 8.23.0
Global ESLint version: no global eslint installed
Operating System: MacOS 12.5.1

What parser are you using?

@babel/eslint-parser

What did you do?

I upgraded eslint-plugin-react from 7.37.1 to 7.37.7.

Due to new rules addition and the cache for the former version still being used, offenses for those new rules weren't being reported.

My code contains the following:

const Componnent = () => {
  return <table>
    <thead>
      <th align="center">title</th>
    </thead>
  </table>
}

What did you expect to happen?

Offenses to be reported

What actually happened?

Nothing was reported

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

Should be fixed by this PR: eslint/eslintrc#88

@tdeo tdeo added bug ESLint is working incorrectly repro:needed labels Sep 8, 2022
@eslint-github-bot eslint-github-bot bot added this to Needs Triage in Triage Sep 8, 2022
@nzakas
Copy link
Member

nzakas commented Sep 8, 2022

I think the only way we can guarantee this with the new config system is to ask plugin authors to include a version field in their plugin object, as we no longer know the package.json to read to get this info with the new config system.

@nzakas nzakas added accepted There is consensus among the team that this change meets the criteria for inclusion repro:yes labels Sep 8, 2022
@nzakas nzakas moved this from Needs Triage to Ready to Implement in Triage Sep 8, 2022
@CSchulz
Copy link

CSchulz commented Dec 6, 2022

I am wondering why we can't read the version out of the package.json file?

@nzakas
Copy link
Member

nzakas commented Dec 8, 2022

@CSchulz because with flat config we don't have any package information. You are manually importing a package and then passing the object into the config. We don't know where that object came from inside of ESLint.

@CSchulz
Copy link

CSchulz commented Dec 9, 2022

I think I did not get the point.

I have checked out the new experimental feature documentation and there is still the plugins array to put custom plugins.
The eslint core loads all plugins declared in the plugins array out of the node_modules, right?
like here?

eslint/lib/cli.js

Lines 132 to 144 in 740b208

if (plugin) {
const plugins = {};
for (const pluginName of plugin) {
const shortName = naming.getShorthandName(pluginName, "eslint-plugin");
const longName = naming.normalizePackageName(pluginName, "eslint-plugin");
plugins[shortName] = await importer.import(longName);
}
overrideConfig[0].plugins = plugins;
}

@nzakas
Copy link
Member

nzakas commented Dec 9, 2022

The eslint core loads all plugins declared in the plugins array out of the node_modules, right?

No. What you're looking at is the code that loads the plugins from the command line --plugin flag. That is not the standard way to load plugins. Please read the documentation for the new config system:
https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new

@nzakas
Copy link
Member

nzakas commented Mar 8, 2023

So I think we can use the same approach as in #16875, where we ask plugins to supply a meta property. @eslint/eslint-tsc what do you think?

@mdjermanovic
Copy link
Member

So I think we can use the same approach as in #16875, where we ask plugins to supply a meta property

Sounds good to me 👍

If plugin exports meta.name (or top-level name), shall we use that name instead of its key from the config?

@nzakas
Copy link
Member

nzakas commented Mar 15, 2023

If plugin exports meta.name (or top-level name), shall we use that name instead of its key from the config?

My idea was to combine the two, so js:@eslint/[email protected] if the plugin has meta information and just js if not.

@nzakas nzakas self-assigned this Mar 15, 2023
nzakas added a commit that referenced this issue Mar 15, 2023
Updates `FlatConfigArray` to look for meta information on plugins when
serializing a config.

Fixes #16284
nzakas added a commit that referenced this issue Mar 17, 2023
Updates `FlatConfigArray` to look for meta information on plugins when
serializing a config.

Fixes #16284
mdjermanovic pushed a commit that referenced this issue Mar 23, 2023
* feat: Use plugin metadata for flat config serialization

Updates `FlatConfigArray` to look for meta information on plugins when
serializing a config.

Fixes #16284

* Update docs/src/extend/plugins.md

Co-authored-by: Nitin Kumar <[email protected]>

* Rebase

---------

Co-authored-by: Nitin Kumar <[email protected]>
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Sep 20, 2023
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly repro:needed repro:yes
Projects
Archived in project
Triage
Ready to Implement
Development

Successfully merging a pull request may close this issue.

4 participants