Removed GopherJS, basic frontend completed, need backend changes for

torrent storage
This commit is contained in:
2017-11-30 18:12:11 -05:00
parent 67fdef16b1
commit e98ad2cc88
69321 changed files with 5498914 additions and 337 deletions

View File

@@ -0,0 +1,26 @@
# Change Log
All notable changes to this module will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).
## Unreleased
## v2.1.1 - 2017-06-22
Re-releasing v2.1.0 after vetting (again) and unable to reproduce issue.
## v2.1.0 - 2017-06-02 [YANKED]
Yanked due to critical issue with cache key resulting from #839.
### Added
- `parse` now additionally passes `filePath` to `parser` in `parserOptions` like `eslint` core does
## v2.0.0 - 2016-11-07
### Changed
- `unambiguous` no longer exposes fast test regex
### Fixed
- `unambiguous.test()` regex is now properly in multiline mode

View File

@@ -0,0 +1,47 @@
"use strict"
exports.__esModule = true
const log = require('debug')('eslint-module-utils:ModuleCache')
class ModuleCache {
constructor(map) {
this.map = map || new Map()
}
/**
* returns value for returning inline
* @param {[type]} cacheKey [description]
* @param {[type]} result [description]
*/
set(cacheKey, result) {
this.map.set(cacheKey, { result, lastSeen: Date.now() })
log('setting entry for', cacheKey)
return result
}
get(cacheKey, settings) {
if (this.map.has(cacheKey)) {
const f = this.map.get(cacheKey)
// check fresness
if (Date.now() - f.lastSeen < (settings.lifetime * 1000)) return f.result
} else log('cache miss for', cacheKey)
// cache miss
return undefined
}
}
ModuleCache.getSettings = function (settings) {
const cacheSettings = Object.assign({
lifetime: 30, // seconds
}, settings['import/cache'])
// parse infinity
if (cacheSettings.lifetime === '∞' || cacheSettings.lifetime === 'Infinity') {
cacheSettings.lifetime = Infinity
}
return cacheSettings
}
exports.default = ModuleCache

View File

@@ -0,0 +1,14 @@
"use strict"
exports.__esModule = true
exports.default = function declaredScope(context, name) {
let references = context.getScope().references
, i
for (i = 0; i < references.length; i++) {
if (references[i].identifier.name === name) {
break
}
}
if (!references[i]) return undefined
return references[i].resolved.scope.type
}

View File

@@ -0,0 +1,59 @@
/**
* utilities for hashing config objects.
* basically iteratively updates hash with a JSON-like format
*/
"use strict"
exports.__esModule = true
const createHash = require('crypto').createHash
const stringify = JSON.stringify
function hashify(value, hash) {
if (!hash) hash = createHash('sha256')
if (value instanceof Array) {
hashArray(value, hash)
} else if (value instanceof Object) {
hashObject(value, hash)
} else {
hash.update(stringify(value) || 'undefined')
}
return hash
}
exports.default = hashify
function hashArray(array, hash) {
if (!hash) hash = createHash('sha256')
hash.update('[')
for (let i = 0; i < array.length; i++) {
hashify(array[i], hash)
hash.update(',')
}
hash.update(']')
return hash
}
hashify.array = hashArray
exports.hashArray = hashArray
function hashObject(object, hash) {
if (!hash) hash = createHash('sha256')
hash.update("{")
Object.keys(object).sort().forEach(key => {
hash.update(stringify(key))
hash.update(':')
hashify(object[key], hash)
hash.update(",")
})
hash.update('}')
return hash
}
hashify.object = hashObject
exports.hashObject = hashObject

View File

