From 83d22d4db19013dcc29a9ce610bb14f01ecd1999 Mon Sep 17 00:00:00 2001 From: Dan Hedgecock Date: Sat, 12 Sep 2020 13:16:08 -0700 Subject: [PATCH] =?UTF-8?q?Fix:=20Check=20for=20exports=20from=20TS=20file?= =?UTF-8?q?s=20always=20=F0=9F=8E=8A=20(#241)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/__snapshots__/index.spec.js.snap | 34 ++++++++++++++++++---------- src/index.js | 9 ++++++-- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/__snapshots__/index.spec.js.snap b/src/__snapshots__/index.spec.js.snap index 4eb3274..86bea23 100644 --- a/src/__snapshots__/index.spec.js.snap +++ b/src/__snapshots__/index.spec.js.snap @@ -114,12 +114,9 @@ Object { "valid-typeof": "off", }, "settings": Object { - "import/extensions": Array [ - ".js", - ".jsx", - ".ts", - ".tsx", - ".d.ts", + "import/external-module-folders": Array [ + "node_modules", + "node_modules/@types", ], "import/parsers": Object { "@typescript-eslint/parser": Array [ @@ -1009,6 +1006,14 @@ Object { }, "settings": Object { "import/cache": 60, + "import/extensions": Array [ + ".js", + ".jsx", + ".mjs", + ".ts", + ".tsx", + ".d.ts", + ], "import/internal-regex": /\\^@\\\\//, "import/resolver": "/mock/test/path", "react": Object { @@ -1137,12 +1142,9 @@ Object { "valid-typeof": "off", }, "settings": Object { - "import/extensions": Array [ - ".js", - ".jsx", - ".ts", - ".tsx", - ".d.ts", + "import/external-module-folders": Array [ + "node_modules", + "node_modules/@types", ], "import/parsers": Object { "@typescript-eslint/parser": Array [ @@ -2453,6 +2455,14 @@ Object { }, "settings": Object { "import/cache": 60, + "import/extensions": Array [ + ".js", + ".jsx", + ".mjs", + ".ts", + ".tsx", + ".d.ts", + ], "import/internal-regex": /\\^@\\\\//, "import/resolver": "/mock/test/path", "react": Object { diff --git a/src/index.js b/src/index.js index 8299609..ac3c245 100644 --- a/src/index.js +++ b/src/index.js @@ -125,6 +125,10 @@ module.exports = function eloquence({ // Use webpack to resolve projects to handle src alias 'import/resolver': path.resolve(__dirname, 'resolver'), + // Extensions that will be parsed to check for exports, including JS, TS, + // React extenions, Node ESM, and type definitions + 'import/extensions': ['.js', '.jsx', '.mjs', '.ts', '.tsx', '.d.ts'], + // --- React plugin settings --- 'react': { pragma: 'React', @@ -203,9 +207,10 @@ module.exports = function eloquence({ plugins: ['@typescript-eslint'], settings: { - // https://github.com/benmosher/eslint-plugin-import/blob/master/config/typescript.js - 'import/extensions': ['.js', '.jsx', '.ts', '.tsx', '.d.ts'], + // Config from plugin:import/typescript + 'import/external-module-folders': ['node_modules', 'node_modules/@types'], 'import/parsers': { + // Use the ESLint-TS parser when parsing TS and type definition files '@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'], }, },