8000 Bug: [recommended-requiring-type-checking] Parsing error: '>' expected · Issue #6532 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Bug: [recommended-requiring-type-checking] Parsing error: '>' expected #6532

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

Closed
4 tasks done
laterdayi opened this issue Feb 25, 2023 · 10 comments
Closed
4 tasks done
Labels
bug Something isn't working external This issue is with another package, not typescript-eslint itself package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin vue issues relating to vue support

Comments

@laterdayi
Copy link
laterdayi commented Feb 25, 2023

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

Repro Code

https://github.com/laterdayi/tests

image

image

ESLint Config

/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution');

module.exports = {
  root: true,
  env: {
    node: true,
    es6: true
  },
  parser: 'vue-eslint-parser',
  plugins: ['standard-recommended'],
  extends: [
    'plugin:vue/vue3-essential',
    'plugin:vue/vue3-strongly-recommended',
    'plugin:vue/vue3-recommended',
    'eslint:recommended',
    '@vue/eslint-config-typescript/recommended',
    '@vue/eslint-config-prettier',
    './.eslintrc-auto-import.json',
    'plugin:@typescript-eslint/recommended-requiring-type-checking'
  ],
  parserOptions: {
    parser: '@typescript-eslint/parser',
    ecmaVersion: 'latest',
    ecmaFeatures: {
      jsx: true
    },
    project: './tsconfig.json'
  },
  rules: {
    'standard-recommended/no-index': 'error',
    'prettier/prettier': ['warn', { printWidth: 120 }],
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    eqeqeq: 'error',
    'no-alert': 'error',
    quotes: 'off',
    'no-const-assign': 'error',
    'no-eval': 'error',
    'no-implied-eval': 'error',
    semi: 'off',
    'no-multi-spaces': 'error',
    'no-new-wrappers': 'error',
    'no-script-url': 'error',
    'no-self-compare': 'error',
    'no-useless-return': 'error',
    'no-void': 'error',
    'require-await': 'error',
    'wrap-iife': ['error', 'inside'],
    yoda: 'error',
    'no-undef': 'off',
    'no-use-before-define': 'off',
    'global-require': 'error',
    'no-new-require': 'error',
    camelcase: 'error',
    'comma-dangle': 'error',
    'line-comment-position': 'error',
    'max-depth': 'error',
    'max-nested-callbacks': 'error',
    'multiline-comment-style': 'error',
    'no-inline-comments': 'error',
    'no-lonely-if': 'error',
    'no-trailing-spaces': 'error',
    'no-unneeded-ternary': 'error',
    'no-whitespace-before-property': 'error',
    'operator-assignment': 'error',
    'padded-blocks': ['error', 'never'],
    'space-before-function-paren': 'off',
    'spaced-comment': 'error',
    'switch-colon-spacing': 'error',
    'no-duplicate-imports': 'error',
    'no-useless-rename': 'error',
    'no-var': 'error',
    'prefer-const': 'error',
    'default-case': 'error',
    'default-case-last': 'error',
    'default-param-last': 'error',
    'new-cap': 'error',
    'no-else-return': 'error',
    'no-empty-function': 'error',
    'no-lone-blocks': 'error',
    'no-return-await': 'error',
    'array-bracket-spacing': 'error',
    'arrow-parens': ['error', 'as-needed'],
    'arrow-spacing': 'error',
    'brace-style': 'error',
    'comma-spacing': 'error',
    'key-spacing': 'error',
    'keyword-spacing': 'error',
    'lines-between-class-members': 'error',
    'no-multiple-empty-lines': 'error',
    'nonblock-statement-body-position': 'error',
    'object-curly-spacing': ['error', 'always'],
    'rest-spread-spacing': 'error',
    'space-before-blocks': 'error',
    'space-in-parens': 'error',
    '@typescript-eslint/array-type': 'error',
    '@typescript-eslint/no-duplicate-enum-values': 'error',
    '@typescript-eslint/no-empty-interface': 'error',
    '@typescript-eslint/no-inferrable-types': 'error',
    '@typescript-eslint/no-unused-vars': 'error',
    '@typescript-eslint/no-explicit-any': 'warn',
    '@typescript-eslint/no-namespace': 'off',
    '@typescript-eslint/prefer-optional-chain': 'off',

    '@typescript-eslint/naming-convention': [
      'error',
      { selector: ['interface', 'typeAlias', 'enum'], format: ['PascalCase'] },
      { selector: ['function', 'parameter'], format: ['camelCase'] },
      {
        selector: 'memberLike',
        modifiers: ['private'],
        format: ['camelCase'],
        leadingUnderscore: 'require'
      }
    ],
    'vue/html-self-closing': [
      'error',
      {
        html: {
          void: 'always',
          normal: 'always',
          component: 'always'
        },
        svg: 'always',
        math: 'always'
      }
    ],
    'vue/multiline-html-element-content-newline': 'error',
    'vue/no-spaces-around-equal-signs-in-attribute': 'error',
    'vue/no-template-shadow': 'error',
    'vue/no-setup-props-destructure': 'off',
    'vue/prop-name-casing': 'error',
    'vue/multi-word-component-names': 'off',
    'vue/no-v-html': 'off'
  },
  overrides: [
    {
      files: [
        'src/components/base-chart/**/*',
        'src/components/base-curd/base-curd.vue',
        'src/components/base-ui/**/*',
        'src/types/global.d.ts',
        'src/utils/component.ts',
        'src/utils/extends.ts',
        'src/utils/localstorage.ts'
      ],
      rules: {
        '@typescript-eslint/no-explicit-any': 'off'
      }
    },
    {
      files: ['src/directive/index.ts', 'src/plugins/core/index.ts', 'src/service/index.ts', 'src/router/index.ts'],
      rules: {
        'standard-recommended/no-index': 'off'
      }
    }
  ]
};


