Wednesday, 17 February 2021

Shared eslint config cannot find node modules

I have multiple apps that I would like to share the same eslint config:

- project_root/
    - app1/
        - node_modules/
        - eslint.rc
    - app2/
        - node_modules/
        - eslint.rc
    - app3/
        - node_modules/
        - eslint.rc
    - eslint.rc

Each app has the same config:

module.exports = {
  extends: [
    '../.eslintrc',
  ],
};

And in the root I want to have everything configured:

module.exports = {
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: 'tsconfig.json',
    sourceType: 'module',
  },
  plugins: ['@typescript-eslint/eslint-plugin'],
  extends: [
    'plugin:@typescript-eslint/eslint-recommended',
    'plugin:@typescript-eslint/recommended',
    'prettier',
    'prettier/@typescript-eslint',
  ],
  root: true,
  env: {
    node: true,
    jest: true,
  },
  rules: {},
};

But now every app throws error that it cant find the node modules:

Failed to load parser '@typescript-eslint/parser' declared in '.eslintrc.js » ../.eslintrc': Cannot find module '@typescript-eslint/parser'`.

I don't have any node_modules in the root and I would like to avoid it.



from Shared eslint config cannot find node modules

No comments:

Post a Comment