8000 Single run detection for type-aware linting causing file not found in any of the provided program instances · Issue #4093 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Single run detection for type-aware linting causing file not found in any of the provided program instances #4093

8000
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
3 tasks done
cmcnicholas opened this issue Nov 5, 2021 · 3 comments
Labels
package: typescript-estree Issues related to @typescript-eslint/typescript-estree vue issues relating to vue support

Comments

@cmcnicholas
Copy link
cmcnicholas commented Nov 5, 2021
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

We have a large TypeScript and Vue based monorepo with 28 packages, 7.5k files, 776k lines of code (if size of repo matters). We have an issue after some house cleaning our eslintrc.js files with the following error message being reported on our ci pipeline during eslint execution:

0:0  error  Parsing error: "parserOptions.programs" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided program instance(s): src\App.vue

This ticket #3528 indicates a change was applied which differentiates the run on a CI environment from local. We are trying to figure out what the above means, there are little to no hits for that error message, most are about parserOptions.project.

We can confirm that using the following config passes on our pipeline when we set allowAutomaticSingleRunInference to false:

 parserOptions: {
        parser: {
          ts: '@typescript-eslint/parser',
          '<template>': 'espree',
        },
        allowAutomaticSingleRunInference: false,
      },

I have read the attached ticket and understand the reasoning behind automatically inferring the property however I would like to understand why we can't use the CI mode on our pipeline, is there any documentation that can show us what config we are missing?

My understanding is the configs shouldn't need specific settings to function on CI vs locally but it looks like either we have something configured wrong or there is genuinely some breaking change as a result of that config switch.

Expected Result

expected these messages to not be present during linting:

0:0  error  Parsing error: "parserOptions.programs" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided program instance(s): src\App.vue

Actual Result

The error messages above are printed during a CI run.

Additional Info

This is our per project .eslintrc.js:

module.exports = {
  root: true,
  extends: '../../.eslintrc.js',
  parserOptions: {
    tsconfigRootDir: __dirname,
    project: ['./tsconfig.json'],
  },
};

This is our root .eslintrc.js:

module.exports = {
  root: true,
  globals: {
    HTMLTableHeaderCellElement: 'readonly',
    Record: 'writable',
    Readonly: 'readonly',
    ReturnType: 'readonly',
    Omit: 'readonly',
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly',
  },
  env: {
    es6: true,
    browser: true,
  },
  plugins: ['@typescript-eslint', 'prettier'],
  extends: [
    'eslint:recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:@typescript-eslint/recommended-requiring-type-checking',
    'plugin:prettier/recommended',
  ],
  parser: '@typescript-eslint/parser',
  parserOptions: {
    tsconfigRootDir: __dirname,
    sourceType: 'module',
    ecmaVersion: 2020,
    project: ['./tsconfig.eslint.json'],
    extraFileExtensions: ['.vue'],
    allowAutomaticSingleRunInference: true,
    EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
  },
  ignorePatterns: [
    './projects/alloy-web-legacy/src/app/svr/street-manager/api/**',
    '*.js',
  ],
  rules: {
    curly: 'error',
    eqeqeq: 'warn',
    'no-console': 'error',
    'no-debugger': 'error',
    'consistent-return': 'error',
    'max-len': [
      'warn',
      {
        code: 100,
        ignoreUrls: true,
      },
    ],
    quotes: ['error', 'single', 'avoid-escape'],
    '@typescript-eslint/prefer-for-of': ['warn'],
    '@typescript-eslint/no-inferrable-types': ['warn'],
    '@typescript-eslint/explicit-function-return-type': ['error'],
    '@typescript-eslint/no-use-before-define': [
      'error',
      {
        functions: false,
      },
    ],
    '@typescript-eslint/no-explicit-any': ['error'],
    '@typescript-eslint/no-unused-vars': [
      'warn',
      {
        args: 'none',
      },
    ],
    '@typescript-eslint/member-ordering': [
      'warn',
      {
        default: [
          'field',
          'constructor',
          'public-static-method',
          'get',
          'public-instance-method',
          'protected-method',
          'private-method',
        ],
      },
    ],
    'prettier/prettier': 'error',
    '@typescript-eslint/no-empty-interface': [
      'error',
      {
        allowSingleExtends: true,
      },
    ],
    /* These no-unsafe should be turned on but I don't think our typescript version (or the parser)
    is ready for them yet. */
    '@typescript-eslint/no-unsafe-member-access': 'off',
    '@typescript-eslint/no-unsafe-call': 'off',
    '@typescript-eslint/no-unsafe-assignment': 'off',
    '@typescript-eslint/no-unsafe-return': 'off',
    /* This no-unnecessary-type-assertion should be turned on but it doesn't work with asserting
     * generics and a few other cases with Vue types so let's keep them off until they fix the
     * issues. */
    '@typescript-eslint/no-unnecessary-type-assertion': 'off',
    /* We do not need this require await rule because we always use async and don't use .then(). */
    'require-await': 'off',
    '@typescript-eslint/require-await': 'off',
    /* We consider statics to be safe (they aren't, but really they sort of are) */
    '@typescript-eslint/unbound-method': [
      'error',
      {
        ignoreStatic: true,
      },
    ],
  },
  overrides: [
    {
      // alloy-web-legacy overrides
      files: ['./projects/alloy-web-legacy/src/**'],
      rules: {
        'no-prototype-builtins': ['off'],
        '@typescript-eslint/no-empty-interface': ['off'],
        '@typescript-eslint/no-explicit-any': ['off'],
        '@typescript-eslint/explicit-module-boundary-types': [
          'error',
          {
            allowArgumentsExplicitlyTypedAsAny: true,
          },
        ],
      },
    },
    {
      // Vue files overrides
      files: [
        '**/*.vue',
      ],
      plugins: ['@yottaltd', 'vue'],
      extends: [
        'plugin:vue/recommended',
      ],
      parser: 'vue-eslint-parser',
      parserOptions: {
        parser: {
          ts: '@typescript-eslint/parser',
          '<template>': 'espree',
        },
        allowAutomaticSingleRunInference: false,
      },
      rules: {
        'vue/custom-event-name-casing': ['error'],
        'vue/component-name-in-template-casing': ['error'],
        'vue/html-self-closing': 'off',
        'vue/max-attributes-per-line': 'off',
        'vue/singleline-html-element-content-newline': 'off',
        '@yottaltd/event-handler-names': 'error',
        '@yottaltd/event-missing-handler': 'error',
        '@yottaltd/missing-refs': 'error',
        '@yottaltd/optional-refs': 'error',
        '@typescript-eslint/member-ordering': [
          'warn',
          {
            default: [
              'field',
              'constructor',
              'decorated-method',
              'get',
              'public-method',
              'protected-method',
              'private-method',
            ],
          },
        ],
      },
    },
    {
      // Vue Mixin files overrides
      files: [
        '**/*Mixin.ts',
      ],
      rules: {
        // has to match member-ordering of vue override
        '@typescript-eslint/member-ordering': [
          'warn',
          {
            default: [
              'field',
              'constructor',
              'decorated-method',
              'get',
              'public-method',
              'protected-method',
              'private-method',
            ],
          },
        ],
      },
    },
    {
      // assets json overrides
      files: [
        '*.json',
      ],
      rules: {
        'quotes': 'off',
        'max-len': 'off',
      },
    },
  ],
};

In both cases the tsconfig's exist and as mentioned linting works locally.

Below is the --debug output of a pipeline lint execution (warning, it's a big file):

https://gist.githubusercontent.com/cmcnicholas/ff09387d56af8df30fe6715ff4237595/raw/4a70d8a0e45821974eeb4daf044828f478500f82/pipeline-output-lint.txt

Versions

package version
@typescript-eslint/typescript-estree 5.3.0
TypeScript 4.4.4
node 16.6.1
@cmcnicholas cmcnicholas added package: typescript-estree Issues related to @typescript-eslint/typescript-estree triage Waiting for team members to take a look labels Nov 5, 2021
@bradzacher
Copy link
Member
bradzacher commented Nov 11, 2021

If I had to guess - glancing at your config and the fact that the only files are .vue files - this is is probably due to weirdness between how vue-eslint-parser splits up files and then calls into our tooling.

Overall we just don't have good support for vue - it has a very custom stack which does its own things to call into our parser in not always compatible ways (for example, leading to issues like #2127).

I'd love to provide more support here, but we just don't have the bandwidth as volunteer maintainers to upskill on the custom vue stack to attempt to learn and support it.
We've been looking for a champion from the vue community to help support it (vuejs/eslint-plugin-vue#1296), but nobody has stepped up.
Which unfortunately leads us into a state of "unsupported, use at your own risk".

I'd suggest starting by turning off single run detection using the allowAutomaticSingleRunInference parser option.

@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 Nov 11, 2021
@cmcnicholas
Copy link
Author

I'd suggest starting by turning off single run detection using the allowAutomaticSingleRunInference parser option.

this is essentially what we have done for our vue files, it works consistently in the pipeline, it's still pretty quick at under 10 mins so is definitely something we can live with for now, let's hope someone from the vue team picks this up and helps with 1st class support here because I imagine they must face similar issues with their source in TS now and more users moving to TS with Vue.

@bradzacher bradzacher added vue issues relating to vue support and removed awaiting response Issues waiting for a reply from the OP or another party labels Nov 17, 2021
@bradzacher
Copy link
Member

As we cannot action this for now - I'm going to close this.
I've tagged it so it can be found later.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: typescript-estree Issues related to @typescript-eslint/typescript-estree vue issues relating to vue support
Projects
None yet
Development

No branches or pull requests

2 participants
0