2

For a React project, I installed Sanity under the schema folder and then I started adding different JS files into it, but even though there is no code in them, I get the error in the header for each js file.

I also tried

npm install --save-dev @babel/preset-react

but it didn't work.

enter image description here

I started to watch Clever Programmer's Uniswap video but I cannot move forward with the error.

DᴀʀᴛʜVᴀᴅᴇʀ
  • 7,681
  • 17
  • 73
  • 127

4 Answers4

12

In your Sanity folder, you can add this code to the .eslintrc file:

"eslint.workingDirectories": ["./web", "./studio"]

So it should be like this:

{
  "extends": "@sanity/eslint-config-studio",
  "eslint.workingDirectories": ["./web", "./studio"]
}
DᴀʀᴛʜVᴀᴅᴇʀ
  • 7,681
  • 17
  • 73
  • 127
Dan Ng
  • 121
  • 6
1

I don't know if you solved it. You might need to change your webpack.config file. Go to:

node_modules/react-scripts/config

and open your webpack.config.js. Inside this file search for babel options and add this preset:

presets: [
  [
    require.resolve('babel-preset-react-app'),
    {
      runtime: hasJsxRuntime ? 'automatic' : 'classic',
    },
  ],
],

so your webpack.config file should look like

test: /\.(js|mjs|jsx|ts|tsx)$/,
include: paths.appSrc,
loader: require.resolve('babel-loader'),
options: {
customize: require.resolve(
  'babel-preset-react-app/webpack-overrides'
),
presets: [
  [
    require.resolve('babel-preset-react-app'),
    {
      runtime: hasJsxRuntime ? 'automatic' : 'classic',
    },
  ],
],
// @remove-on-eject-begin
babelrc: false,
configFile: false,
DᴀʀᴛʜVᴀᴅᴇʀ
  • 7,681
  • 17
  • 73
  • 127
murage kibicho
  • 546
  • 5
  • 14
0

Yes, In my case, this command is working now "eslint.workingDirectories": ["./web", "./studio"]

after adding this command project will working

-1

You can just change your .eslinc files into:

["next/babel", "next/core-web-vitals"]
Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
  • 2
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 02 '22 at 11:55