@@ -0,0 +1,56 @@
"use strict"
exports.__esModule = true
const extname = require('path').extname
const log = require('debug')('eslint-plugin-import:utils:ignore')
// one-shot memoized
let cachedSet, lastSettings
function validExtensions(context) {
if (cachedSet && context.settings === lastSettings) {
return cachedSet
}
lastSettings = context.settings
cachedSet = makeValidExtensionSet(context.settings)
return cachedSet
}
function makeValidExtensionSet(settings) {
// start with explicit JS-parsed extensions
const exts = new Set(settings['import/extensions'] || [ '.js' ])
// all alternate parser extensions are also valid
if ('import/parsers' in settings) {
for (let parser in settings['import/parsers']) {
settings['import/parsers'][parser]
.forEach(ext => exts.add(ext))
}
}
return exts
}
exports.default = function ignore(path, context) {
// check extension whitelist first (cheap)
if (!hasValidExtension(path, context)) return true
if (!('import/ignore' in context.settings)) return false
const ignoreStrings = context.settings['import/ignore']
for (let i = 0; i < ignoreStrings.length; i++) {
const regex = new RegExp(ignoreStrings[i])
if (regex.test(path)) {
log(`ignoring ${path}, matched pattern /${ignoreStrings[i]}/`)
return true
}
}
return false
}
function hasValidExtension(path, context) {
return validExtensions(context).has(extname(path))
}
exports.hasValidExtension = hasValidExtension

View File

@@ -0,0 +1,30 @@
"use strict"
exports.__esModule = true
const Module = require('module')
const path = require('path')
// borrowed from babel-eslint
function createModule(filename) {
const mod = new Module(filename)
mod.filename = filename
mod.paths = Module._nodeModulePaths(path.dirname(filename))
return mod
}
exports.default = function moduleRequire(p) {
try {
// attempt to get espree relative to eslint
const eslintPath = require.resolve('eslint')
const eslintModule = createModule(eslintPath)
return require(Module._resolveFilename(p, eslintModule))
} catch(err) { /* ignore */ }
try {
// try relative to entry point
return require.main.require(p)
} catch(err) { /* ignore */ }
// finally, try from here
return require(p)
}

View File

@@ -0,0 +1,129 @@
"use strict"
exports.__esModule = true
/**
* Returns an object of node visitors that will call
* 'visitor' with every discovered module path.
*
* todo: correct function prototype for visitor
* @param {Function(String)} visitor [description]
* @param {[type]} options [description]
* @return {object}
*/
exports.default = function visitModules(visitor, options) {
// if esmodule is not explicitly disabled, it is assumed to be enabled
options = Object.assign({ esmodule: true }, options)
let ignoreRegExps = []
if (options.ignore != null) {
ignoreRegExps = options.ignore.map(p => new RegExp(p))
}
function checkSourceValue(source) {
if (source == null) return //?
// handle ignore
if (ignoreRegExps.some(re => re.test(source.value))) return
// fire visitor
visitor(source)
}
// for import-y declarations
function checkSource(node) {
checkSourceValue(node.source)
}
// for CommonJS `require` calls
// adapted from @mctep: http://git.io/v4rAu
function checkCommon(call) {
if (call.callee.type !== 'Identifier') return
if (call.callee.name !== 'require') return
if (call.arguments.length !== 1) return
const modulePath = call.arguments[0]
if (modulePath.type !== 'Literal') return
if (typeof modulePath.value !== 'string') return
checkSourceValue(modulePath)
}
function checkAMD(call) {
if (call.callee.type !== 'Identifier') return
if (call.callee.name !== 'require' &&
call.callee.name !== 'define') return
if (call.arguments.length !== 2) return
const modules = call.arguments[0]
if (modules.type !== 'ArrayExpression') return
for (let element of modules.elements) {
if (element.type !== 'Literal') continue
if (typeof element.value !== 'string') continue
if (element.value === 'require' ||
element.value === 'exports') continue // magic modules: http://git.io/vByan
checkSourceValue(element)
}
}
const visitors = {}
if (options.esmodule) {
Object.assign(visitors, {
'ImportDeclaration': checkSource,
'ExportNamedDeclaration': checkSource,
'ExportAllDeclaration': checkSource,
})
}
if (options.commonjs || options.amd) {
visitors['CallExpression'] = function (call) {
if (options.commonjs) checkCommon(call)
if (options.amd) checkAMD(call)
}
}
return visitors
}
/**
* make an options schema for the module visitor, optionally
* adding extra fields.
* @param {[type]} additionalProperties [description]
* @return {[type]} [description]
*/
function makeOptionsSchema(additionalProperties) {
const base = {
'type': 'object',
'properties': {
'commonjs': { 'type': 'boolean' },
'amd': { 'type': 'boolean' },
'esmodule': { 'type': 'boolean' },
'ignore': {
'type': 'array',
'minItems': 1,
'items': { 'type': 'string' },
'uniqueItems': true,
},
},
'additionalProperties': false,
}
if (additionalProperties){
for (let key in additionalProperties) {
base.properties[key] = additionalProperties[key]
}
}
return base
}
exports.makeOptionsSchema = makeOptionsSchema
/**
* json schema object for options parameter. can be used to build
* rule options schema object.
* @type {Object}
*/
exports.optionsSchema = makeOptionsSchema()