### tsconfig

```jsonc
{
  "extends": "@vue/tsconfig/tsconfig.web.json",
  "include": ["env.d.ts", "src/**/*", "src/**/*.vue", "auto-imports.d.ts", "components.d.ts"],
  "exclude": ["src/plugins/vite/plugins/index.ts"],
  "compilerOptions": {
    "jsx": "preserve",
    "baseUrl": ".",
    "paths": {
      // TODO: delete https://github.com/userquin/unocss-browser-issue
      "@unocss/preset-icons/browser": ["./node_modules/@unocss/preset-icons/dist/browser"],
      "@/*": ["./src/*"],
      "@c/*": ["./src/components/*"],
      "@v/*": ["./src/views/*"]
    },
    "preserveValueImports": false,
    "lib": ["es6", "es2017", "es2019", "es2022"],
    "types": ["vite-plugin-svg-icons/client", "vite/client", "naive-ui/volar"]
  },
  "references": [
    {
      "path": "./tsconfig.config.json"
    }
  ]
}

Expected Result

is work

Actual Result

[{
	"resource": "/F:/my/E-fab/.eslintrc.cjs",
	"owner": "eslint",
	"severity": 8,
	"message": "Parsing error: ESLint was configured to run on `<tsconfigRootDir>/.eslintrc.cjs` using `parserOptions.project`: <tsconfigRootDir>/tsconfig.json\nHowever, that TSConfig does not include this file. Either:\n- Change ESLint's list of included files to not include this file\n- Change that TSConfig to include this file\n- Create a new TSConfig that includes this file and include it in your parserOptions.project\nSee the typescript-eslint docs for more info: https://typescript-eslint.io/linting/troubleshooting#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file",
	"source": "eslint",
	"startLineNumber": 1,
	"startColumn": 1,
	"endLineNumber": 1,
	"endColumn": 1
}]
[{
	"resource": "/f:/my/E-fab/src/views/testing/basic-config/equipment-layout-manage/equipment-layout-manage.vue",
	"owner": "eslint",
	"severity": 8,
	"message": "Parsing error: '>' expected.",
	"source": "eslint",
	"startLineNumber": 145,
	"startColumn": 34,
	"endLineNumber": 145,
	"endColumn": 34
}]

Additional Info

https://github.com/laterdayi/tests
No response

@laterdayi laterdayi added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Feb 25, 2023
@armano2
Copy link
Collaborator
armano2 commented Feb 25, 2023

can you provide code example?

generally this error usually means that you don't have jsx enabled in your project

Parsing error: '>' expected.

from what i can understand your config is not correct but without repro it's going to be hard to say why/

for first error read:
https://typescript-eslint.io/linting/troubleshooting/#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file

note references are not supported, i recommend creating tsconfig.eslint.json

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party and removed triage Waiting for team members to take a look labels Feb 25, 2023
@laterdayi
Copy link
Author
  parserOptions: {
    parser: '@typescript-eslint/parser',
    ecmaVersion: 'latest',
    ecmaFeatures: {
      jsx: true
    },
    project: './tsconfig.json'
  },

I have the parser set up

@armano2

@laterdayi
Copy link
Author

https://github.com/laterdayi/tests @bradzacher @armano2

@bradzacher bradzacher added the vue issues relating to vue support label Feb 26, 2023
@laterdayi
Copy link
Author
module.exports = {
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:@typescript-eslint/recommended-requiring-type-checking',
  ],
  plugins: ['@typescript-eslint'],
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: true,
    tsconfigRootDir: __dirname,
  },
  root: true,
};

If you don't set these items, it's normal

@typescript-eslint typescript-eslint deleted a comment from laterdayi Feb 26, 2023
@armano2
Copy link
Collaborator
armano2 commented Feb 27, 2023

yes, this is actually supper weird (related issue vuejs/vue-eslint-parser#176)

From my analysis, it looks like typescript reports ScriptKind TS for this file as reported path its .../XYZ.vue witch we treat as normal ts file

code that creates program for this:

this is most likely related to

or difference in behaviour of determinign ScriptKind in createWatchCompilerHost and outs

function getScriptKind(filePath: string, jsx: boolean): ts.ScriptKind {
as i don't see any override of a default behavior for this


@bradzacher all non standard extensions when paired with createWatchCompilerHost not not determine format for base on jsx option, WDYT?

@bradzacher
Copy link
Member

getScriptKind isn't used by type-aware linting.
when doing type-aware linting we defer to TS's internal logic for resolving extension -> "kind".

I didn't think you can use type-aware linting for vue template files because they aren't physical files on disk?

I don't know enough about vue to be able to say much of anything about how the infra fits together.

@armano2
Copy link
Collaborator
armano2 commented Mar 25, 2023

after debugging it seem that filePath is actually not pointing to virtual file, its reported as .vue witch means we are parsing is like any ts file and not tsx

there is actually no information from vue parser that we should treat this file as tsx instead of ts

cc @ota-meshi

@ota-meshi
Copy link
Contributor

I don't know if this is relevant to this issue, but I am experimenting with ways to provide the correct type information in *.vue.
https://github.com/ota-meshi/typescript-eslint-parser-for-extra-files

I'm not sure if it will work or not, however, as I've gotten very little feedback from users.
vuejs/vue-eslint-parser#104 (comment)

@laterdayi
Copy link
Author

@ota-meshi Looking forward to the official release

@bradzacher
Copy link
Member

I'm going to close this as an external issue as I don't think there's anything we can explicitly action in this project.

@bradzacher bradzacher closed this as not planned Won't fix, can't repro, duplicate, stale Mar 25, 2023
@bradzacher bradzacher added external This issue is with another package, not typescript-eslint itself and removed awaiting response Issues waiting for a reply from the OP or another party labels Mar 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working external This issue is with another package, not typescript-eslint itself package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin vue issues relating to vue support
Projects
None yet
Development

No branches or pull requests

4 participants
0