-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[Bug]: TypeError: sourceCode.getAllComments is not a function #3913
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
Comments
you might need to put the tseslint config after the react ones, since the ts-eslint one sets the proper TS parser settings, but since it works when you remove the CSS rules, it's probably that the pragma util is erroring on .css files. I'll see if I can repro it (but if you have a repo, that'd be better) |
Thanks @ljharb for your answering!
.special-title {
color: #47c2fc;
}
import './App.css';
export default function App() {
return (
<main>
<h1 className="special-title">Hello!!!</h1>
</main>
);
}
import { defineConfig } from 'eslint/config';
import globals from 'globals';
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import pluginReact from 'eslint-plugin-react';
import css from '@eslint/css';
export default defineConfig([
{
settings: {
react: {
version: 'detect',
},
},
},
{ files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'] },
{
files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'],
languageOptions: { globals: globals.browser },
},
{
files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'],
plugins: { js },
extends: ['js/recommended'],
},
pluginReact.configs.flat.recommended,
pluginReact.configs.flat['jsx-runtime'],
tseslint.configs.recommended,
// lint css files
{
files: ['**/*.css'],
plugins: {
css,
},
language: 'css/css',
rules: {
'css/no-duplicate-imports': 'error',
},
},
]);
![]()
npm run lint ![]() Unfortunately, the error persisted.
Please, I will appreciate your help. |
@developermau your repro repo uses |
@ljharb I am so sorry, but I cannot understand what you are talking about. Because I have installed Then...
Can you please give me more information about that I should do or next steps? I would appreciate it. I want to help, and fix this error, but not make more errors 😅 or generate confusion. |
I'm currently reproducing this. Unsure what @ljharb is saying about Dependencies look like this: "@eslint/js": "^9.24.0",
"eslint": "^9.24.0",
"eslint-plugin-react": "^7.37.5",
"typescript-eslint": "^8.29.1" I started hacking on the eslint-plugin-react code at the error site and noticed it was failing to process markdown assets. I corrected the error by specifying files for the plugin: // eslint.config.mjs
export default defineConfig([
// ...more of my config
{ plugins: { react } },
{
...react.configs.flat.recommended,
files: ["**/*.{jsx?,mjsx?,cjsx?,tsx?}"],
},
{
...react.configs.flat["jsx-runtime"],
files: ["**/*.{jsx?,mjsx?,cjsx?,tsx?}"],
},
]); |
I'm not sure where I saw that other plugin mentioned; i don't see it now. Thanks, I'll take a look at the repro. |
Thanks for taking a second look 👀 |
Is there an existing issue for this?
Description Overview
I have built an app using Vite (
^6.2.2
), React (^19.0.0
), Typescript(~5.7.2
), ESLint (^9.23.0
), and @eslint/css (^0.5.0
).I have this ESLint configuration file (
eslint.config.js
):Also, I have some scripts on my
package.json
:Unfortunately, I have an error:
The error happens when I run this command:
I tried to uninstall
eslint-plugin-react
, removenode_modules
folder, and install all dependencies again but the error persists.I have created a Stackblitz project. Please, I will appreciate your help.
Expected Behavior
If I remove the
@eslint/css
code on myeslint.config.js
file, I do not have this error:Results:
eslint-plugin-react version
^7.37.4
eslint version
^9.23.0
node version
18.20.3
The text was updated successfully, but these errors were encountered: