Specify babel module resolver options once
diff --git a/.eslintrc.js b/.eslintrc.js
index cb6c43c..526cfc3 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,3 +1,12 @@
+const babel = require('@babel/core');
+
+// Use the root babel.config.js for module resolution.
+// Relevant issue: tleunen/eslint-import-resolver-babel-module#89
+const babelOptions = babel.loadOptions({ cwd: __dirname });
+const babelModuleResolver = babelOptions.plugins.find(
+ ({ key }) => key === 'module-resolver',
+);
+
module.exports = {
root: true,
env: {
@@ -44,11 +53,7 @@
},
settings: {
'import/resolver': {
- 'babel-module': {
- alias: {
- '^@annotator/(.+)$': '@annotator/\\1/src/index.js',
- },
- },
+ 'babel-module': babelModuleResolver.options,
},
},
overrides: [
diff --git a/babel.config.js b/babel.config.js
index 6469948..ffb36ab 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -35,7 +35,7 @@
};
// Options for the module-resolver plugin.
- // Used for resolving source files during development and testing.
+ // Used for resolving source files during development.
let resolverOptions = {
alias: {
'^@annotator/(.+)$': '@annotator/\\1/src/index.js',
@@ -54,7 +54,7 @@
plugins: [
'preserve-comment-header',
['@babel/transform-runtime', runtimeOptions],
- ...(DEV || TEST ? [['module-resolver', resolverOptions]] : []),
+ ...(DEV ? [['module-resolver', resolverOptions]] : []),
...(TEST ? ['istanbul'] : []),
],
presets: [['@babel/env', envOptions]],