{"analyzedAt":"2022-06-28T02:52:06.882Z","collected":{"metadata":{"name":"tradeship","scope":"unscoped","version":"0.0.13","description":"Automatically imports missing JS dependencies and removes unused ones.","date":"2017-03-31T21:35:52.346Z","author":{"name":"Karthik Viswanathan","email":"karthik.ksv@gmail.com","username":"karthikv"},"publisher":{"username":"karthikv","email":"karthik.ksv@gmail.com"},"maintainers":[{"username":"karthikv","email":"karthik.ksv@gmail.com"}],"links":{"npm":"https://www.npmjs.com/package/tradeship","homepage":"https://github.com/karthikv/tradeship"},"dependencies":{"babel-code-frame":"^6.22.0","babylon":"^6.16.1","debug":"^2.6.2","escope":"^3.6.0","estraverse":"^4.2.0","globals":"^9.16.0","js-yaml":"^3.8.1","progress":"^1.1.8"},"devDependencies":{"@exponent/json-file":"^5.3.0","ava":"^0.18.2","eslint":"^3.18.0","prettier":"^0.17.1","react":"^15.4.2"},"releases":[{"from":"2022-05-29T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":1},{"from":"2022-03-30T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":1},{"from":"2021-12-30T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":1},{"from":"2021-06-28T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":1},{"from":"2020-06-28T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":1}],"hasTestScript":true,"readme":"[![tradeship][logo-image]][tradeship-url]\n\n[![Linux Build][travis-image]][travis-url]\n[![Windows Build][appveyor-image]][appveyor-url]\n[![NPM Version][npm-image]][npm-url]\n\ntradeship statically analyzes your JavaScript code for identifiers that aren't\ndefined and finds the appropriate dependencies to import. It also removes\nimports that aren't used. tradeship is meant to be used as an editor plugin that\nmanages your imports.\n\n![tradeship](http://g.recordit.co/OlDKhJc9LI.gif)\n\n## Features\n- Imports dependencies from node.js standard libraries, npm packages listed in\n  package.json, and other files within your project directory.\n- Infers properties that are exported by dependencies and imports them using\n  destructuring syntax (e.g. `const { Component } = require(\"react\");`).\n- Knows aliases for dependencies (e.g. `$` for jQuery, `_` for\n  lodash/underscore, `test` for ava, etc.) by analyzing more than 100 GB of\n  public JS code on GitHub.\n- Automatically identifies the style of your code and makes the imports match\n  (e.g. single vs. double quotes, semicolons vs. no semicolons, var vs. let vs.\n  const, etc.)\n- Statically analyzes files within your project directory to determine their\n  exports for use in other files.\n- Supports both CommonJS and ES6 modules. Can output `require()` or `import`\n  syntax.\n- Supports JSX identifiers and ensures React is in scope when using JSX.\n\n## Installation\nInstall tradeship using npm or yarn. It's recommended to either install\ntradeship globally or make the local installation available on your path (e.g.\nby adding `export PATH=node_modules/.bin:$PATH` to your shell configuration),\nsince editor plugins make use of the `tradeship` executable.\n\n```sh\n$ npm install -g tradeship\n# or use yarn:\n$ yarn global add tradeship\n```\n\nThen, install the editor plugin of your choice:\n\n- Vim: [`tradeship-vim`](https://github.com/karthikv/tradeship-vim)\n- Atom: [`tradeship-atom`](https://github.com/karthikv/tradeship-atom)\n- Sublime: [`tradeship-sublime`](https://github.com/karthikv/tradeship-sublime)\n- Emacs: [`tradeship-emacs`](https://github.com/karthikv/tradeship-emacs)\n\nEach editor plugin has instructions on how to run tradeship on the current file\nbeing edited. You can also configure each plugin to run tradeship on save. See\nthe respective links above for more information.\n\nThe first time tradeship runs in a project directory with many JavaScript files,\nit'll take some time to parse and cache dependencies. Future runs will be much\nfaster. If you'd like to use tradeship in a large project, it's recommended to\nrun it once on the command-line, as shown below, so you can see the progress as\nit populates the cache:\n\n```sh\ntradeship [path]\n```\n\nReplace `[path]` with any path to a JavaScript file in your project directory.\nNote that this won't modify the file in any way; it'll just print the new code\nto stdout. See the [Command Line Interface](#command-line-interface-cli) section\nfor details.\n\n## Configuration\ntradeship doesn't need any configuration to work out of the box. By design,\nalmost nothing is configurable, as tradeship automatically infers style from\nyour code. There is, however, one configuration option that you may want to\ntweak: environments.\n\nTo correctly find identifiers that aren't defined, tradeship needs to know what\nglobal variables are available. It does this through environments, where each\nenvironment defines a set of global variables that come with it. tradeship\npiggybacks on [eslint's configuration\nsystem](http://eslint.org/docs/user-guide/configuring) to avoid introducing\nanother configuration file and format.\n\nIn eslint, you specify the environments you want in your configuration file,\ngenerally at the root of your project directory. tradeship searches for an\neslint configuration file (either `.eslintrc.js`, `.eslintrc.yaml`,\n`.eslintrc.yml`, `.eslintrc.json`, `.eslintrc`, or an `eslintConfig` object in\n`package.json`) within the code's directory or successive parent directories.\n\nWhen it finds one, it looks at the `env` object to determine the active\nenvironments. An example configuration object is:\n\n```js\n{\n  \"env\": {\n    \"browser\": true,\n    \"es6\": true\n  }\n}\n```\n\nEach key is an environment name, and the corresponding value is whether that\nenvironment is active. See eslint's guide to [specifying\nenvironments](http://eslint.org/docs/user-guide/configuring#specifying-environments)\nfor more details about the available environments.\n\nIf there's no configuration file, `tradeship` assumes the environments\n`browser`, `node`, and `es6`, bringing in globals from the browser (e.g.\n`window` and `document`), from node.js (e.g. `process` and `__dirname`), and\nfrom ES6 (e.g. `Set` and `Map`).\n\nNote that tradeship makes all the node.js standard libraries available for\nimport if and only if the `node` environment is active.\n\n## Command Line Interface (CLI)\nUsing an editor plugin (see section above) is the easiest way to get started\nwith tradeship, but you can also use the command line interface (which all\neditor plugins use internally).\n\n```sh\ntradeship [options] [path]\n```\n\nReads the code given at `[path]`. Outputs new code to stdout, adding missing\ndependencies and removing unused ones. The `[options]` are as follows:\n\n- `-s` or `--stdin`: Read contents from stdin as opposed to `[path]`. `[path]`\n  is still required so that tradeship can resolve relative imports and find\n  available npm packages, but it need not exist as a file; you can even just\n  provide a directory.\n\n- `-w` or `--write`: Write output back to `[path]` (be careful!).\n\n- `-h` or `--help`: Print help.\n\n- `-v` or `--version`: Print version.\n\nThe full help text is below:\n\n```\nUsage: tradeship [options] [path]\nAutomatically imports missing JS dependencies and removes unused ones.\n\nOptions:\n-s, --stdin    read contents from stdin\n-w, --write    write output to source file (careful!)\n-h, --help     print help\n-v, --version  print version\n\nArguments:\n[path]  Relative imports and available npm packages will be determined\n        from this path. If not --stdin, input code will be read from this\n        path. If --write, new code will be written to this path.\n```\n\n## Node.js Interface\ntradeship exposes a simple node.js API if you'd like to use it programmatically:\n\n```js\nconst tradeship = require(\"tradeship\");\ntradeship.import(dir, code).then(newCode => {\n  // do something with newCode\n});\n```\n\n`dir` is the directory used to resolve relative imports and find available npm\npackages (generally the directory where the `code` comes from). `code` is the\nactual JavaScript code. `tradeship.import()` returns a promise that, when\nresolved, gives the resulting new code.\n\n## How it works\n`tradeship` analyzes dependencies from three sources: node.js standard\nlibraries, package.json dependencies, and other files within your project\ndirectory.\n\nFor each dependency it finds, tradeship:\n\n- **Determines potential import names**:\n\n  An import name is a variable name you might see in code that refers to the\n  dependency. For instance, the import name `fs` would refer to the `fs` node.js\n  standard library. The import name `React` would refer to the `react` npm\n  package.\n\n  For node.js standard libraries and package.json packages, if the\n  library/package name is itself a valid JavaScript identifier, it and its\n  capitalized version are potential import names (e.g. `react` and `React` for\n  the `react` npm package).  If the library/package name has non-word characters\n  or underscores, it is split on `[\\W_]+` and the parts are joined, both in\n  camel and class case, to get two more import names (`childProcess` and\n  `ChildProcess` for the `child_process` node.js standard library).\n\n  There are various package.json packages that are imported under common aliases\n  known by the community (e.g. `$` for jQuery, `_` for lodash/underscore, `test`\n  for ava, etc.). By analyzing more than 100 GB of public JS code on GitHub,\n  tradeship knows many such aliases, and will import the associated package.\n\n  For project files, the code is statically analyzed to find an import name. For\n  instance, if you write `module.exports = SomeExport;`, `SomeExport` will be an\n  import name. This is one simple case; there are many others that tradeship\n  parses, including those with ES6 `export` syntax. In addition to the analyzed\n  import name, tradeship also uses the file path's base name as an import name,\n  using the same logic as defined for node.js standard library names above.\n\n- **Determines properties**:\n\n  These are JavaScript object properties that are exported by the dependency.\n  For instance, `readFile` is a property of the `fs` node.js standard library.\n  `Component` is a property of the `react` npm package. The import name of\n  properties is equivalent to the property name.\n\n  For node.js standard libraries and package.json packages, the library is\n  loaded within a separate node.js process, and properties are extracted using\n  `Object.keys()`.\n\n  For project files, the code is statically analyzed to find properties. For\n  instance, if you write `exports.someProperty = ...;`, `someProperty` will be\n  a parsed property. This is one simple case; there are many others that\n  tradeship parses, including those with ES6 `export` syntax.\n\nThen, tradeship analyzes your code for identifiers that aren't defined. Each\nidentifier is a potential import name, and tradeship searches for the\ncorresponding dependency or property. If it finds a match, it adds the\nappropriate import to the code. If multiple dependencies or properties match\na given import name, tradeship prioritizes them as follows:\n\n1. Project file dependency (highest priority)\n1. Project file property\n1. package.json dependency\n1. package.json property\n1. Node.js standard library dependency\n1. Node.js standard library property (lowest priority)\n\ntradeship groups all node.js and package.json dependencies together, sorted\nlexicographically. It then adds a blank line and all project file dependencies,\nalso sorted lexicographically.\n\ntradeship finds all imports that aren't used and removes them.\n\n## License\n[MIT](https://github.com/karthikv/tradeship/blob/master/LICENSE.md)\n\nship vector icon by [Vecteezy](https://www.vecteezy.com/)\n\n[tradeship-url]: https://github.com/karthikv/tradeship\n[logo-image]: https://raw.githubusercontent.com/karthikv/tradeship/master/logo.png\n[travis-image]: https://img.shields.io/travis/karthikv/tradeship/master.svg?label=linux\n[travis-url]: https://travis-ci.org/karthikv/tradeship\n[appveyor-image]: https://img.shields.io/appveyor/ci/karthikv/tradeship/master.svg?label=windows\n[appveyor-url]: https://ci.appveyor.com/project/karthikv/tradeship\n[npm-image]: https://img.shields.io/npm/v/tradeship.svg\n[npm-url]: https://npmjs.org/package/tradeship"},"npm":{"downloads":[{"from":"2022-06-27T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":0},{"from":"2022-06-21T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":5},{"from":"2022-05-29T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":37},{"from":"2022-03-30T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":162},{"from":"2021-12-30T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":315},{"from":"2021-06-28T00:00:00.000Z","to":"2022-06-28T00:00:00.000Z","count":588}],"starsCount":0},"source":{"files":{"readmeSize":10780,"testsSize":0,"hasNpmIgnore":true},"badges":[{"urls":{"original":"https://img.shields.io/travis/karthikv/tradeship/master.svg?label=linux","service":"https://api.travis-ci.org/karthikv/tradeship.svg?branch=master","shields":"https://img.shields.io/travis/karthikv/tradeship/master.svg","content":"https://img.shields.io/travis/karthikv/tradeship/master.json"},"info":{"service":"travis","type":"build","modifiers":{"branch":"master"}}},{"urls":{"original":"https://img.shields.io/appveyor/ci/karthikv/tradeship/master.svg?label=windows","service":"https://ci.appveyor.com/api/projects/status/karthikv/tradeship/branch/master","shields":"https://img.shields.io/appveyor/ci/karthikv/tradeship/master.svg","content":"https://img.shields.io/appveyor/ci/karthikv/tradeship/master.json"},"info":{"service":"appveyor","type":"build","modifiers":{"branch":"master"}}},{"urls":{"original":"https://img.shields.io/npm/v/tradeship.svg","shields":"https://img.shields.io/npm/v/tradeship.svg","content":"https://img.shields.io/npm/v/tradeship.json"},"info":{"service":"npm","type":"version","modifiers":{"type":"v"}}}],"linters":["eslint","prettier"],"outdatedDependencies":{"progress":{"required":"^1.1.8","stable":"2.0.3","latest":"2.0.3"},"estraverse":{"required":"^4.2.0","stable":"5.3.0","latest":"5.3.0"},"globals":{"required":"^9.16.0","stable":"13.15.0","latest":"13.15.0"},"js-yaml":{"required":"^3.8.1","stable":"4.1.0","latest":"4.1.0"},"debug":{"required":"^2.6.2","stable":"4.3.4","latest":"4.3.4"}}}},"evaluation":{"quality":{"carefulness":0.295,"tests":0,"health":0.5,"branding":0.44999999999999996},"popularity":{"communityInterest":0,"downloadsCount":54,"downloadsAcceleration":-0.059646118721461194,"dependentsCount":0},"maintenance":{"releasesFrequency":0.7591609589041095,"commitsFrequency":0,"openIssues":0,"issuesDistribution":0}},"score":{"final":0.24468507960314193,"detail":{"quality":0.4214065999405643,"popularity":0.005338676696658518,"maintenance":0.33255589364897764}}}