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

Parsing error: Unexpected token #231

Closed
UglyHobbitFeet opened this issue Oct 9, 2024 · 2 comments
Closed

Parsing error: Unexpected token #231

UglyHobbitFeet opened this issue Oct 9, 2024 · 2 comments
Assignees
Labels

Comments

@UglyHobbitFeet
Copy link

When I run eslint I get the Parsing Error: 'Unexpected Token' when including pluginCypress. When I remove pluginCypress the error goes away. Please let me know if it's something obvious or if I need to post another config file (tsconfig.json, vite.config.mts, cypress.config.ts, etc). Thanks!

package.json (eslint deps)

    "@eslint/js": "9.11.1",
    "@types/eslint__js": "8.42.3",
    "@typescript-eslint/eslint-plugin": "8.7.0",
    "@vue/eslint-config-typescript": "13.0.0",
    "eslint": "9.11.1",
    "eslint-plugin-cypress": "3.5.0",
    "eslint-plugin-vue": "9.28.0",
    "typescript-eslint": "8.7.0",

eslint.config.mjs

// @ts-check
import eslint from '@eslint/js';
import pluginCypress from 'eslint-plugin-cypress/flat'
import tseslint from 'typescript-eslint';

export default tseslint.config(
  eslint.configs.recommended,
  //...tseslint.configs.recommendedTypeChecked,
  ...tseslint.configs.recommendedTypeChecked.map((config) => ({
    files: ['**/*.ts'],
    ...config,
    ...pluginCypress.configs.recommended,
    ...{
      languageOptions: {
        ecmaVersion: 'latest',
      },
    },
  }))
);
@MikeMcC399
Copy link
Collaborator

@UglyHobbitFeet

I was not able to run your configuration successfully.

The following alternative configuration works when run against https://github.com/cypress-io/cypress-component-testing-apps/tree/main/vue3-vite-ts (and reports genuine linting errors). This may help you, however it is out-of-scope to provide individual configuration support here in this issue list. I should also say that I'm not familiar with typescript-eslint. I just used the documentation.

// @ts-check

import globals from 'globals'
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint'
import pluginCypress from 'eslint-plugin-cypress/flat'

export default [
  eslint.configs.recommended,
  pluginCypress.configs.recommended,
  ...tseslint.configs.recommendedTypeChecked,
  {
    languageOptions: {
      globals: {
        ...globals.node
      },
      parserOptions: {
        projectService: true,
        tsconfigRootDir: import.meta.dirname,
      },
    }
  }
]

If you think you have found a bug in eslint-plugin-cypress we would really need a full reproducible example.

The ESLint organization also hosts a Discord server where you can ask for help with configurations.

BTW: @vue/[email protected], which you list in your package.json, is not compatible with ESLint v9 / flat config. You would need to be using @vue/[email protected].

@MikeMcC399 MikeMcC399 added the bug label Oct 10, 2024
@MikeMcC399 MikeMcC399 self-assigned this Oct 10, 2024
@UglyHobbitFeet
Copy link
Author

Thanks for looking into this and providing an example. I have used your config and updated deps and it seems to compile without the original errors!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants