Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

WIP: Add the guide to work with TypeScript #51

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tetsuharuohzeki
Copy link
Contributor

No description provided.


## `eslint-plugin-import`

Add the following config for your
Copy link
Contributor Author

@tetsuharuohzeki tetsuharuohzeki Mar 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seem it's better to write the following sample code. But I have not much time to figured out yet the details of why this code works and why we don't have to use....

'use strict';

const JS_EXTENSION = ['.mjs', '.js', '.jsx'];
const TS_EXTENSION = ['.ts', '.tsx', '.d.ts'];
const ALL_EXTENSION = [...TS_EXTENSION, ...JS_EXTENSION];


module.exports = {
    'settings': {
        // It might be better to _not_ specifying this if you use TypeScript with some type checker.
        // Then you can detect what a symbol is exported from a module by static checking by the typechecker.
        'import/extensions': ALL_EXTENSION,

        // I don't seem that you don't have to use this
        // if you use `'@typescript-eslint` plugin to lint your typescript.
        // Then eslint-plugin-impor will not switch the parser and use the more globally specified.
        'import/parsers': {
            '@typescript-eslint/parser': TS_EXTENSION,
        },

        'import/resolver': {
            'node': {
                'extensions': ALL_EXTENSION,
            },
        },

        'import/ignore': [
            'node_modules',
        ],
    },
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, I seem it's safe to only specify import/resolver for TypeScript project....

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant