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

Commit 354953d

Browse files
JLHwunghzoo
authored andcommitted
fix: require eslint dependencies from eslint base (#794)
1 parent 48f6d78 commit 354953d

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

lib/analyze-scope.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
"use strict";
22

33
const t = require("@babel/types");
4-
const escope = require("eslint-scope");
5-
const Definition = require("eslint-scope/lib/definition").Definition;
6-
const OriginalPatternVisitor = require("eslint-scope/lib/pattern-visitor");
7-
const OriginalReferencer = require("eslint-scope/lib/referencer");
4+
const requireFromESLint = require("./require-from-eslint");
5+
6+
const escope = requireFromESLint("eslint-scope");
7+
const Definition = requireFromESLint("eslint-scope/lib/definition").Definition;
8+
const OriginalPatternVisitor = requireFromESLint(
9+
"eslint-scope/lib/pattern-visitor"
10+
);
11+
const OriginalReferencer = requireFromESLint("eslint-scope/lib/referencer");
812
const fallback = require("eslint-visitor-keys").getKeys;
913
const childVisitorKeys = require("./visitor-keys");
1014

lib/require-from-eslint.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"use strict";
2+
3+
const resolve = require("resolve");
4+
const eslintBase = require.resolve("eslint");
5+
6+
module.exports = function requireFromESLint(id) {
7+
const path = resolve.sync(id, { basedir: eslintBase });
8+
return require(path);
9+
};

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"@babel/parser": "^7.0.0",
1616
"@babel/traverse": "^7.0.0",
1717
"@babel/types": "^7.0.0",
18-
"eslint-scope": "3.7.1",
19-
"eslint-visitor-keys": "^1.0.0"
18+
"eslint-visitor-keys": "^1.0.0",
19+
"resolve": "^1.12.0"
2020
},
2121
"scripts": {
2222
"test": "npm run lint && npm run test-only",

yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,11 @@ path-parse@^1.0.5:
17541754
version "1.0.5"
17551755
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1"
17561756

1757+
path-parse@^1.0.6:
1758+
version "1.0.6"
1759+
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
1760+
integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==
1761+
17571762
path-type@^2.0.0:
17581763
version "2.0.0"
17591764
resolved "https://registry.yarnpkg.com/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73"
@@ -1894,6 +1899,13 @@ resolve-url@^0.2.1:
18941899
version "0.2.1"
18951900
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
18961901

1902+
resolve@^1.12.0:
1903+
version "1.12.0"
1904+
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.12.0.tgz#3fc644a35c84a48554609ff26ec52b66fa577df6"
1905+
integrity sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==
1906+
dependencies:
1907+
path-parse "^1.0.6"
1908+
18971909
resolve@^1.5.0:
18981910
version "1.5.0"
18991911
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36"

0 commit comments

Comments
 (0)