ionic-cli icon indicating copy to clipboard operation
ionic-cli copied to clipboard

Eslint and Vite errors after scaffolding new react project

Open s4ff0x opened this issue 2 years ago • 1 comments

Description:

After creating new project using ionic-cli some error messages were discovered

  1. Error [ERR_REQUIRE_ESM]: Cannot read config file: /<appRoot>/.eslintrc.js
  2. TS2345: Argument of type '{ plugins: PluginOption[][]; test: { globals: boolean; environment: string; setupFiles: string; }; }' is not assignable to parameter of type 'UserConfigExport'.
  3. ESLint: Parsing error: 'import' and 'export' may appear only with 'sourceType: module'

Steps to Reproduce: ionic start -> choose react with side menu -> check tsx files and vite.config

Possible solutions

  1. rename .eslintrc.js to .eslintrc.cjs
  2. take eslint config and eslint plugins from default vite react app (yarn create vite)

s4ff0x avatar Jun 03 '23 14:06 s4ff0x

  1. eslintrc.js => eslintrc.cjs
  2. parserOptions: { ecmaVersion: 2020, "sourceType": "module" },

zhengmenghuang avatar Oct 15 '24 04:10 zhengmenghuang