Open rimakan opened 6 days ago
I think this might be a yarn only issue.
@rimakan,
It is a yarn bug https://github.com/yarnpkg/berry/issues/2476
There might be a work around by using: NODE_OPTIONS="--require .pnp.cjs"
like this:
NODE_OPTIONS="--require .pnp.cjs" yarn eslint .
.
You could also try importing .pnp.cjs
from .eslint.config.js
, that might work, but the above issue might keep it from working.
eslint.config.js
import './.pnp.cjs';
// ... the rest of your config.
I'm open to a PR if you find a good fix, there are docs https://yarnpkg.com/features/pnp
@Jason3S , thank you for your input!
It didn't help to be candid.
What helps is to set nodeLinkers: node-modules
in .yarnrc.yaml
and reinstall deps to have node_modules
but this is a weird solution because it violates the plug and play pattern of new Yarn versions. It is better not to do it.
@rimakan,
There is not much I can do. It really is a Yarn issue: https://github.com/yarnpkg/berry/issues/6335
This plugin uses SyncKit to run the worker.
Please try yarn unplug @cspell/eslint-plugin
and see if that works for you.
@rimakan,
A bit of information would be useful:
@Jason3S ,
My bad, sure I will provide you with the info
Node: 20.13 Yarn: 4.5.0
Your workaround didn't work. I saw similar error to what I attached to the issue. This time I saw the issue but with SyncKit. I tried to install it and put to to "resolutions". It did not help me whatsoever :(
@rimakan,
I took the time to set it up and try it out. There are other tests to ensure cspell
runs with Yarn, but I had not done that with the ESLint plugin.
I think the key thing to get it working is to ensure yarn generates the .pnp.loader.mjs
file. Use the pnpEnableEsmLoader: true
in .yarnrc.yml
.
@Jason3S ,
Thank you for your assistance. Your solution did not help me. I still see the very error
Do I need to install extra packages that may be dependencies for the plugin?
@rimakan,
Please start with a basic setup and see if it works.
Here is a SandBox Link
Please make an example that fails. As far as I can tell, it is working as expected.
@Jason3S ,
I have just tried to reproduce the issue using an example project locally. I still see the issue.
You can check it out yourself by deploying it locally: https://github.com/rimakan/cspell-example-project
In order to deploy it locally, make sure you have corepack on your local machine
I think this may be caused by the config which is automatically created after executing the command npx @eslint/migrate-config .eslintrc.json
to migrate to the flat config
Could you please try this.
npx @eslint/migrate-config .eslintrc.json
in the directory where your .eslint.json
is located@rimakan,
Thank you for the repo case, I'll take a look.
@rimakan,
The example breaks before cspell is even loaded. It cannot find prettier, no-cycle, etc.
Do you have a working example that breaks only after cspell is added?
@Jason3S ,
Have you installed dependencies? By running yarn install
If it doesn’t help, I’ll check it out
When I comment out all the rules that do not load, the spell checker works fine:
This is the eslint.config.mjs
that works:
// @ts-check
import { fixupConfigRules, fixupPluginRules } from "@eslint/compat";
import react from "eslint-plugin-react";
// import prettier from "eslint-plugin-prettier";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import reactHooks from "eslint-plugin-react-hooks";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
import cspellPlugin from "@cspell/eslint-plugin";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
export default [
...fixupConfigRules(
compat.extends(
"eslint:recommended",
// "plugin:@typescript-eslint/recommended",
// "plugin:react-hooks/recommended",
// "plugin:prettier/recommended",
)
),
{
plugins: {
// react,
// prettier: fixupPluginRules(prettier),
// "@typescript-eslint": fixupPluginRules(typescriptEslint),
// "react-hooks": fixupPluginRules(reactHooks),
"@cspell": cspellPlugin,
},
// languageOptions: {
// parser: tsParser,
// ecmaVersion: "latest",
// sourceType: "module",
// },
settings: {},
rules: {
'@cspell/spellchecker': ['warn', {}],
// "import/no-cycle": [
// "error",
// {
// maxDepth: 10,
// ignoreExternal: true,
// },
// ],
// "no-restricted-imports": "off",
// "@typescript-eslint/no-unused-vars": [
// "error",
// {
// ignoreRestSiblings: true,
// },
// ],
// "object-curly-spacing": [2, "always"],
// quotes: ["error", "single"],
// semi: ["warn", "always"],
// "comma-dangle": ["error", "always-multiline"],
// "space-before-function-paren": [
// "error",
// {
// anonymous: "always",
// named: "never",
// asyncArrow: "always",
// },
// ],
// "react/jsx-max-props-per-line": [
// 1,
// {
// when: "multiline",
// },
// ],
// "no-console": [
// "error",
// {
// allow: ["info", "warn", "error"],
// },
// ],
},
},
];
@Jason3S ,
Have you installed dependencies? By running
yarn install
Yes, I did.
If it doesn’t help, I’ll check it out
Is everything checked into master?
@Jason3S ,
Usual developer’s excuse is coming. It worked locally :)
I will double check because it really did work (I mean the rest things apart from cspell checker).
Also you have given me a brilliant idea. I will check it out as well.
P.S. I checked out your issue. My bad, sorry. I was commenting other packages out in order to test things.
@Jason3S , the plugin works like a charm. I should not have paid attention to the eslint output in the VS Code. Once I ran yarn eslint
, I saw that plugin told me about some unknown words
However, the issue is still present. It can really be a Yarn or even ESLint issue
Thank you so much for your assistance!
P.S. I fixed the repo's code. You can check out the problem above
@rimakan,
ESLint won't automatically reload in VSCode. You need to run: F1
- Restart Extension Host
Do you have the latest version of the ESLint plugin?
@Jason3S ,
Yeah, I do. My ESLint plugin's version is 3.0.10 which seems to be the latest one bc VS Code does not suggest me updating it.
Kind of Issue
Question
Tool or Library
cspell/eslint-plugin
Version
8.15.5
Supporting Library
Not sure / None
OS
Linux
OS Version
22.04
Description
The ESLint cannot import @cspell/eslint-plugin for some reason
Steps to Reproduce
npx @eslint/migrate-config .eslintrc.json
Expected Behavior
There are no errors
Additional Information
No response
cspell.json
No response
cspell.config.yaml
No response
Example Repository
No response
Code of Conduct