Skip to content

Parser error - file does not match your project config #1160

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
1 task done
bradzacher opened this issue Oct 29, 2019 · 2 comments
Closed
1 task done

Parser error - file does not match your project config #1160

bradzacher opened this issue Oct 29, 2019 · 2 comments
Labels
package: typescript-estree Issues related to @typescript-eslint/typescript-estree question Questions! (i.e. not a bug / enhancment / documentation)

Comments

@bradzacher
Copy link
Member

@JoshuaKGoldberg via #890

I'm hitting this trying to onboard a Lerna monorepo with shared tooling... so it's a little hard to tell where the complaints are coming from.

See the pull request here: https://github.com/Codecademy/client-modules/pull/528
Build logs are here (are you able to see them?): https://circleci.com/gh/Codecademy/client-modules/13523?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-checks-link

Local equivalents of the same errors
$ eslint --ignore-path .eslintignore "./**/*.{js,ts,tsx,json}"

/Users/joshgoldberg/Codecademy-dev/repos/client-modules/packages/gamut/src/Form/Checkbox.tsx
  28:5  error  Form label must have ALL of the following types of associated control: nesting, id  jsx-a11y/label-has-for

/Users/joshgoldberg/Codecademy-dev/repos/client-modules/packages/gamut/src/Form/FormGroupLabel.tsx
  25:12  error  Form label must have ALL of the following types of associated control: nesting, id  jsx-a11y/label-has-for

/Users/joshgoldberg/Codecademy-dev/repos/client-modules/packages/gamut/src/Form/Radio.tsx
  43:7  error  Form label must have ALL of the following types of associated control: nesting, id  jsx-a11y/label-has-for

/Users/joshgoldberg/Codecademy-dev/repos/client-modules/packages/gamut/src/NotificationList/__tests__/NotificationList-test.js
  0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: packages/gamut/src/NotificationList/__tests__/NotificationList-test.js.
The file must be included in at least one of the projects provided

/Users/joshgoldberg/Codecademy-dev/repos/client-modules/packages/gamut/src/NotificationList/NotificationItem.tsx
  3:20  error  Parse errors in imported module 'moment': "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: node_modules/moment/src/moment.js.
The file must be included in at least one of the projects provided. (undefined:undefined)  import/default

/Users/joshgoldberg/Codecademy-dev/repos/client-modules/workspaces/gamut-storybook/__tests__/storybook-test.ts
  2:44  error  Parse errors in imported module '@storybook/addon-storyshots': "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: node_modules/@storybook/addon-storyshots/src/index.js.
The file must be included in at least one of the projects provided. (undefined:undefined)  import/named
  2:44  error  Parse errors in imported module '@storybook/addon-storyshots': "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: node_modules/@storybook/addon-storyshots/src/index.js.
The file must be included in at least one of the projects provided. (undefined:undefined)  import/default
  • I certify that I have read the OP, and attempted the listed steps to fix.
**tsconfig.json**
{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "jsx": "react",
    "module": "esnext",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "noUnusedLocals": true,
    "noUnusedParameters": false,
    "sourceMap": true,
    "target": "esnext"
  },
  "exclude": [
    "**/node_modules"
  ]
}
**packages/gamut/tsconfig.json**
{
    "extends": "../../tsconfig.json",
    "include": [
        "./src/**/*.ts",
        "./src/**/*.tsx"
    ],
    "compilerOptions": {
      "outDir": "./dist"
    }
}

**.eslintrc.js**
/**
 * @remarks
 * This could just use `extends`
 * but making a monorepo module a dependency in the root
 * causes an extra copy to be saved to node-modules that isn't
 * symlinked, which we don't want. This should eventually just
 * move to a shared private module instead of having this in the
 * project root
 */
const defaultConfig = require('./packages/eslint-config');

module.exports = {
  ...defaultConfig,
  overrides: [
    {
      files: ['*.js'],
      rules: {
        'import/default': 'off',
        'import/named': 'off',
      },
    },
    {
      files: ['**/typings/*', '*.d.ts'],
      rules: {
        '@typescript-eslint/no-namespace': 'off',
      },
    },
  ],
};

