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
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/WITH_TYPESCRIPT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Example to work with TypeScript

_This is non-normative guide to use this presets with TypeScript.
By changing versions of each of plugins, this guide might not works_.


## `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....