Eslint configuration for Meteor 3, Eslint, TypeScript and WebStorm

I just set-up a new Meteor project using meteor create using the typescript setup and wanted to add the current eslint to it. I’d also like to use it for auto-formatting in WebStorm.

However, the docs in the Meteor guide are a bit outdated, they only describe how to include the @meteorjs/eslint-config-meteor which hasn’t been updated for a while.

What is the best way to get a working eslint 9 configuration that supports Meteor, Mocha, TypeScript, and React?

Do you have an eslint configuration for Eslint 8 such as an .eslintrc file?

Yes, but this stems from a Meteor project that was not using TypeScript. I tried to convert it using the automatic converter, but this failed.

module.exports = {
    parser: 'babel-eslint',
    parserOptions: {
        sourceType: 'module',
        ecmaVersion: 2019
    },
    plugins: ['babel', 'mocha'],
    extends: [
        'standard',
        'standard-react',
        'plugin:import/errors',
        'plugin:import/warnings',
        'plugin:mocha/recommended'
    ],
    env: {
        node: true,
        browser: true,
        mocha: true
    },
    rules: {
        'babel/semi': 0,
        'comma-dangle': 0,
        'jsx-quotes': ['error', 'prefer-double'],
        'no-return-assign': 0,
        'no-trailing-spaces': 0,
        'react/react-in-jsx-scope': 0,
        semi: [2, 'always'],
        'react/prop-types': 0,
        'react/jsx-tag-spacing': 0,
        'space-before-function-paren': 0,
        indent: ['error', 2, {SwitchCase: 1, ignoredNodes: ['ConditionalExpression *']}],
        eqeqeq: ['error', 'always']
    },
    settings: {
        'import/resolver': {
            meteor: {
                extensions: ['.js', '.jsx']
            }
        }
    }
};

I also tried to setup this old file using the old eslint to auto-format TypeScript files. But this also failed. I ran into a “missing module eslint/use-at-your-own-risk” error. Seems as something is not compatible.

I don’t care if it’s actually eslint 9, could also work with 8 or older, as long as TypeScript auto-formatting on save works in WebStorm.

Did you use this?

meteor npm install @eslint/compat globals @eslint/js @eslint/eslintrc -D --force
meteor npm install --save-dev eslint-config-standard eslint-plugin-promise eslint-plugin-import eslint-plugin-n --force

npx @eslint/migrate-config .eslintrc

from here: Migrate to ESLint 9.x. In this article, I share some… | by Duy NG | ekino-france | Medium
This is what I used yesterday in order to migrate from 8 t 9

I used that npx, but not the rest. Will try it.

But as stated above, I do not actually care about eslint 9 vs. 8. All I need is a working eslint setup that supports Meteor 3 and auto-format on save for TypeScript in WebStorm.

I just returned to my old config, and it kinda works even with TypeScript. But I get a couple of errors, e.g. here:

Also, keywords like as are flagged as an error. So there seems to be something wrong with the TypeScript setup (I’m just using the bare-bone Meteor scaffold right now).

I see you use standard for JS. I believe there is also a ts-standard for TS. You also need to make sure Webstorm has TS enabled (I think by default is enabled, I had to turned it of before performance issues with Material UI) and beware of Webstorm + TS issues such as: https://youtrack.jetbrains.com/issue/WEB-52943/Meta-High-CPU-usage-on-resolve-or-types-evaluation-in-TypeScript

1 Like

Thanks. I now got it working with eslint 8. It’s really crazy how long these configs take to adapt :slight_smile:

The only thing I did not get working is the resolver for module names like meteor/meteor. Seems as if the Meteor module resolver is not compatible with the TypeScript parser.

Are you using https://typescript-eslint.io/ ?

I’m using the parser right now, but not the new configuration file setup.