**packages/eslint-config/index.js**
/module.exports = {
  env: {
    browser: true,
    es6: true,
    jest: true,
    node: true,
  },

  extends: [
    'plugin:import/errors',
    'plugin:import/typescript',
    'plugin:jsx-a11y/strict',
    'plugin:react/recommended',
    'plugin:@typescript-eslint/all',
    'prettier',
    'prettier/react',
    'prettier/@typescript-eslint',
  ],

  globals: {
    // testcafe
    fixture: false,
    test: false,
  },

  parser: require.resolve('@typescript-eslint/parser'),

  parserOptions: {
    project: './tsconfig.json',
    sourceType: 'module',
  },

  plugins: ['import', 'jsx-a11y', 'no-only-tests', 'react', 'react-hooks'],

  rules: {
    // These off-by-default or configurable rules are good and we like having them on
    'no-only-tests/no-only-tests': 'error',
    'react/prop-types': [
      'error',
      {
        ignore: ['children'],
        skipUndeclared: true,
      },
    ],
    'react-hooks/exhaustive-deps': 'error',
    'react-hooks/rules-of-hooks': 'error',

    // These rules could be useful, but we haven't gotten around to trying them out
    '@typescript-eslint/array-type': 'off',
    '@typescript-eslint/await-thenable': 'off',
    '@typescript-eslint/ban-types': 'off',
    '@typescript-eslint/camelcase': 'off',
    '@typescript-eslint/explicit-member-accessibility': 'off',
    '@typescript-eslint/generic-type-naming': 'off',
    '@typescript-eslint/member-ordering': 'off',
    '@typescript-eslint/no-empty-function': 'off',
    '@typescript-eslint/no-explicit-any': 'off',
    '@typescript-eslint/no-floating-promises': 'off',
    '@typescript-eslint/no-misused-promises': 'off',
    '@typescript-eslint/no-non-null-assertion': 'off',
    '@typescript-eslint/no-require-imports': 'off',
    '@typescript-eslint/no-unnecessary-condition': 'off',
    '@typescript-eslint/no-use-before-define': 'off',
    '@typescript-eslint/no-var-requires': 'off',
    '@typescript-eslint/prefer-includes': 'off',
    '@typescript-eslint/prefer-regexp-exec': 'off',
    '@typescript-eslint/promise-function-async': 'off',
    '@typescript-eslint/require-array-sort-compare': 'off',
    '@typescript-eslint/require-await': 'off',
    '@typescript-eslint/restrict-plus-operands': 'off',
    '@typescript-eslint/strict-boolean-expressions': 'off',
    '@typescript-eslint/unbound-method': 'off',
    'import/namespace': 'off',
    'import/no-unresolved': 'off',
    'react/display-name': 'off',

    // These functional rules are annoying and we generally don't want them on
    '@typescript-eslint/consistent-type-definitions': 'off',
    '@typescript-eslint/explicit-function-return-type': 'off',
    '@typescript-eslint/no-magic-numbers': 'off',
    '@typescript-eslint/no-type-alias': 'off',
    '@typescript-eslint/no-unused-vars': 'off', // https://github.com/bradzacher/eslint-plugin-typescript/issues/283
    '@typescript-eslint/typedef': 'off',

    // These style rules conflict with Prettier but aren't disabled by its plugins
    '@typescript-eslint/quotes': 'off',
  },

  settings: {
    react: {
      version: 'detect',
    },
  },
};

**Example file paths that are throwing errors**
  • /Users/joshgoldberg/Codecademy-dev/repos/client-modules/packages/gamut/src/NotificationList/__tests__/NotificationList-test.js
    • 0:0 error Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
  • ./src/foo.ts
    • "parserOptions.project" has been set for @typescript-eslint/parser.
      The file does not match your project config: ./src/foo.ts
      The file must be included in at least one of the projects provided.

Versions

package version
@typescript-eslint/eslint-plugin 2.6.1-alpha.0
@typescript-eslint/parser 2.6.1-alpha0
TypeScript 3.5.3
node 12.13.0

Edit: would you like me to file a new issue, now that this is closed...?

@bradzacher bradzacher added question Questions! (i.e. not a bug / enhancment / documentation) package: typescript-estree Issues related to @typescript-eslint/typescript-estree labels Oct 29, 2019
@bradzacher
Copy link
Member Author

bradzacher commented Oct 31, 2019

I checked out your branch, installed and ran yarn lint.

This was my output
/Users/bradzacher/temp/client-modules-jg-eslint-fancy/packages/gamut/src/Form/Checkbox.tsx
  28:5  error  Form label must have ALL of the following types of associated control: nesting, id  jsx-a11y/label-has-for

/Users/bradzacher/temp/client-modules-jg-eslint-fancy/packages/gamut/src/Form/FormGroupLabel.tsx
  25:12  error  Form label must have ALL of the following types of associated control: nesting, id  jsx-a11y/label-has-for

/Users/bradzacher/temp/client-modules-jg-eslint-fancy/packages/gamut/src/Form/Radio.tsx
  43:7  error  Form label must have ALL of the following types of associated control: nesting, id  jsx-a11y/label-has-for

