immosquare-cleaner 0.1.34 → 0.1.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/immosquare-cleaner/version.rb +1 -1
- data/lib/immosquare-cleaner.rb +2 -2
- data/linters/eslint.config.mjs +30 -0
- data/linters/rubocop-3.2.2.yml +2 -0
- data/node_modules/function-bind/README.md +27 -25
- data/node_modules/function-bind/implementation.js +12 -44
- data/node_modules/function-bind/package.json +14 -38
- data/node_modules/is-core-module/CHANGELOG.md +0 -7
- data/node_modules/is-core-module/index.js +2 -2
- data/node_modules/is-core-module/package.json +4 -4
- data/package.json +2 -4
- metadata +3 -180
- data/linters/eslintrc.json +0 -57
- data/node_modules/.bin/rimraf +0 -1
- data/node_modules/eslint-config-airbnb-base/CHANGELOG.md +0 -374
- data/node_modules/eslint-config-airbnb-base/LICENSE.md +0 -21
- data/node_modules/eslint-config-airbnb-base/README.md +0 -112
- data/node_modules/eslint-config-airbnb-base/index.js +0 -17
- data/node_modules/eslint-config-airbnb-base/legacy.js +0 -34
- data/node_modules/eslint-config-airbnb-base/node_modules/semver/LICENSE +0 -15
- data/node_modules/eslint-config-airbnb-base/node_modules/semver/README.md +0 -443
- data/node_modules/eslint-config-airbnb-base/node_modules/semver/bin/semver.js +0 -174
- data/node_modules/eslint-config-airbnb-base/node_modules/semver/package.json +0 -38
- data/node_modules/eslint-config-airbnb-base/node_modules/semver/range.bnf +0 -16
- data/node_modules/eslint-config-airbnb-base/node_modules/semver/semver.js +0 -1643
- data/node_modules/eslint-config-airbnb-base/package.json +0 -95
- data/node_modules/eslint-config-airbnb-base/rules/best-practices.js +0 -408
- data/node_modules/eslint-config-airbnb-base/rules/errors.js +0 -179
- data/node_modules/eslint-config-airbnb-base/rules/es6.js +0 -185
- data/node_modules/eslint-config-airbnb-base/rules/imports.js +0 -273
- data/node_modules/eslint-config-airbnb-base/rules/node.js +0 -43
- data/node_modules/eslint-config-airbnb-base/rules/strict.js +0 -6
- data/node_modules/eslint-config-airbnb-base/rules/style.js +0 -529
- data/node_modules/eslint-config-airbnb-base/rules/variables.js +0 -56
- data/node_modules/eslint-config-airbnb-base/test/requires.js +0 -13
- data/node_modules/eslint-config-airbnb-base/test/test-base.js +0 -32
- data/node_modules/eslint-config-airbnb-base/whitespace-async.js +0 -96
- data/node_modules/eslint-config-airbnb-base/whitespace.js +0 -102
- data/node_modules/eslint-plugin-import/CHANGELOG.md +0 -1925
- data/node_modules/eslint-plugin-import/CONTRIBUTING.md +0 -84
- data/node_modules/eslint-plugin-import/LICENSE +0 -22
- data/node_modules/eslint-plugin-import/README.md +0 -500
- data/node_modules/eslint-plugin-import/RELEASE.md +0 -54
- data/node_modules/eslint-plugin-import/SECURITY.md +0 -11
- data/node_modules/eslint-plugin-import/config/electron.js +0 -8
- data/node_modules/eslint-plugin-import/config/errors.js +0 -14
- data/node_modules/eslint-plugin-import/config/react-native.js +0 -13
- data/node_modules/eslint-plugin-import/config/react.js +0 -18
- data/node_modules/eslint-plugin-import/config/recommended.js +0 -28
- data/node_modules/eslint-plugin-import/config/stage-0.js +0 -12
- data/node_modules/eslint-plugin-import/config/typescript.js +0 -34
- data/node_modules/eslint-plugin-import/config/warnings.js +0 -12
- data/node_modules/eslint-plugin-import/docs/rules/consistent-type-specifier-style.md +0 -91
- data/node_modules/eslint-plugin-import/docs/rules/default.md +0 -72
- data/node_modules/eslint-plugin-import/docs/rules/dynamic-import-chunkname.md +0 -92
- data/node_modules/eslint-plugin-import/docs/rules/export.md +0 -37
- data/node_modules/eslint-plugin-import/docs/rules/exports-last.md +0 -51
- data/node_modules/eslint-plugin-import/docs/rules/extensions.md +0 -174
- data/node_modules/eslint-plugin-import/docs/rules/first.md +0 -75
- data/node_modules/eslint-plugin-import/docs/rules/group-exports.md +0 -118
- data/node_modules/eslint-plugin-import/docs/rules/imports-first.md +0 -9
- data/node_modules/eslint-plugin-import/docs/rules/max-dependencies.md +0 -70
- data/node_modules/eslint-plugin-import/docs/rules/named.md +0 -102
- data/node_modules/eslint-plugin-import/docs/rules/namespace.md +0 -106
- data/node_modules/eslint-plugin-import/docs/rules/newline-after-import.md +0 -167
- data/node_modules/eslint-plugin-import/docs/rules/no-absolute-path.md +0 -54
- data/node_modules/eslint-plugin-import/docs/rules/no-amd.md +0 -37
- data/node_modules/eslint-plugin-import/docs/rules/no-anonymous-default-export.md +0 -83
- data/node_modules/eslint-plugin-import/docs/rules/no-commonjs.md +0 -96
- data/node_modules/eslint-plugin-import/docs/rules/no-cycle.md +0 -111
- data/node_modules/eslint-plugin-import/docs/rules/no-default-export.md +0 -65
- data/node_modules/eslint-plugin-import/docs/rules/no-deprecated.md +0 -62
- data/node_modules/eslint-plugin-import/docs/rules/no-duplicates.md +0 -109
- data/node_modules/eslint-plugin-import/docs/rules/no-dynamic-require.md +0 -25
- data/node_modules/eslint-plugin-import/docs/rules/no-empty-named-blocks.md +0 -49
- data/node_modules/eslint-plugin-import/docs/rules/no-extraneous-dependencies.md +0 -139
- data/node_modules/eslint-plugin-import/docs/rules/no-import-module-exports.md +0 -81
- data/node_modules/eslint-plugin-import/docs/rules/no-internal-modules.md +0 -136
- data/node_modules/eslint-plugin-import/docs/rules/no-mutable-exports.md +0 -54
- data/node_modules/eslint-plugin-import/docs/rules/no-named-as-default-member.md +0 -52
- data/node_modules/eslint-plugin-import/docs/rules/no-named-as-default.md +0 -53
- data/node_modules/eslint-plugin-import/docs/rules/no-named-default.md +0 -36
- data/node_modules/eslint-plugin-import/docs/rules/no-named-export.md +0 -79
- data/node_modules/eslint-plugin-import/docs/rules/no-namespace.md +0 -44
- data/node_modules/eslint-plugin-import/docs/rules/no-nodejs-modules.md +0 -42
- data/node_modules/eslint-plugin-import/docs/rules/no-relative-packages.md +0 -70
- data/node_modules/eslint-plugin-import/docs/rules/no-relative-parent-imports.md +0 -123
- data/node_modules/eslint-plugin-import/docs/rules/no-restricted-paths.md +0 -198
- data/node_modules/eslint-plugin-import/docs/rules/no-self-import.md +0 -32
- data/node_modules/eslint-plugin-import/docs/rules/no-unassigned-import.md +0 -60
- data/node_modules/eslint-plugin-import/docs/rules/no-unresolved.md +0 -110
- data/node_modules/eslint-plugin-import/docs/rules/no-unused-modules.md +0 -125
- data/node_modules/eslint-plugin-import/docs/rules/no-useless-path-segments.md +0 -85
- data/node_modules/eslint-plugin-import/docs/rules/no-webpack-loader-syntax.md +0 -39
- data/node_modules/eslint-plugin-import/docs/rules/order.md +0 -365
- data/node_modules/eslint-plugin-import/docs/rules/prefer-default-export.md +0 -185
- data/node_modules/eslint-plugin-import/docs/rules/unambiguous.md +0 -57
- data/node_modules/eslint-plugin-import/lib/ExportMap.js +0 -856
- data/node_modules/eslint-plugin-import/lib/core/importType.js +0 -129
- data/node_modules/eslint-plugin-import/lib/core/packagePath.js +0 -22
- data/node_modules/eslint-plugin-import/lib/core/staticRequire.js +0 -11
- data/node_modules/eslint-plugin-import/lib/docsUrl.js +0 -8
- data/node_modules/eslint-plugin-import/lib/importDeclaration.js +0 -5
- data/node_modules/eslint-plugin-import/lib/index.js +0 -71
- data/node_modules/eslint-plugin-import/lib/rules/consistent-type-specifier-style.js +0 -221
- data/node_modules/eslint-plugin-import/lib/rules/default.js +0 -40
- data/node_modules/eslint-plugin-import/lib/rules/dynamic-import-chunkname.js +0 -120
- data/node_modules/eslint-plugin-import/lib/rules/export.js +0 -250
- data/node_modules/eslint-plugin-import/lib/rules/exports-last.js +0 -40
- data/node_modules/eslint-plugin-import/lib/rules/extensions.js +0 -193
- data/node_modules/eslint-plugin-import/lib/rules/first.js +0 -144
- data/node_modules/eslint-plugin-import/lib/rules/group-exports.js +0 -155
- data/node_modules/eslint-plugin-import/lib/rules/imports-first.js +0 -16
- data/node_modules/eslint-plugin-import/lib/rules/max-dependencies.js +0 -60
- data/node_modules/eslint-plugin-import/lib/rules/named.js +0 -143
- data/node_modules/eslint-plugin-import/lib/rules/namespace.js +0 -218
- data/node_modules/eslint-plugin-import/lib/rules/newline-after-import.js +0 -237
- data/node_modules/eslint-plugin-import/lib/rules/no-absolute-path.js +0 -40
- data/node_modules/eslint-plugin-import/lib/rules/no-amd.js +0 -47
- data/node_modules/eslint-plugin-import/lib/rules/no-anonymous-default-export.js +0 -103
- data/node_modules/eslint-plugin-import/lib/rules/no-commonjs.js +0 -141
- data/node_modules/eslint-plugin-import/lib/rules/no-cycle.js +0 -158
- data/node_modules/eslint-plugin-import/lib/rules/no-default-export.js +0 -43
- data/node_modules/eslint-plugin-import/lib/rules/no-deprecated.js +0 -138
- data/node_modules/eslint-plugin-import/lib/rules/no-duplicates.js +0 -354
- data/node_modules/eslint-plugin-import/lib/rules/no-dynamic-require.js +0 -77
- data/node_modules/eslint-plugin-import/lib/rules/no-empty-named-blocks.js +0 -105
- data/node_modules/eslint-plugin-import/lib/rules/no-extraneous-dependencies.js +0 -301
- data/node_modules/eslint-plugin-import/lib/rules/no-import-module-exports.js +0 -85
- data/node_modules/eslint-plugin-import/lib/rules/no-internal-modules.js +0 -144
- data/node_modules/eslint-plugin-import/lib/rules/no-mutable-exports.js +0 -59
- data/node_modules/eslint-plugin-import/lib/rules/no-named-as-default-member.js +0 -96
- data/node_modules/eslint-plugin-import/lib/rules/no-named-as-default.js +0 -45
- data/node_modules/eslint-plugin-import/lib/rules/no-named-default.js +0 -31
- data/node_modules/eslint-plugin-import/lib/rules/no-named-export.js +0 -39
- data/node_modules/eslint-plugin-import/lib/rules/no-namespace.js +0 -175
- data/node_modules/eslint-plugin-import/lib/rules/no-nodejs-modules.js +0 -44
- data/node_modules/eslint-plugin-import/lib/rules/no-relative-packages.js +0 -71
- data/node_modules/eslint-plugin-import/lib/rules/no-relative-parent-imports.js +0 -48
- data/node_modules/eslint-plugin-import/lib/rules/no-restricted-paths.js +0 -245
- data/node_modules/eslint-plugin-import/lib/rules/no-self-import.js +0 -39
- data/node_modules/eslint-plugin-import/lib/rules/no-unassigned-import.js +0 -79
- data/node_modules/eslint-plugin-import/lib/rules/no-unresolved.js +0 -60
- data/node_modules/eslint-plugin-import/lib/rules/no-unused-modules.js +0 -945
- data/node_modules/eslint-plugin-import/lib/rules/no-useless-path-segments.js +0 -147
- data/node_modules/eslint-plugin-import/lib/rules/no-webpack-loader-syntax.js +0 -26
- data/node_modules/eslint-plugin-import/lib/rules/order.js +0 -785
- data/node_modules/eslint-plugin-import/lib/rules/prefer-default-export.js +0 -116
- data/node_modules/eslint-plugin-import/lib/rules/unambiguous.js +0 -38
- data/node_modules/eslint-plugin-import/memo-parser/LICENSE +0 -22
- data/node_modules/eslint-plugin-import/memo-parser/README.md +0 -21
- data/node_modules/eslint-plugin-import/memo-parser/index.js +0 -41
- data/node_modules/eslint-plugin-import/node_modules/debug/CHANGELOG.md +0 -395
- data/node_modules/eslint-plugin-import/node_modules/debug/LICENSE +0 -19
- data/node_modules/eslint-plugin-import/node_modules/debug/README.md +0 -437
- data/node_modules/eslint-plugin-import/node_modules/debug/node.js +0 -1
- data/node_modules/eslint-plugin-import/node_modules/debug/node_modules/ms/index.js +0 -162
- data/node_modules/eslint-plugin-import/node_modules/debug/node_modules/ms/license.md +0 -21
- data/node_modules/eslint-plugin-import/node_modules/debug/node_modules/ms/package.json +0 -38
- data/node_modules/eslint-plugin-import/node_modules/debug/node_modules/ms/readme.md +0 -59
- data/node_modules/eslint-plugin-import/node_modules/debug/package.json +0 -51
- data/node_modules/eslint-plugin-import/node_modules/debug/src/browser.js +0 -180
- data/node_modules/eslint-plugin-import/node_modules/debug/src/common.js +0 -249
- data/node_modules/eslint-plugin-import/node_modules/debug/src/index.js +0 -12
- data/node_modules/eslint-plugin-import/node_modules/debug/src/node.js +0 -177
- data/node_modules/eslint-plugin-import/node_modules/doctrine/CHANGELOG.md +0 -94
- data/node_modules/eslint-plugin-import/node_modules/doctrine/LICENSE +0 -177
- data/node_modules/eslint-plugin-import/node_modules/doctrine/LICENSE.closure-compiler +0 -202
- data/node_modules/eslint-plugin-import/node_modules/doctrine/LICENSE.esprima +0 -19
- data/node_modules/eslint-plugin-import/node_modules/doctrine/README.md +0 -165
- data/node_modules/eslint-plugin-import/node_modules/doctrine/lib/doctrine.js +0 -899
- data/node_modules/eslint-plugin-import/node_modules/doctrine/lib/typed.js +0 -1305
- data/node_modules/eslint-plugin-import/node_modules/doctrine/lib/utility.js +0 -35
- data/node_modules/eslint-plugin-import/node_modules/doctrine/package.json +0 -57
- data/node_modules/eslint-plugin-import/node_modules/minimatch/LICENSE +0 -15
- data/node_modules/eslint-plugin-import/node_modules/minimatch/README.md +0 -230
- data/node_modules/eslint-plugin-import/node_modules/minimatch/minimatch.js +0 -947
- data/node_modules/eslint-plugin-import/node_modules/minimatch/node_modules/brace-expansion/LICENSE +0 -21
- data/node_modules/eslint-plugin-import/node_modules/minimatch/node_modules/brace-expansion/README.md +0 -129
- data/node_modules/eslint-plugin-import/node_modules/minimatch/node_modules/brace-expansion/index.js +0 -201
- data/node_modules/eslint-plugin-import/node_modules/minimatch/node_modules/brace-expansion/package.json +0 -47
- data/node_modules/eslint-plugin-import/node_modules/minimatch/package.json +0 -33
- data/node_modules/eslint-plugin-import/node_modules/semver/LICENSE +0 -15
- data/node_modules/eslint-plugin-import/node_modules/semver/README.md +0 -443
- data/node_modules/eslint-plugin-import/node_modules/semver/bin/semver.js +0 -174
- data/node_modules/eslint-plugin-import/node_modules/semver/package.json +0 -38
- data/node_modules/eslint-plugin-import/node_modules/semver/range.bnf +0 -16
- data/node_modules/eslint-plugin-import/node_modules/semver/semver.js +0 -1643
- data/node_modules/eslint-plugin-import/package.json +0 -124
- data/node_modules/function-bind/CHANGELOG.md +0 -136
@@ -1,301 +0,0 @@
|
|
1
|
-
'use strict';var _slicedToArray = function () {function sliceIterator(arr, i) {var _arr = [];var _n = true;var _d = false;var _e = undefined;try {for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {_arr.push(_s.value);if (i && _arr.length === i) break;}} catch (err) {_d = true;_e = err;} finally {try {if (!_n && _i["return"]) _i["return"]();} finally {if (_d) throw _e;}}return _arr;}return function (arr, i) {if (Array.isArray(arr)) {return arr;} else if (Symbol.iterator in Object(arr)) {return sliceIterator(arr, i);} else {throw new TypeError("Invalid attempt to destructure non-iterable instance");}};}();var _path = require('path');var _path2 = _interopRequireDefault(_path);
|
2
|
-
var _fs = require('fs');var _fs2 = _interopRequireDefault(_fs);
|
3
|
-
var _pkgUp = require('eslint-module-utils/pkgUp');var _pkgUp2 = _interopRequireDefault(_pkgUp);
|
4
|
-
var _minimatch = require('minimatch');var _minimatch2 = _interopRequireDefault(_minimatch);
|
5
|
-
var _resolve = require('eslint-module-utils/resolve');var _resolve2 = _interopRequireDefault(_resolve);
|
6
|
-
var _moduleVisitor = require('eslint-module-utils/moduleVisitor');var _moduleVisitor2 = _interopRequireDefault(_moduleVisitor);
|
7
|
-
var _importType = require('../core/importType');var _importType2 = _interopRequireDefault(_importType);
|
8
|
-
var _packagePath = require('../core/packagePath');
|
9
|
-
var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}
|
10
|
-
|
11
|
-
var depFieldCache = new Map();
|
12
|
-
|
13
|
-
function hasKeys() {var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
14
|
-
return Object.keys(obj).length > 0;
|
15
|
-
}
|
16
|
-
|
17
|
-
function arrayOrKeys(arrayOrObject) {
|
18
|
-
return Array.isArray(arrayOrObject) ? arrayOrObject : Object.keys(arrayOrObject);
|
19
|
-
}
|
20
|
-
|
21
|
-
function readJSON(jsonPath, throwException) {
|
22
|
-
try {
|
23
|
-
return JSON.parse(_fs2['default'].readFileSync(jsonPath, 'utf8'));
|
24
|
-
} catch (err) {
|
25
|
-
if (throwException) {
|
26
|
-
throw err;
|
27
|
-
}
|
28
|
-
}
|
29
|
-
}
|
30
|
-
|
31
|
-
function extractDepFields(pkg) {
|
32
|
-
return {
|
33
|
-
dependencies: pkg.dependencies || {},
|
34
|
-
devDependencies: pkg.devDependencies || {},
|
35
|
-
optionalDependencies: pkg.optionalDependencies || {},
|
36
|
-
peerDependencies: pkg.peerDependencies || {},
|
37
|
-
// BundledDeps should be in the form of an array, but object notation is also supported by
|
38
|
-
// `npm`, so we convert it to an array if it is an object
|
39
|
-
bundledDependencies: arrayOrKeys(pkg.bundleDependencies || pkg.bundledDependencies || []) };
|
40
|
-
|
41
|
-
}
|
42
|
-
|
43
|
-
function getPackageDepFields(packageJsonPath, throwAtRead) {
|
44
|
-
if (!depFieldCache.has(packageJsonPath)) {
|
45
|
-
var depFields = extractDepFields(readJSON(packageJsonPath, throwAtRead));
|
46
|
-
depFieldCache.set(packageJsonPath, depFields);
|
47
|
-
}
|
48
|
-
|
49
|
-
return depFieldCache.get(packageJsonPath);
|
50
|
-
}
|
51
|
-
|
52
|
-
function getDependencies(context, packageDir) {
|
53
|
-
var paths = [];
|
54
|
-
try {
|
55
|
-
var packageContent = {
|
56
|
-
dependencies: {},
|
57
|
-
devDependencies: {},
|
58
|
-
optionalDependencies: {},
|
59
|
-
peerDependencies: {},
|
60
|
-
bundledDependencies: [] };
|
61
|
-
|
62
|
-
|
63
|
-
if (packageDir && packageDir.length > 0) {
|
64
|
-
if (!Array.isArray(packageDir)) {
|
65
|
-
paths = [_path2['default'].resolve(packageDir)];
|
66
|
-
} else {
|
67
|
-
paths = packageDir.map(function (dir) {return _path2['default'].resolve(dir);});
|
68
|
-
}
|
69
|
-
}
|
70
|
-
|
71
|
-
if (paths.length > 0) {
|
72
|
-
// use rule config to find package.json
|
73
|
-
paths.forEach(function (dir) {
|
74
|
-
var packageJsonPath = _path2['default'].join(dir, 'package.json');
|
75
|
-
var _packageContent = getPackageDepFields(packageJsonPath, true);
|
76
|
-
Object.keys(packageContent).forEach(function (depsKey) {
|
77
|
-
Object.assign(packageContent[depsKey], _packageContent[depsKey]);
|
78
|
-
});
|
79
|
-
});
|
80
|
-
} else {
|
81
|
-
var packageJsonPath = (0, _pkgUp2['default'])({
|
82
|
-
cwd: context.getPhysicalFilename ? context.getPhysicalFilename() : context.getFilename(),
|
83
|
-
normalize: false });
|
84
|
-
|
85
|
-
|
86
|
-
// use closest package.json
|
87
|
-
Object.assign(
|
88
|
-
packageContent,
|
89
|
-
getPackageDepFields(packageJsonPath, false));
|
90
|
-
|
91
|
-
}
|
92
|
-
|
93
|
-
if (![
|
94
|
-
packageContent.dependencies,
|
95
|
-
packageContent.devDependencies,
|
96
|
-
packageContent.optionalDependencies,
|
97
|
-
packageContent.peerDependencies,
|
98
|
-
packageContent.bundledDependencies].
|
99
|
-
some(hasKeys)) {
|
100
|
-
return null;
|
101
|
-
}
|
102
|
-
|
103
|
-
return packageContent;
|
104
|
-
} catch (e) {
|
105
|
-
if (paths.length > 0 && e.code === 'ENOENT') {
|
106
|
-
context.report({
|
107
|
-
message: 'The package.json file could not be found.',
|
108
|
-
loc: { line: 0, column: 0 } });
|
109
|
-
|
110
|
-
}
|
111
|
-
if (e.name === 'JSONError' || e instanceof SyntaxError) {
|
112
|
-
context.report({
|
113
|
-
message: 'The package.json file could not be parsed: ' + String(e.message),
|
114
|
-
loc: { line: 0, column: 0 } });
|
115
|
-
|
116
|
-
}
|
117
|
-
|
118
|
-
return null;
|
119
|
-
}
|
120
|
-
}
|
121
|
-
|
122
|
-
function missingErrorMessage(packageName) {
|
123
|
-
return '\'' + String(packageName) + '\' should be listed in the project\'s dependencies. Run \'npm i -S ' + String(packageName) + '\' to add it';
|
124
|
-
}
|
125
|
-
|
126
|
-
function devDepErrorMessage(packageName) {
|
127
|
-
return '\'' + String(packageName) + '\' should be listed in the project\'s dependencies, not devDependencies.';
|
128
|
-
}
|
129
|
-
|
130
|
-
function optDepErrorMessage(packageName) {
|
131
|
-
return '\'' + String(packageName) + '\' should be listed in the project\'s dependencies, not optionalDependencies.';
|
132
|
-
}
|
133
|
-
|
134
|
-
function getModuleOriginalName(name) {var _name$split =
|
135
|
-
name.split('/'),_name$split2 = _slicedToArray(_name$split, 2),first = _name$split2[0],second = _name$split2[1];
|
136
|
-
return first.startsWith('@') ? String(first) + '/' + String(second) : first;
|
137
|
-
}
|
138
|
-
|
139
|
-
function getModuleRealName(resolved) {
|
140
|
-
return (0, _packagePath.getFilePackageName)(resolved);
|
141
|
-
}
|
142
|
-
|
143
|
-
function checkDependencyDeclaration(deps, packageName, declarationStatus) {
|
144
|
-
var newDeclarationStatus = declarationStatus || {
|
145
|
-
isInDeps: false,
|
146
|
-
isInDevDeps: false,
|
147
|
-
isInOptDeps: false,
|
148
|
-
isInPeerDeps: false,
|
149
|
-
isInBundledDeps: false };
|
150
|
-
|
151
|
-
|
152
|
-
// in case of sub package.json inside a module
|
153
|
-
// check the dependencies on all hierarchy
|
154
|
-
var packageHierarchy = [];
|
155
|
-
var packageNameParts = packageName ? packageName.split('/') : [];
|
156
|
-
packageNameParts.forEach(function (namePart, index) {
|
157
|
-
if (!namePart.startsWith('@')) {
|
158
|
-
var ancestor = packageNameParts.slice(0, index + 1).join('/');
|
159
|
-
packageHierarchy.push(ancestor);
|
160
|
-
}
|
161
|
-
});
|
162
|
-
|
163
|
-
return packageHierarchy.reduce(function (result, ancestorName) {return {
|
164
|
-
isInDeps: result.isInDeps || deps.dependencies[ancestorName] !== undefined,
|
165
|
-
isInDevDeps: result.isInDevDeps || deps.devDependencies[ancestorName] !== undefined,
|
166
|
-
isInOptDeps: result.isInOptDeps || deps.optionalDependencies[ancestorName] !== undefined,
|
167
|
-
isInPeerDeps: result.isInPeerDeps || deps.peerDependencies[ancestorName] !== undefined,
|
168
|
-
isInBundledDeps:
|
169
|
-
result.isInBundledDeps || deps.bundledDependencies.indexOf(ancestorName) !== -1 };},
|
170
|
-
newDeclarationStatus);
|
171
|
-
}
|
172
|
-
|
173
|
-
function reportIfMissing(context, deps, depsOptions, node, name) {
|
174
|
-
// Do not report when importing types unless option is enabled
|
175
|
-
if (
|
176
|
-
!depsOptions.verifyTypeImports && (
|
177
|
-
|
178
|
-
node.importKind === 'type' ||
|
179
|
-
node.importKind === 'typeof' ||
|
180
|
-
node.exportKind === 'type' ||
|
181
|
-
Array.isArray(node.specifiers) && node.specifiers.length && node.specifiers.every(function (specifier) {return specifier.importKind === 'type' || specifier.importKind === 'typeof';})))
|
182
|
-
|
183
|
-
{
|
184
|
-
return;
|
185
|
-
}
|
186
|
-
|
187
|
-
var typeOfImport = (0, _importType2['default'])(name, context);
|
188
|
-
|
189
|
-
if (
|
190
|
-
typeOfImport !== 'external' && (
|
191
|
-
typeOfImport !== 'internal' || !depsOptions.verifyInternalDeps))
|
192
|
-
{
|
193
|
-
return;
|
194
|
-
}
|
195
|
-
|
196
|
-
var resolved = (0, _resolve2['default'])(name, context);
|
197
|
-
if (!resolved) {return;}
|
198
|
-
|
199
|
-
var importPackageName = getModuleOriginalName(name);
|
200
|
-
var declarationStatus = checkDependencyDeclaration(deps, importPackageName);
|
201
|
-
|
202
|
-
if (
|
203
|
-
declarationStatus.isInDeps ||
|
204
|
-
depsOptions.allowDevDeps && declarationStatus.isInDevDeps ||
|
205
|
-
depsOptions.allowPeerDeps && declarationStatus.isInPeerDeps ||
|
206
|
-
depsOptions.allowOptDeps && declarationStatus.isInOptDeps ||
|
207
|
-
depsOptions.allowBundledDeps && declarationStatus.isInBundledDeps)
|
208
|
-
{
|
209
|
-
return;
|
210
|
-
}
|
211
|
-
|
212
|
-
// test the real name from the resolved package.json
|
213
|
-
// if not aliased imports (alias/react for example), importPackageName can be misinterpreted
|
214
|
-
var realPackageName = getModuleRealName(resolved);
|
215
|
-
if (realPackageName && realPackageName !== importPackageName) {
|
216
|
-
declarationStatus = checkDependencyDeclaration(deps, realPackageName, declarationStatus);
|
217
|
-
|
218
|
-
if (
|
219
|
-
declarationStatus.isInDeps ||
|
220
|
-
depsOptions.allowDevDeps && declarationStatus.isInDevDeps ||
|
221
|
-
depsOptions.allowPeerDeps && declarationStatus.isInPeerDeps ||
|
222
|
-
depsOptions.allowOptDeps && declarationStatus.isInOptDeps ||
|
223
|
-
depsOptions.allowBundledDeps && declarationStatus.isInBundledDeps)
|
224
|
-
{
|
225
|
-
return;
|
226
|
-
}
|
227
|
-
}
|
228
|
-
|
229
|
-
if (declarationStatus.isInDevDeps && !depsOptions.allowDevDeps) {
|
230
|
-
context.report(node, devDepErrorMessage(realPackageName || importPackageName));
|
231
|
-
return;
|
232
|
-
}
|
233
|
-
|
234
|
-
if (declarationStatus.isInOptDeps && !depsOptions.allowOptDeps) {
|
235
|
-
context.report(node, optDepErrorMessage(realPackageName || importPackageName));
|
236
|
-
return;
|
237
|
-
}
|
238
|
-
|
239
|
-
context.report(node, missingErrorMessage(realPackageName || importPackageName));
|
240
|
-
}
|
241
|
-
|
242
|
-
function testConfig(config, filename) {
|
243
|
-
// Simplest configuration first, either a boolean or nothing.
|
244
|
-
if (typeof config === 'boolean' || typeof config === 'undefined') {
|
245
|
-
return config;
|
246
|
-
}
|
247
|
-
// Array of globs.
|
248
|
-
return config.some(function (c) {return (0, _minimatch2['default'])(filename, c) ||
|
249
|
-
(0, _minimatch2['default'])(filename, _path2['default'].join(process.cwd(), c));});
|
250
|
-
|
251
|
-
}
|
252
|
-
|
253
|
-
module.exports = {
|
254
|
-
meta: {
|
255
|
-
type: 'problem',
|
256
|
-
docs: {
|
257
|
-
category: 'Helpful warnings',
|
258
|
-
description: 'Forbid the use of extraneous packages.',
|
259
|
-
url: (0, _docsUrl2['default'])('no-extraneous-dependencies') },
|
260
|
-
|
261
|
-
|
262
|
-
schema: [
|
263
|
-
{
|
264
|
-
type: 'object',
|
265
|
-
properties: {
|
266
|
-
devDependencies: { type: ['boolean', 'array'] },
|
267
|
-
optionalDependencies: { type: ['boolean', 'array'] },
|
268
|
-
peerDependencies: { type: ['boolean', 'array'] },
|
269
|
-
bundledDependencies: { type: ['boolean', 'array'] },
|
270
|
-
packageDir: { type: ['string', 'array'] },
|
271
|
-
includeInternal: { type: ['boolean'] },
|
272
|
-
includeTypes: { type: ['boolean'] } },
|
273
|
-
|
274
|
-
additionalProperties: false }] },
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
create: function () {function create(context) {
|
280
|
-
var options = context.options[0] || {};
|
281
|
-
var filename = context.getPhysicalFilename ? context.getPhysicalFilename() : context.getFilename();
|
282
|
-
var deps = getDependencies(context, options.packageDir) || extractDepFields({});
|
283
|
-
|
284
|
-
var depsOptions = {
|
285
|
-
allowDevDeps: testConfig(options.devDependencies, filename) !== false,
|
286
|
-
allowOptDeps: testConfig(options.optionalDependencies, filename) !== false,
|
287
|
-
allowPeerDeps: testConfig(options.peerDependencies, filename) !== false,
|
288
|
-
allowBundledDeps: testConfig(options.bundledDependencies, filename) !== false,
|
289
|
-
verifyInternalDeps: !!options.includeInternal,
|
290
|
-
verifyTypeImports: !!options.includeTypes };
|
291
|
-
|
292
|
-
|
293
|
-
return (0, _moduleVisitor2['default'])(function (source, node) {
|
294
|
-
reportIfMissing(context, deps, depsOptions, node, source.value);
|
295
|
-
}, { commonjs: true });
|
296
|
-
}return create;}(),
|
297
|
-
|
298
|
-
'Program:exit': function () {function ProgramExit() {
|
299
|
-
depFieldCache.clear();
|
300
|
-
}return ProgramExit;}() };
|
301
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1leHRyYW5lb3VzLWRlcGVuZGVuY2llcy5qcyJdLCJuYW1lcyI6WyJkZXBGaWVsZENhY2hlIiwiTWFwIiwiaGFzS2V5cyIsIm9iaiIsIk9iamVjdCIsImtleXMiLCJsZW5ndGgiLCJhcnJheU9yS2V5cyIsImFycmF5T3JPYmplY3QiLCJBcnJheSIsImlzQXJyYXkiLCJyZWFkSlNPTiIsImpzb25QYXRoIiwidGhyb3dFeGNlcHRpb24iLCJKU09OIiwicGFyc2UiLCJmcyIsInJlYWRGaWxlU3luYyIsImVyciIsImV4dHJhY3REZXBGaWVsZHMiLCJwa2ciLCJkZXBlbmRlbmNpZXMiLCJkZXZEZXBlbmRlbmNpZXMiLCJvcHRpb25hbERlcGVuZGVuY2llcyIsIn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BGaWVsZHMoe30pO1xuXG4gICAgY29uc3QgZGVwc09wdGlvbnMgPSB7XG4gICAgICBhbGxvd0RldkRlcHM6IHRlc3RDb25maWcob3B0aW9ucy5kZXZEZXBlbmRlbmNpZXMsIGZpbGVuYW1lKSAhPT0gZmFsc2UsXG4gICAgICBhbGxvd09wdERlcHM6IHRlc3RDb25maWcob3B0aW9ucy5vcHRpb25hbERlcGVuZGVuY2llcywgZmlsZW5hbWUpICE9PSBmYWxzZSxcbiAgICAgIGFsbG93UGVlckRlcHM6IHRlc3RDb25maWcob3B0aW9ucy5wZWVyRGVwZW5kZW5jaWVzLCBmaWxlbmFtZSkgIT09IGZhbHNlLFxuICAgICAgYWxsb3dCdW5kbGVkRGVwczogdGVzdENvbmZpZyhvcHRpb25zLmJ1bmRsZWREZXBlbmRlbmNpZXMsIGZpbGVuYW1lKSAhPT0gZmFsc2UsXG4gICAgICB2ZXJpZnlJbnRlcm5hbERlcHM6ICEhb3B0aW9ucy5pbmNsdWRlSW50ZXJuYWwsXG4gICAgICB2ZXJpZnlUeXBlSW1wb3J0czogISFvcHRpb25zLmluY2x1ZGVUeXBlcyxcbiAgICB9O1xuXG4gICAgcmV0dXJuIG1vZHVsZVZpc2l0b3IoKHNvdXJjZSwgbm9kZSkgPT4ge1xuICAgICAgcmVwb3J0SWZNaXNzaW5nKGNvbnRleHQsIGRlcHMsIGRlcHNPcHRpb25zLCBub2RlLCBzb3VyY2UudmFsdWUpO1xuICAgIH0sIHsgY29tbW9uanM6IHRydWUgfSk7XG4gIH0sXG5cbiAgJ1Byb2dyYW06ZXhpdCcoKSB7XG4gICAgZGVwRmllbGRDYWNoZS5jbGVhcigpO1xuICB9LFxufTtcbiJdfQ==
|
@@ -1,85 +0,0 @@
|
|
1
|
-
'use strict';var _minimatch = require('minimatch');var _minimatch2 = _interopRequireDefault(_minimatch);
|
2
|
-
var _path = require('path');var _path2 = _interopRequireDefault(_path);
|
3
|
-
var _pkgUp = require('eslint-module-utils/pkgUp');var _pkgUp2 = _interopRequireDefault(_pkgUp);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}
|
4
|
-
|
5
|
-
function getEntryPoint(context) {
|
6
|
-
var pkgPath = (0, _pkgUp2['default'])({ cwd: context.getPhysicalFilename ? context.getPhysicalFilename() : context.getFilename() });
|
7
|
-
try {
|
8
|
-
return require.resolve(_path2['default'].dirname(pkgPath));
|
9
|
-
} catch (error) {
|
10
|
-
// Assume the package has no entrypoint (e.g. CLI packages)
|
11
|
-
// in which case require.resolve would throw.
|
12
|
-
return null;
|
13
|
-
}
|
14
|
-
}
|
15
|
-
|
16
|
-
function findScope(context, identifier) {var _context$getSourceCod =
|
17
|
-
context.getSourceCode(),scopeManager = _context$getSourceCod.scopeManager;
|
18
|
-
|
19
|
-
return scopeManager && scopeManager.scopes.slice().reverse().find(function (scope) {return scope.variables.some(function (variable) {return variable.identifiers.some(function (node) {return node.name === identifier;});});});
|
20
|
-
}
|
21
|
-
|
22
|
-
function findDefinition(objectScope, identifier) {
|
23
|
-
var variable = objectScope.variables.find(function (variable) {return variable.name === identifier;});
|
24
|
-
return variable.defs.find(function (def) {return def.name.name === identifier;});
|
25
|
-
}
|
26
|
-
|
27
|
-
module.exports = {
|
28
|
-
meta: {
|
29
|
-
type: 'problem',
|
30
|
-
docs: {
|
31
|
-
category: 'Module systems',
|
32
|
-
description: 'Forbid import statements with CommonJS module.exports.',
|
33
|
-
recommended: true },
|
34
|
-
|
35
|
-
fixable: 'code',
|
36
|
-
schema: [
|
37
|
-
{
|
38
|
-
type: 'object',
|
39
|
-
properties: {
|
40
|
-
exceptions: { type: 'array' } },
|
41
|
-
|
42
|
-
additionalProperties: false }] },
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
create: function () {function create(context) {
|
47
|
-
var importDeclarations = [];
|
48
|
-
var entryPoint = getEntryPoint(context);
|
49
|
-
var options = context.options[0] || {};
|
50
|
-
var alreadyReported = false;
|
51
|
-
|
52
|
-
function report(node) {
|
53
|
-
var fileName = context.getPhysicalFilename ? context.getPhysicalFilename() : context.getFilename();
|
54
|
-
var isEntryPoint = entryPoint === fileName;
|
55
|
-
var isIdentifier = node.object.type === 'Identifier';
|
56
|
-
var hasKeywords = /^(module|exports)$/.test(node.object.name);
|
57
|
-
var objectScope = hasKeywords && findScope(context, node.object.name);
|
58
|
-
var variableDefinition = objectScope && findDefinition(objectScope, node.object.name);
|
59
|
-
var isImportBinding = variableDefinition && variableDefinition.type === 'ImportBinding';
|
60
|
-
var hasCJSExportReference = hasKeywords && (!objectScope || objectScope.type === 'module');
|
61
|
-
var isException = !!options.exceptions && options.exceptions.some(function (glob) {return (0, _minimatch2['default'])(fileName, glob);});
|
62
|
-
|
63
|
-
if (isIdentifier && hasCJSExportReference && !isEntryPoint && !isException && !isImportBinding) {
|
64
|
-
importDeclarations.forEach(function (importDeclaration) {
|
65
|
-
context.report({
|
66
|
-
node: importDeclaration,
|
67
|
-
message: 'Cannot use import declarations in modules that export using CommonJS (module.exports = \'foo\' or exports.bar = \'hi\')' });
|
68
|
-
|
69
|
-
});
|
70
|
-
alreadyReported = true;
|
71
|
-
}
|
72
|
-
}
|
73
|
-
|
74
|
-
return {
|
75
|
-
ImportDeclaration: function () {function ImportDeclaration(node) {
|
76
|
-
importDeclarations.push(node);
|
77
|
-
}return ImportDeclaration;}(),
|
78
|
-
MemberExpression: function () {function MemberExpression(node) {
|
79
|
-
if (!alreadyReported) {
|
80
|
-
report(node);
|
81
|
-
}
|
82
|
-
}return MemberExpression;}() };
|
83
|
-
|
84
|
-
}return create;}() };
|
85
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1pbXBvcnQtbW9kdWxlLWV4cG9ydHMuanMiXSwibmFtZXMiOlsiZ2V0RW50cnlQb2ludCIsImNvbnRleHQiLCJwa2dQYXRoIiwiY3dkIiwiZ2V0UGh5c2ljYWxGaW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Y2VwdGlvbnMgJiYgb3B0aW9ucy5leGNlcHRpb25zLnNvbWUoKGdsb2IpID0+IG1pbmltYXRjaChmaWxlTmFtZSwgZ2xvYikpO1xuXG4gICAgICBpZiAoaXNJZGVudGlmaWVyICYmIGhhc0NKU0V4cG9ydFJlZmVyZW5jZSAmJiAhaXNFbnRyeVBvaW50ICYmICFpc0V4Y2VwdGlvbiAmJiAhaXNJbXBvcnRCaW5kaW5nKSB7XG4gICAgICAgIGltcG9ydERlY2xhcmF0aW9ucy5mb3JFYWNoKChpbXBvcnREZWNsYXJhdGlvbikgPT4ge1xuICAgICAgICAgIGNvbnRleHQucmVwb3J0KHtcbiAgICAgICAgICAgIG5vZGU6IGltcG9ydERlY2xhcmF0aW9uLFxuICAgICAgICAgICAgbWVzc2FnZTogYENhbm5vdCB1c2UgaW1wb3J0IGRlY2xhcmF0aW9ucyBpbiBtb2R1bGVzIHRoYXQgZXhwb3J0IHVzaW5nIENvbW1vbkpTIChtb2R1bGUuZXhwb3J0cyA9ICdmb28nIG9yIGV4cG9ydHMuYmFyID0gJ2hpJylgLFxuICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICAgICAgYWxyZWFkeVJlcG9ydGVkID0gdHJ1ZTtcbiAgICAgIH1cbiAgICB9XG5cbiAgICByZXR1cm4ge1xuICAgICAgSW1wb3J0RGVjbGFyYXRpb24obm9kZSkge1xuICAgICAgICBpbXBvcnREZWNsYXJhdGlvbnMucHVzaChub2RlKTtcbiAgICAgIH0sXG4gICAgICBNZW1iZXJFeHByZXNzaW9uKG5vZGUpIHtcbiAgICAgICAgaWYgKCFhbHJlYWR5UmVwb3J0ZWQpIHtcbiAgICAgICAgICByZXBvcnQobm9kZSk7XG4gICAgICAgIH1cbiAgICAgIH0sXG4gICAgfTtcbiAgfSxcbn07XG4iXX0=
|
@@ -1,144 +0,0 @@
|
|
1
|
-
'use strict';var _minimatch = require('minimatch');var _minimatch2 = _interopRequireDefault(_minimatch);
|
2
|
-
|
3
|
-
var _resolve = require('eslint-module-utils/resolve');var _resolve2 = _interopRequireDefault(_resolve);
|
4
|
-
var _importType = require('../core/importType');var _importType2 = _interopRequireDefault(_importType);
|
5
|
-
var _moduleVisitor = require('eslint-module-utils/moduleVisitor');var _moduleVisitor2 = _interopRequireDefault(_moduleVisitor);
|
6
|
-
var _docsUrl = require('../docsUrl');var _docsUrl2 = _interopRequireDefault(_docsUrl);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { 'default': obj };}
|
7
|
-
|
8
|
-
module.exports = {
|
9
|
-
meta: {
|
10
|
-
type: 'suggestion',
|
11
|
-
docs: {
|
12
|
-
category: 'Static analysis',
|
13
|
-
description: 'Forbid importing the submodules of other modules.',
|
14
|
-
url: (0, _docsUrl2['default'])('no-internal-modules') },
|
15
|
-
|
16
|
-
|
17
|
-
schema: [
|
18
|
-
{
|
19
|
-
anyOf: [
|
20
|
-
{
|
21
|
-
type: 'object',
|
22
|
-
properties: {
|
23
|
-
allow: {
|
24
|
-
type: 'array',
|
25
|
-
items: {
|
26
|
-
type: 'string' } } },
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
additionalProperties: false },
|
31
|
-
|
32
|
-
{
|
33
|
-
type: 'object',
|
34
|
-
properties: {
|
35
|
-
forbid: {
|
36
|
-
type: 'array',
|
37
|
-
items: {
|
38
|
-
type: 'string' } } },
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
additionalProperties: false }] }] },
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
create: function () {function noReachingInside(context) {
|
50
|
-
var options = context.options[0] || {};
|
51
|
-
var allowRegexps = (options.allow || []).map(function (p) {return _minimatch2['default'].makeRe(p);});
|
52
|
-
var forbidRegexps = (options.forbid || []).map(function (p) {return _minimatch2['default'].makeRe(p);});
|
53
|
-
|
54
|
-
// minimatch patterns are expected to use / path separators, like import
|
55
|
-
// statements, so normalize paths to use the same
|
56
|
-
function normalizeSep(somePath) {
|
57
|
-
return somePath.split('\\').join('/');
|
58
|
-
}
|
59
|
-
|
60
|
-
function toSteps(somePath) {
|
61
|
-
return normalizeSep(somePath).
|
62
|
-
split('/').
|
63
|
-
filter(function (step) {return step && step !== '.';}).
|
64
|
-
reduce(function (acc, step) {
|
65
|
-
if (step === '..') {
|
66
|
-
return acc.slice(0, -1);
|
67
|
-
}
|
68
|
-
return acc.concat(step);
|
69
|
-
}, []);
|
70
|
-
}
|
71
|
-
|
72
|
-
// test if reaching to this destination is allowed
|
73
|
-
function reachingAllowed(importPath) {
|
74
|
-
return allowRegexps.some(function (re) {return re.test(importPath);});
|
75
|
-
}
|
76
|
-
|
77
|
-
// test if reaching to this destination is forbidden
|
78
|
-
function reachingForbidden(importPath) {
|
79
|
-
return forbidRegexps.some(function (re) {return re.test(importPath);});
|
80
|
-
}
|
81
|
-
|
82
|
-
function isAllowViolation(importPath) {
|
83
|
-
var steps = toSteps(importPath);
|
84
|
-
|
85
|
-
var nonScopeSteps = steps.filter(function (step) {return step.indexOf('@') !== 0;});
|
86
|
-
if (nonScopeSteps.length <= 1) {return false;}
|
87
|
-
|
88
|
-
// before trying to resolve, see if the raw import (with relative
|
89
|
-
// segments resolved) matches an allowed pattern
|
90
|
-
var justSteps = steps.join('/');
|
91
|
-
if (reachingAllowed(justSteps) || reachingAllowed('/' + String(justSteps))) {return false;}
|
92
|
-
|
93
|
-
// if the import statement doesn't match directly, try to match the
|
94
|
-
// resolved path if the import is resolvable
|
95
|
-
var resolved = (0, _resolve2['default'])(importPath, context);
|
96
|
-
if (!resolved || reachingAllowed(normalizeSep(resolved))) {return false;}
|
97
|
-
|
98
|
-
// this import was not allowed by the allowed paths, and reaches
|
99
|
-
// so it is a violation
|
100
|
-
return true;
|
101
|
-
}
|
102
|
-
|
103
|
-
function isForbidViolation(importPath) {
|
104
|
-
var steps = toSteps(importPath);
|
105
|
-
|
106
|
-
// before trying to resolve, see if the raw import (with relative
|
107
|
-
// segments resolved) matches a forbidden pattern
|
108
|
-
var justSteps = steps.join('/');
|
109
|
-
|
110
|
-
if (reachingForbidden(justSteps) || reachingForbidden('/' + String(justSteps))) {return true;}
|
111
|
-
|
112
|
-
// if the import statement doesn't match directly, try to match the
|
113
|
-
// resolved path if the import is resolvable
|
114
|
-
var resolved = (0, _resolve2['default'])(importPath, context);
|
115
|
-
if (resolved && reachingForbidden(normalizeSep(resolved))) {return true;}
|
116
|
-
|
117
|
-
// this import was not forbidden by the forbidden paths so it is not a violation
|
118
|
-
return false;
|
119
|
-
}
|
120
|
-
|
121
|
-
// find a directory that is being reached into, but which shouldn't be
|
122
|
-
var isReachViolation = options.forbid ? isForbidViolation : isAllowViolation;
|
123
|
-
|
124
|
-
function checkImportForReaching(importPath, node) {
|
125
|
-
var potentialViolationTypes = ['parent', 'index', 'sibling', 'external', 'internal'];
|
126
|
-
if (
|
127
|
-
potentialViolationTypes.indexOf((0, _importType2['default'])(importPath, context)) !== -1 &&
|
128
|
-
isReachViolation(importPath))
|
129
|
-
{
|
130
|
-
context.report({
|
131
|
-
node: node,
|
132
|
-
message: 'Reaching to "' + String(importPath) + '" is not allowed.' });
|
133
|
-
|
134
|
-
}
|
135
|
-
}
|
136
|
-
|
137
|
-
return (0, _moduleVisitor2['default'])(
|
138
|
-
function (source) {
|
139
|
-
checkImportForReaching(source.value, source);
|
140
|
-
},
|
141
|
-
{ commonjs: true });
|
142
|
-
|
143
|
-
}return noReachingInside;}() };
|
144
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydWxlcy9uby1pbnRlcm5hbC1tb2R1bGVzLmpzIl0sIm5hbWVzIjpbIm1vZHVsZSIsImV4cG9ydHMiLCJtZXRhIiwidHlwZSIsImRvY3MiLCJjYXRlZ29yeSIsImRlc2NyaXB0aW9uIiwidXJsIiwic2NoZW1hIiwiYW55T2YiLCJwcm9wZXJ0aWVzIiwiYWxsb3ciLCJpdGVtc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N0YXRpYyBhbmFseXNpcycsXG4gICAgICBkZXNjcmlwdGlvbjogJ0ZvcmJpZCBpbXBvcnRpbmcgdGhlIHN1Ym1vZHVsZXMgb2Ygb3RoZXIgbW9kdWxlcy4nLFxuICAgICAgdXJsOiBkb2NzVXJsKCduby1pbnRlcm5hbC1tb2R1bGVzJyksXG4gICAgfSxcblxuICAgIHNjaGVtYTogW1xuICAgICAge1xuICAgICAgICBhbnlPZjogW1xuICAgICAgICAgIHtcbiAgICAgICAgICAgIHR5cGU6ICdvYmplY3QnLFxuICAgICAgICAgICAgcHJvcGVydGllczoge1xuICAgICAgICAgICAgICBhbGxvdzoge1xuICAgICAgICAgICAgICAgIHR5cGU6ICdhcnJheScsXG4gICAgICAgICAgICAgICAgaXRlbXM6IHtcbiAgICAgICAgICAgICAgICAgIHR5cGU6ICdzdHJpbmcnLFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYWRkaXRpb25hbFByb3BlcnRpZXM6IGZhbHNlLFxuICAgICAgICAgIH0sXG4gICAgICAgICAge1xuICAgICAgICAgICAgdHlwZTogJ29iamVjdCcsXG4gICAgICAgICAgICBwcm9wZXJ0aWVzOiB7XG4gICAgICAgICAgICAgIGZvcmJpZDoge1xuICAgICAgICAgICAgICAgIHR5cGU6ICdhcnJheScsXG4gICAgICAgICAgICAgICAgaXRlbXM6IHtcbiAgICAgICAgICAgICAgICAgIHR5cGU6ICdzdHJpbmcnLFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgYWRkaXRpb25hbFByb3BlcnRpZXM6IGZhbHNlLFxuICAgICAgICAgIH0sXG4gICAgICAgIF0sXG4gICAgICB9LFxuICAgIF0sXG4gIH0sXG5cbiAgY3JlYXRlOiBmdW5jdGlvbiBub1JlYWNoaW5nSW5zaWRlKGNvbnRleHQpIHtcbiAgICBjb25zd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