View File

@@ -0,0 +1,53 @@
'use strict';
var path = require('path');
var pathExists = require('path-exists');
var Promise = require('pinkie-promise');
function splitPath(x) {
return path.resolve(x || '').split(path.sep);
}
function join(parts, filename) {
return path.resolve(parts.join(path.sep) + path.sep, filename);
}
module.exports = function (filename, opts) {
opts = opts || {};
var parts = splitPath(opts.cwd);
return new Promise(function (resolve) {
(function find() {
var fp = join(parts, filename);
pathExists(fp).then(function (exists) {
if (exists) {
resolve(fp);
} else if (parts.pop()) {
find();
} else {
resolve(null);
}
});
})();
});
};
module.exports.sync = function (filename, opts) {
opts = opts || {};
var parts = splitPath(opts.cwd);
var len = parts.length;
while (len--) {
var fp = join(parts, filename);
if (pathExists.sync(fp)) {
return fp;
}
parts.pop();
}
return null;
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,86 @@
{
"_args": [
[
"find-up@1.1.2",
"C:\\Users\\deranjer\\GoglandProjects\\torrent-project\\torrent-project"
]
],
"_from": "find-up@1.1.2",
"_id": "find-up@1.1.2",
"_inBundle": false,
"_integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=",
"_location": "/react-scripts/eslint-module-utils/find-up",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "find-up@1.1.2",
"name": "find-up",
"escapedName": "find-up",
"rawSpec": "1.1.2",
"saveSpec": null,
"fetchSpec": "1.1.2"
},
"_requiredBy": [
"/react-scripts/eslint-module-utils/pkg-dir"
],
"_resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz",
"_spec": "1.1.2",
"_where": "C:\\Users\\deranjer\\GoglandProjects\\torrent-project\\torrent-project",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/find-up/issues"
},
"dependencies": {
"path-exists": "^2.0.0",
"pinkie-promise": "^2.0.0"
},
"description": "Find a file by walking up parent directories",
"devDependencies": {
"ava": "*",
"tempfile": "^1.1.1",
"xo": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/find-up#readme",
"keywords": [
"find",
"up",
"find-up",
"findup",
"look-up",
"look",
"file",
"search",
"match",
"package",
"resolve",
"parent",
"parents",
"folder",
"directory",
"dir",
"walk",
"walking",
"path"
],
"license": "MIT",
"name": "find-up",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/find-up.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "1.1.2"
}

View File

@@ -0,0 +1,72 @@
# find-up [![Build Status](https://travis-ci.org/sindresorhus/find-up.svg?branch=master)](https://travis-ci.org/sindresorhus/find-up)
> Find a file by walking up parent directories
## Install
```
$ npm install --save find-up
```
## Usage
```
/
└── Users
└── sindresorhus
├── unicorn.png
└── foo
└── bar
├── baz
└── example.js
```
```js
// example.js
const findUp = require('find-up');
findUp('unicorn.png').then(filepath => {
console.log(filepath);
//=> '/Users/sindresorhus/unicorn.png'
});
```
## API
### findUp(filename, [options])
Returns a promise for the filepath or `null`.
### findUp.sync(filename, [options])
Returns a filepath or `null`.
#### filename
Type: `string`
Filename of the file to find.
#### options
##### cwd
Type: `string`
Default: `process.cwd()`
Directory to start from.
## Related
- [find-up-cli](https://github.com/sindresorhus/find-up-cli) - CLI for this module
- [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
- [pkg-dir](https://github.com/sindresorhus/pkg-dir) - Find the root directory of an npm package
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,24 @@
'use strict';
var fs = require('fs');
var Promise = require('pinkie-promise');
module.exports = function (fp) {
var fn = typeof fs.access === 'function' ? fs.access : fs.stat;
return new Promise(function (resolve) {
fn(fp, function (err) {
resolve(!err);
});
});
};
module.exports.sync = function (fp) {
var fn = typeof fs.accessSync === 'function' ? fs.accessSync : fs.statSync;
try {
fn(fp);
return true;
} catch (err) {
return false;
}
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,75 @@
{
"_args": [
[
"path-exists@2.1.0",
"C:\\Users\\deranjer\\GoglandProjects\\torrent-project\\torrent-project"
]
],
"_from": "path-exists@2.1.0",
"_id": "path-exists@2.1.0",
"_inBundle": false,
"_integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=",
"_location": "/react-scripts/eslint-module-utils/path-exists",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "path-exists@2.1.0",
"name": "path-exists",
"escapedName": "path-exists",
"rawSpec": "2.1.0",
"saveSpec": null,
"fetchSpec": "2.1.0"
},
"_requiredBy": [
"/react-scripts/eslint-module-utils/find-up"
],
"_resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz",
"_spec": "2.1.0",
"_where": "C:\\Users\\deranjer\\GoglandProjects\\torrent-project\\torrent-project",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/path-exists/issues"
},
"dependencies": {
"pinkie-promise": "^2.0.0"
},
"description": "Check if a path exists",
"devDependencies": {
"ava": "*",
"xo": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/path-exists#readme",
"keywords": [
"path",
"exists",
"exist",
"file",
"filepath",
"fs",
"filesystem",
"file-system",
"access",
"stat"
],
"license": "MIT",
"name": "path-exists",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/path-exists.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "2.1.0"
}

View File

@@ -0,0 +1,45 @@
# path-exists [![Build Status](https://travis-ci.org/sindresorhus/path-exists.svg?branch=master)](https://travis-ci.org/sindresorhus/path-exists)
> Check if a path exists
Because [`fs.exists()`](https://nodejs.org/api/fs.html#fs_fs_exists_path_callback) is being [deprecated](https://github.com/iojs/io.js/issues/103), but there's still a genuine use-case of being able to check if a path exists for other purposes than doing IO with it.
Never use this before handling a file though:
> In particular, checking if a file exists before opening it is an anti-pattern that leaves you vulnerable to race conditions: another process may remove the file between the calls to `fs.exists()` and `fs.open()`. Just open the file and handle the error when it's not there.
## Install
```
$ npm install --save path-exists
```
## Usage
```js
// foo.js
var pathExists = require('path-exists');
pathExists('foo.js').then(function (exists) {
console.log(exists);
//=> true
});
```
## API
### pathExists(path)
Returns a promise that resolves to a boolean of whether the path exists.
### pathExists.sync(path)
Returns a boolean of whether the path exists.
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,14 @@
'use strict';
var path = require('path');
var findUp = require('find-up');
module.exports = function (cwd) {
return findUp('package.json', {cwd: cwd}).then(function (fp) {
return fp ? path.dirname(fp) : null;
});
};
module.exports.sync = function (cwd) {
var fp = findUp.sync('package.json', {cwd: cwd});
return fp ? path.dirname(fp) : null;
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,89 @@
{
"_args": [
[
"pkg-dir@1.0.0",
"C:\\Users\\deranjer\\GoglandProjects\\torrent-project\\torrent-project"
]
],
"_from": "pkg-dir@1.0.0",
"_id": "pkg-dir@1.0.0",
"_inBundle": false,
"_integrity": "sha1-ektQio1bstYp1EcFb/TpyTFM89Q=",
"_location": "/react-scripts/eslint-module-utils/pkg-dir",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "pkg-dir@1.0.0",
"name": "pkg-dir",
"escapedName": "pkg-dir",
"rawSpec": "1.0.0",
"saveSpec": null,
"fetchSpec": "1.0.0"
},
"_requiredBy": [
"/react-scripts/eslint-module-utils"
],
"_resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-1.0.0.tgz",
"_spec": "1.0.0",
"_where": "C:\\Users\\deranjer\\GoglandProjects\\torrent-project\\torrent-project",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/pkg-dir/issues"
},
"dependencies": {
"find-up": "^1.0.0"
},
"description": "Find the root directory of a npm package",
"devDependencies": {
"ava": "*",
"xo": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/pkg-dir#readme",
"keywords": [
"package",
"json",
"root",
"npm",
"entry",
"find",
"up",
"find-up",
"findup",
"look-up",
"look",
"file",
"search",
"match",
"package",
"resolve",
"parent",
"parents",
"folder",
"directory",
"dir",
"walk",
"walking",
"path"
],
"license": "MIT",
"name": "pkg-dir",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/pkg-dir.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "1.0.0"
}

View File

@@ -0,0 +1,63 @@
# pkg-dir [![Build Status](https://travis-ci.org/sindresorhus/pkg-dir.svg?branch=master)](https://travis-ci.org/sindresorhus/pkg-dir)
> Find the root directory of a npm package
## Install
```
$ npm install --save pkg-dir
```
## Usage
```
/
└── Users
└── sindresorhus
└── foo
├── package.json
└── bar
├── baz
└── example.js
```
```js
// example.js
var pkgDir = require('pkg-dir');
pkgDir(__dirname).then(function (rootPath) {
console.log(rootPath);
//=> '/Users/sindresorhus/foo'
});
```
## API
### pkgDir([cwd])
Returns a promise that resolves to the package root path or `null`.
### pkgDir.sync([cwd])
Returns the package root path or `null`.
#### cwd
Type: `string`
Default: `process.cwd()`
Directory to start from.
## Related
- [pkg-dir-cli](https://github.com/sindresorhus/pkg-dir-cli) - CLI for this module
- [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,64 @@
{
"_args": [
[
"eslint-module-utils@2.1.1",
"C:\\Users\\deranjer\\GoglandProjects\\torrent-project\\torrent-project"
]
],
"_from": "eslint-module-utils@2.1.1",
"_id": "eslint-module-utils@2.1.1",
"_inBundle": false,
"_integrity": "sha512-jDI/X5l/6D1rRD/3T43q8Qgbls2nq5km5KSqiwlyUbGo5+04fXhMKdCPhjwbqAa6HXWaMxj8Q4hQDIh7IadJQw==",
"_location": "/react-scripts/eslint-module-utils",
"_phantomChildren": {
"pinkie-promise": "2.0.1"
},
"_requested": {
"type": "version",
"registry": true,
"raw": "eslint-module-utils@2.1.1",
"name": "eslint-module-utils",
"escapedName": "eslint-module-utils",
"rawSpec": "2.1.1",
"saveSpec": null,
"fetchSpec": "2.1.1"
},
"_requiredBy": [
"/react-scripts/eslint-plugin-import"
],
"_resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.1.1.tgz",
"_spec": "2.1.1",
"_where": "C:\\Users\\deranjer\\GoglandProjects\\torrent-project\\torrent-project",
"author": {
"name": "Ben Mosher",
"email": "me@benmosher.com"
},
"bugs": {
"url": "https://github.com/benmosher/eslint-plugin-import/issues"
},
"dependencies": {
"debug": "^2.6.8",
"pkg-dir": "^1.0.0"
},
"description": "Core utilities to support eslint-plugin-import and other module-related plugins.",
"engines": {
"node": ">=4"
},
"homepage": "https://github.com/benmosher/eslint-plugin-import#readme",
"keywords": [
"eslint-plugin-import",
"eslint",
"modules",
"esmodules"
],
"license": "MIT",
"name": "eslint-module-utils",
"repository": {
"type": "git",
"url": "git+https://github.com/benmosher/eslint-plugin-import.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "2.1.1"
}

View File

@@ -0,0 +1,49 @@
"use strict"
exports.__esModule = true
const moduleRequire = require('./module-require').default
const extname = require('path').extname
const log = require('debug')('eslint-plugin-import:parse')
exports.default = function parse(path, content, context) {
if (context == null) throw new Error('need context to parse properly')
let parserOptions = context.parserOptions
const parserPath = getParserPath(path, context)
if (!parserPath) throw new Error('parserPath is required!')
// hack: espree blows up with frozen options
parserOptions = Object.assign({}, parserOptions)
parserOptions.ecmaFeatures = Object.assign({}, parserOptions.ecmaFeatures)
// always attach comments
parserOptions.attachComment = true
// provide the `filePath` like eslint itself does, in `parserOptions`
// https://github.com/eslint/eslint/blob/3ec436ee/lib/linter.js#L637
parserOptions.filePath = path
// require the parser relative to the main module (i.e., ESLint)
const parser = moduleRequire(parserPath)
return parser.parse(content, parserOptions)
}
function getParserPath(path, context) {
const parsers = context.settings['import/parsers']
if (parsers != null) {
const extension = extname(path)
for (let parserPath in parsers) {
if (parsers[parserPath].indexOf(extension) > -1) {
// use this alternate parser
log('using alt parser:', parserPath)
return parserPath
}
}
}
// default to use ESLint parser
return context.parserPath
}

View File

@@ -0,0 +1,187 @@
"use strict"
exports.__esModule = true
const pkgDir = require('pkg-dir')
const fs = require('fs')
const path = require('path')
const hashObject = require('./hash').hashObject
, ModuleCache = require('./ModuleCache').default
const CASE_SENSITIVE_FS = !fs.existsSync(path.join(__dirname, 'reSOLVE.js'))
exports.CASE_SENSITIVE_FS = CASE_SENSITIVE_FS
const fileExistsCache = new ModuleCache()
// http://stackoverflow.com/a/27382838
exports.fileExistsWithCaseSync = function fileExistsWithCaseSync(filepath, cacheSettings) {
// don't care if the FS is case-sensitive
if (CASE_SENSITIVE_FS) return true
// null means it resolved to a builtin
if (filepath === null) return true
const parsedPath = path.parse(filepath)
, dir = parsedPath.dir
let result = fileExistsCache.get(filepath, cacheSettings)
if (result != null) return result
// base case
if (dir === '' || parsedPath.root === filepath) {
result = true
} else {
const filenames = fs.readdirSync(dir)
if (filenames.indexOf(parsedPath.base) === -1) {
result = false
} else {
result = fileExistsWithCaseSync(dir, cacheSettings)
}
}
fileExistsCache.set(filepath, result)
return result
}
function relative(modulePath, sourceFile, settings) {
return fullResolve(modulePath, sourceFile, settings).path
}
function fullResolve(modulePath, sourceFile, settings) {
// check if this is a bonus core module
const coreSet = new Set(settings['import/core-modules'])
if (coreSet != null && coreSet.has(modulePath)) return { found: true, path: null }
const sourceDir = path.dirname(sourceFile)
, cacheKey = sourceDir + hashObject(settings).digest('hex') + modulePath
const cacheSettings = ModuleCache.getSettings(settings)
const cachedPath = fileExistsCache.get(cacheKey, cacheSettings)
if (cachedPath !== undefined) return { found: true, path: cachedPath }
function cache(resolvedPath) {
fileExistsCache.set(cacheKey, resolvedPath)
}
function withResolver(resolver, config) {
function v1() {
try {
const resolved = resolver.resolveImport(modulePath, sourceFile, config)
if (resolved === undefined) return { found: false }
return { found: true, path: resolved }
} catch (err) {
return { found: false }
}
}
function v2() {
return resolver.resolve(modulePath, sourceFile, config)
}
switch (resolver.interfaceVersion) {
case 2:
return v2()
default:
case 1:
return v1()
}
}
const configResolvers = (settings['import/resolver']
|| { 'node': settings['import/resolve'] }) // backward compatibility
const resolvers = resolverReducer(configResolvers, new Map())
for (let pair of resolvers) {
let name = pair[0]
, config = pair[1]
const resolver = requireResolver(name, sourceFile)
, resolved = withResolver(resolver, config)
if (!resolved.found) continue
// else, counts
cache(resolved.path)
return resolved
}
// failed
// cache(undefined)
return { found: false }
}
exports.relative = relative
function resolverReducer(resolvers, map) {
if (resolvers instanceof Array) {
resolvers.forEach(r => resolverReducer(r, map))
return map
}
if (typeof resolvers === 'string') {
map.set(resolvers, null)
return map
}
if (typeof resolvers === 'object') {
for (let key in resolvers) {
map.set(key, resolvers[key])
}
return map
}
throw new Error('invalid resolver config')
}
function requireResolver(name, sourceFile) {
// Try to resolve package with conventional name
try {
return require(`eslint-import-resolver-${name}`)
} catch (err) { /* continue */ }
// Try to resolve package with custom name (@myorg/resolver-name)
try {
return require(name)
} catch (err) { /* continue */ }
// Try to resolve package with path, relative to closest package.json
// or current working directory
try {
const baseDir = pkgDir.sync(sourceFile) || process.cwd()
// absolute paths ignore base, so this covers both
return require(path.resolve(baseDir, name))
} catch (err) { /* continue */ }
// all else failed
throw new Error(`unable to load resolver "${name}".`)
}
const erroredContexts = new Set()
/**
* Given
* @param {string} p - module path
* @param {object} context - ESLint context
* @return {string} - the full module filesystem path;
* null if package is core;
* undefined if not found
*/
function resolve(p, context) {
try {
return relative( p
, context.getFilename()
, context.settings
)
} catch (err) {
if (!erroredContexts.has(context)) {
context.report({
message: `Resolve error: ${err.message}`,
loc: { line: 1, column: 0 },
})
erroredContexts.add(context)
}
}
}
resolve.relative = relative
exports.default = resolve

View File

@@ -0,0 +1,30 @@
'use strict'
exports.__esModule = true
const pattern = /(^|;)\s*(export|import)((\s+\w)|(\s*[{*]))/m
/**
* detect possible imports/exports without a full parse.
*
* A negative test means that a file is definitely _not_ a module.
* A positive test means it _could_ be.
*
* Not perfect, just a fast way to disqualify large non-ES6 modules and
* avoid a parse.
* @type {RegExp}
*/
exports.test = function isMaybeUnambiguousModule(content) {
return pattern.test(content)
}
// future-/Babel-proof at the expense of being a little loose
const unambiguousNodeType = /^(Exp|Imp)ort.*Declaration$/
/**
* Given an AST, return true if the AST unambiguously represents a module.
* @param {Program node} ast
* @return {Boolean}
*/
exports.isModule = function isUnambiguousModule(ast) {
return ast.body.some(node => unambiguousNodeType.test(node.type))
}