/Users/bradzacher/temp/client-modules-jg-eslint-fancy/packages/gamut/src/NotificationList/__tests__/NotificationList-test.js
  0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: packages/gamut/src/NotificationList/__tests__/NotificationList-test.js.
The file must be included in at least one of the projects provided

/Users/bradzacher/temp/client-modules-jg-eslint-fancy/packages/gamut/src/NotificationList/NotificationItem.tsx
  3:20  error  Parse errors in imported module 'moment': "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: node_modules/moment/src/moment.js.
The file must be included in at least one of the projects provided. (undefined:undefined)  import/default

/Users/bradzacher/temp/client-modules-jg-eslint-fancy/workspaces/gamut-storybook/__tests__/storybook-test.ts
  2:44  error  Parse errors in imported module '@storybook/addon-storyshots': "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: node_modules/@storybook/addon-storyshots/src/index.js.
The file must be included in at least one of the projects provided. (undefined:undefined)  import/named
  2:44  error  Parse errors in imported module '@storybook/addon-storyshots': "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: node_modules/@storybook/addon-storyshots/src/index.js.
The file must be included in at least one of the projects provided. (undefined:undefined)  import/default

✖ 7 problems (7 errors, 0 warnings)

Going through the list...


/Users/bradzacher/temp/client-modules-jg-eslint-fancy/packages/gamut/src/Form/Checkbox.tsx
  28:5  error  Form label must have ALL of the following types of associated control: nesting, id  jsx-a11y/label-has-for

/Users/bradzacher/temp/client-modules-jg-eslint-fancy/packages/gamut/src/Form/FormGroupLabel.tsx
  25:12  error  Form label must have ALL of the following types of associated control: nesting, id  jsx-a11y/label-has-for

/Users/bradzacher/temp/client-modules-jg-eslint-fancy/packages/gamut/src/Form/Radio.tsx
  43:7  error  Form label must have ALL of the following types of associated control: nesting, id  jsx-a11y/label-has-for

These are expected lint errors.


/Users/bradzacher/temp/client-modules-jg-eslint-fancy/packages/gamut/src/NotificationList/__tests__/NotificationList-test.js
  0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: packages/gamut/src/NotificationList/__tests__/NotificationList-test.js.
The file must be included in at least one of the projects provided

This an expected error is because you have a file with the same name (NotificationsList-test.tsx) in the same directory. TypeScript does not let us handle this. Nor does it tell us that this has happened - it just returns undefined when asked for the source file.
(maybe we could add some smarts in the error messaging to make this experience better).

See: #955


/Users/bradzacher/temp/client-modules-jg-eslint-fancy/packages/gamut/src/NotificationList/NotificationItem.tsx
  3:20  error  Parse errors in imported module 'moment': "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: node_modules/moment/src/moment.js.
The file must be included in at least one of the projects provided. (undefined:undefined)  import/default

/Users/bradzacher/temp/client-modules-jg-eslint-fancy/workspaces/gamut-storybook/__tests__/storybook-test.ts
  2:44  error  Parse errors in imported module '@storybook/addon-storyshots': "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: node_modules/@storybook/addon-storyshots/src/index.js.
The file must be included in at least one of the projects provided. (undefined:undefined)  import/named
  2:44  error  Parse errors in imported module '@storybook/addon-storyshots': "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: node_modules/@storybook/addon-storyshots/src/index.js.
The file must be included in at least one of the projects provided. (undefined:undefined)  import/default

These are errors which should not be happening.
Looking into it, it's because your lock file is resolving to the wrong version of eslint-module-utils. Your lock file is resolving the ^2.4.0 dependency declared by eslint-plugin-import to be 2.4.0, instead of 2.4.1.

Why is this a problem? 2.4.1 contains a fix for eslint-plugin-import which I submitted to make it work faster and better with our parser: import-js/eslint-plugin-import#1409

How to fix it? Delete these lines from your yarn lock file:

https://github.com/Codecademy/client-modules/blob/79885ee777890cdfdb1d16d5936d7912d6eac504/yarn.lock#L7099-L7122

and then re-install in the root (I did a yarn --force to be sure), then yarn will fetch the correct (latest) version of eslint-module-utils.

I have raised import-js/eslint-plugin-import#1530 about this incorrect dependency in the published eslint-plugin-import pacakge.

@JoshuaKGoldberg
Copy link
Member

🙌 thanks so much for looking into our configuration & filing the issues! You were right about everything. 😺

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
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 question Questions! (i.e. not a bug / enhancment / documentation)
Projects
None yet
Development

No branches or pull requests

2 participants