pax_global_header00006660000000000000000000000064134442520640014516gustar00rootroot0000000000000052 comment=163abf4507ac2c282e1dd14a87f77707e79edb41 eslint-plugin-requirejs-4.0.0/000077500000000000000000000000001344425206400163205ustar00rootroot00000000000000eslint-plugin-requirejs-4.0.0/.editorconfig000066400000000000000000000002031344425206400207700ustar00rootroot00000000000000root = true [*] indent_style = space indent_size = 4 trim_trailing_whitespace = true end_of_line = lf insert_final_newline = true eslint-plugin-requirejs-4.0.0/.eslintignore000066400000000000000000000000301344425206400210140ustar00rootroot00000000000000coverage tests/fixtures eslint-plugin-requirejs-4.0.0/.eslintrc.yml000066400000000000000000000012421344425206400207430ustar00rootroot00000000000000root: true plugins: - "node" extends: - "eslint" - "plugin:node/recommended" rules: space-before-function-paren: - error - anonymous: always named: never no-use-before-define: off require-jsdoc: off no-var: error one-var: - error - never func-style: - error - declaration - allowArrowFunctions: true quote-props: - error - consistent no-undefined: off no-multi-spaces: - error - exceptions: { VariableDeclarator: true } curly: - error - multi-line key-spacing: - error - mode: minimum eslint-plugin-requirejs-4.0.0/.gitignore000066400000000000000000000011131344425206400203040ustar00rootroot00000000000000# Logs logs *.log # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directory # Commenting this out is preferred by some people, see # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- node_modules # Users Environment Variables .lock-wscript eslint-plugin-requirejs-4.0.0/.npmignore000066400000000000000000000001371344425206400203200ustar00rootroot00000000000000.editorconfig .eslintignore .eslintrc.yml .gitignore .npmrc .travis.yml makefile.js tests docs eslint-plugin-requirejs-4.0.0/.npmrc000066400000000000000000000000431344425206400174350ustar00rootroot00000000000000save-exact = true progress = false eslint-plugin-requirejs-4.0.0/.travis.yml000066400000000000000000000001371344425206400204320ustar00rootroot00000000000000language: node_js node_js: - 6 - 8 - 10 after_success: - "npm run coveralls" eslint-plugin-requirejs-4.0.0/CHANGELOG.md000066400000000000000000000177631344425206400201470ustar00rootroot00000000000000### v4.0.0 - March 19, 2019 * Upgrade Istanbul (Casey Visco) * New: no-restricted-amd-modules rule (fixes #109) (Stefan Buck) * Build: Remove support for node v4 (#111) (Stefan Buck) * Add URL to rule documentation to the metadata (#105) (Landon Abney) * Build: Update Travis Node versions (#108) (Mackie Underdown) ### v3.2.0 - May 1, 2018 * Fix: Support ArrowFunctionExpression in one-dependency-per-line (#107) (Mackie Underdown) ### v3.1.1 - January 2, 2017 * Added travis ci support for node 7 (Amila Welihinda) ### v3.1.0 - November 29, 2016 * New: Add support for Arrow Functions in `ast.isFunctionExpr` (#98) (Justin Cruz) ### v3.0.0 - September 26, 2016 * Breaking: Convert rules to new format (fixes #81) (Casey Visco) * New: Export `plugin:requirejs/recommended` config (Casey Visco) * Update: Refactor codebase to ES6 (Casey Visco) * Chore: Extract generic AST functions to own file (Casey Visco) * Chore: Convert all `var` to `const` or `let` (Casey Visco) * Chore: Update ESLint Dev and Peer versions to 3.x (fixes #95) (Casey Visco) * Chore: Replace custom `repeat` function with native ES6 (fixes #94) (Casey Visco) * Chore: Update eslintrc to support Node 4 ES6 features (fixes #92) (Casey Visco) * Chore: Remove old node versions from Travis CI (fixes #90) (Casey Visco) * Build: Improve Test Coverage of no-assign-require rule (Casey Visco) * Build: Refactor error message creators for amd-function-arity (Casey Visco) * Build: Add wrapper around ESLint RuleTester (Casey Visco) * Build: Move test fixtures to a single file (fixes #93) (Casey Visco) * Docs: Format rule list into tables (Casey Visco) * Docs: Update version note in README (Casey Visco) ### v2.0.1 - July 16, 2016 * Chore: Add .npmignore (fixes #91) (Casey Visco) * Chore: Implement `unique` util function (fixes #89) (Casey Visco) * Chore: Implement `repeat` util function (fixes #87) (Casey Visco) ### v2.0.0 - July 16, 2016 * Breaking: Bump ESLint peer version to 2.0.0 (fixes #76) (Casey Visco) * Breaking: Remove `rulesConfig` (fixes #84) (Casey Visco) * Fix: no-js-extension rule crashes on empty require (fixes #83) (Casey Visco) * Docs: Add Contributing Documentation (fixes #61) (Casey Visco) * Docs: Add Version Compatibility Section (Casey Visco) * Build: Remove rulesConfig related checks from makefile (Casey Visco) * Build: Fix RegExp in `changelog` target (Casey Visco) * Build: Add `unit` makefile target (Casey Visco) * Build: Add Node v6 to Travis CI Build (fixes #82) (Casey Visco) * Build: Roll ESLint Back to v2.13.1 (Casey Visco) * Upgrade: Update DevDependencies (fixes #80) (Casey Visco) * Upgrade: Update Dependencies (fixes #79) (Casey Visco) * Chore: Add npmrc file (Casey Visco) * Chore: Rename .eslintrc (Casey Visco) ### v0.10.0 - July 11, 2016 * Add array of allowed paths to allowExtraDependencies of amd-function-arity (fixes #77) (Sam Bason) ### v0.9.4 - February 1, 2016 * Update: sorting of paths with a plugin prefix (fixes #73) (Ondrej Brejla) ### v0.9.3 - January 28, 2016 * Fix failing tests in sort-amd-paths (Casey Visco) * Update: sort-amd-paths rule should give a better feedback (fixes #69) (Ondrej Brejla) * Update: sort-amd-paths should consider "/" before anything else (fixes #70) (Ondřej Brejla) ### v0.9.2 - January 26, 2016 * Update: invalid no-js-extension (fixes #62) (Ondrej Brejla) ### v0.9.1 - January 25, 2016 * API: introduce getAmdCallback() to utils API (fixes #65) (Ondrej Brejla) * Fix: Sort-amd-path rule should ignore some paths (fixes #63) (Ondrej Brejla) ### v0.9.0 - January 24, 2016 * Build: Update dependency versions (Casey Visco) * New: sort-amd-paths rule (fixes #59) (Ondrej Brejla) * Build: Auto-load fixtures (fixes #54) (Casey Visco) ### v0.8.0 - January 16, 2016 * New: Fixer for one-dependency-per-line rule (fixes #51). (Afnan Fahim) * Build: Add Node v4 and v5 targets to travis.yml (Casey Visco) ### v0.7.2 - January 13, 2016 * Build: Remove duplicate keys in .eslintrc (Casey Visco) ### v0.7.1 - January 13, 2016 * Fix: amd-function-arity no longer reports on dynamic dependencies (fixes #50) (Kevin Partington) ### v0.7.0 - December 19, 2015 * Fix: no-invalid-require tolerates Identifier/CallExpression callbacks (fixes #44) (Kevin Partington) * Build: Added files array to package.json (fixes #40) (Kevin Partington) * New: amd-function-arity rule (fixes #38) (Kevin Partington) * Build: Ensuring build can run on Windows (fixes #41) (Kevin Partington) * Update: no-multiple-define checks CallExpression only (fixes #42) (Kevin Partington) * Fix: enforce-define will warn on any non-ExpressionStatement (fixes #37) (Kevin Partington) * Docs: Use full URL for CHANGELOG in README (Casey Visco) * Docs: Link to eslint.org in README instead of repo (Casey Visco) * Docs: Fix typos in one-dependency-per-line docs (Casey Visco) ### v0.6.0 - August 9, 2015 * New: Implement one-dependency-per-line rule (fixes #34) (Casey Visco) * Add empty schemas for rules that take no options (Casey Visco) * Build: Add mocha npm script for running individual tests (Casey Visco) * Build: Improve fixture loading (Casey Visco) ### v0.5.3 - August 8, 2015 * Build: Add release scripts to package.json (Casey Visco) * Build: Add release tasks to makefile (Casey Visco) * Build: Add changelog task to makefile (Casey Visco) * Build: Add checkRules task to makefile (Casey Visco) * Build: Move lint and test tasks to makefile (Casey Visco) * Fix typo in default setting for enforce-define (Casey Visco) ### v0.5.2 - August 8, 2015 * Prevent no-commonjs-return false positive (fixes #36) (Casey Visco) * Build: Bump eslint version to 1.1.0 (Casey Visco) * Update: Provide schema for enforce-define rule (Casey Visco) * Build: Bump eslint version to 1.0.0 (Casey Visco) ### v0.5.1 - July 20, 2015 * Fix: Compare basename against ignore list in enforce-define (fixes #33) (Casey Visco) ### v0.5.0 - July 20, 2015 * New: Implement enforce-define rule (fixes #28) (Casey Visco) * Build: Upgrade eslint and eslint-tester versions (Casey Visco) ### v0.4.2 - June 29, 2015 * Fix: only include string literals in array returned from util.getDependencyNodes (fixes #32) (Casey Visco) ### v0.4.1 - June 25, 2015 * Fix: no-invalid-define rule affecting other rules (Andrew Sutton) ### v0.4.0 - June 13, 2015 * New: Implement no-invalid-require rule (fixes #19) * New: Implement no-js-extension rule (fixes #29) * Fix: Warn on invalid callback in no-invalid-require rule (fixes #30) * Update: Cleanup code in `util#isValidRequire` * Build: Execute coverage as part of `npm test` ### v0.3.0 - April 27, 2015 * New: Implement no-dynamic-require rule (fixes #18) * New: Implement no-conditional-require rule (fixes #22) * New: Implement no-require-tourl rule (fixes #21) * New: Implement no-assign-require rule (fixes #20) * Fix: Verify callee is an Identifier when testing CallExpression name (fixes #25) ### v0.2.3 - April 19, 2015 * Fix: Prevent rules from warning on non-define calls (fixes #23) ### v0.2.2 - April 16, 2015 * Update: Remove unused helpers lib * Docs: Clarify installation instructions * Docs: Add link to CHANGELOG from README ### v0.2.1 - April 16, 2015 * Fix: Permit named modules in no-invalid-define rule (fixes #17) * Fix: Flag named AMD module definitions as warning in no-amd-define (fixes #16) * Fix: Flag named CommonJS definitions as warning in no-commonjs-wrapper (fixes #15) * Fix: Flag named function definitions as warning in no-function-define (fixes #14) * Fix: Flag named object modules as warning in no-object-define (fixes #13) * Fix: Allow other forms of named modules in no-named-define (fixes #12) ### v0.2.0 - April 13, 2015 * Docs: Link to RequireJS home page from README * Docs: Sort rules in README by type (fixes #9) * New: Implement no-commonjs-module-exports rule (fixes #11) * New: Implement no-commonjs-exports rule (fixes #3) * New: Implement no-commonjs-return rule (fixes #4) * New: Implement no-assign-exports rule (fixes #6) ### v0.1.2 - April 3, 2015 * Fix: Allow plugin to work with wider range of eslint versions (fixes #8) ### v0.1.1 - April 2, 2015 * Docs: Cleanup README ### v0.1.0 - March 30, 2015 * Initial Release eslint-plugin-requirejs-4.0.0/CONTRIBUTING.md000066400000000000000000000004631344425206400205540ustar00rootroot00000000000000# Contributing Please be sure to read the following contribution guidelines before making or requesting a change. ### Filing an issue? Please read the [Issue Guidelines](docs/contributing/issues.md). ### Contributing code? Please read the [Pull Request Guidelines](docs/contributing/pull-requests.md). eslint-plugin-requirejs-4.0.0/LICENSE000066400000000000000000000020671344425206400173320ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2015 Casey Visco 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. eslint-plugin-requirejs-4.0.0/README.md000066400000000000000000000167111344425206400176050ustar00rootroot00000000000000[![npm][version-image]][version-url] [![Maintenance Status][status-image]][status-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Package Quality][packagequality-image]][packagequality-url] # eslint-plugin-requirejs Enforce code conventions for [RequireJS](http://requirejs.org) modules with [ESLint](http://eslint.org/). This plugin is under active development, and is updated frequently. Take a look at the [CHANGELOG](https://github.com/cvisco/eslint-plugin-requirejs/blob/master/CHANGELOG.md) to see what's recently been added or fixed. ## Installation Install [ESLint](https://www.github.com/eslint/eslint) either locally or globally, and then install the plugin (see below). It is important to note that a global instance of ESLint can only use plugins that are also installed globally. A local instance of ESLint, however, can make use of both local and global ESLint plugins. ### Global Installation $ npm install -g eslint $ npm install -g eslint-plugin-requirejs ### Local Installation $ npm install --save-dev eslint $ npm install --save-dev eslint-plugin-requirejs ### Installing Older Versions Please note: this plugin requires **Node 6.x or greater** and ESLint **version 3.x or greater**. If you need to use it with an older version of Node or ESLint, you may install a specific, previous version of the plugin: $ npm install --save-dev eslint-plugin-requirejs@3.2.0 ## Configuration Add the `plugins` section to your [config](http://eslint.org/docs/user-guide/configuring) file if not already present and specify `eslint-plugin-requirejs` as a plugin. The `eslint-plugin-` prefix may be omitted: ```json { "plugins": [ "requirejs" ] } ``` Enable the rules that you would like to use, for example: ```json { "rules": { "requirejs/no-invalid-define": 2, "requirejs/no-multiple-define": 2, "requirejs/no-named-define": 2, "requirejs/no-commonjs-wrapper": 2, "requirejs/no-object-define": 1 } } ``` ## Bundled Config This plugin provides the `plugin:requirejs/recommended` preset config. Which does the following: * Enables the `amd` environment * Enables all recommended rules, indicated with a :star: icon in the table below ## List of supported rules No rules are enabled by default. The `"extends": "plugin:requirejs/recommended"` property in a configuration file enables the marked with a :star:. The `--fix` option on the command line automatically fixes problems reported by rules marked by a :wrench:. ### Possible Errors These rules relate to possible syntax or logic errors in your module definition: | | | Rule | Description | | :----: | :------: | :--- | :---------- | | :star: | | [no-invalid-define](docs/rules/no-invalid-define.md) | Disallow invalid module definitions | | :star: | | [no-invalid-require](docs/rules/no-invalid-require.md) | Disallow invalid `require` or `requirejs` calls | | :star: | | [no-multiple-define](docs/rules/no-multiple-define.md) | Disallow multiple module definitions in one file | | :star: | | [no-assign-exports](docs/rules/no-assign-exports.md) | Disallow assignment to `exports` when using Simplified CommonJS Wrapper | | :star: | | [no-js-extension](docs/rules/no-js-extension.md) | Disallow `.js` extension in dependency paths | ### Stylistic Choices These rules relate to style guidelines, and are therefore quite subjective: | | | Rule | Description | | :----: | :------: | :--- | :---------- | | | | [no-object-define](docs/rules/no-object-define.md) | Disallow Simple Name/Value Pairs form of `define` | | | | [no-function-define](docs/rules/no-function-define.md) | Disallow Simple Function form of `define` | | | | [no-amd-define](docs/rules/no-amd-define.md) | Disallow AMD (dependency array) form of `define` | | | | [no-named-define](docs/rules/no-named-define.md) | Disallow named module form of `define` | | | | [no-commonjs-wrapper](docs/rules/no-commonjs-wrapper.md) | Disallow use of Simplified CommonJS Wrapper | | | | [no-commonjs-return](docs/rules/no-commonjs-return.md) | Disallow use of `return` statement in a module definition when using Simplified CommonJS Wrapper | | | | [no-commonjs-exports](docs/rules/no-commonjs-exports.md) | Disallow use of `exports` in a module definition when using Simplified CommonJS Wrapper | | | | [no-commonjs-module-exports](docs/rules/no-commonjs-module-exports.md) | Disallow use of `module.exports` in a module definition when using Simplified CommonJS Wrapper | | | | [no-dynamic-require](docs/rules/no-dynamic-require.md) | Disallow use of dynamically generated paths in a `require` call | | | | [no-conditional-require](docs/rules/no-conditional-require.md) | Disallow use of conditional `require` calls | | | | [no-assign-require](docs/rules/no-assign-require.md) | Disallow assignment to `require` or `window.require` | | | | [no-require-tourl](docs/rules/no-require-tourl.md) | Disallow use of `require.toUrl` and `require.nameToUrl` | | | | [enforce-define](docs/rules/enforce-define.md) | Require that all files be wrapped in a `define` call | | | :wrench: | [one-dependency-per-line](docs/rules/one-dependency-per-line.md) | Enforce line-break rules for AMD dependencies | | | | [amd-function-arity](docs/rules/amd-function-arity.md) | Ensure AMD callbacks have correct number of parameters | | | | [sort-amd-paths](docs/rules/sort-amd-paths.md) | Ensure that required paths are in alphabetical order | | | | [no-restricted-amd-modules](docs/rules/no-restricted-amd-modules.md) | Disallow specific amd modules | ### Don't see the rule you're looking for? Take a look at what's in progress for the next [milestone](https://github.com/cvisco/eslint-plugin-requirejs/milestones), or suggest a new rule by filing an [issue](https://github.com/cvisco/eslint-plugin-requirejs/issues). ## Contributing Contributions are encouraged. There are a few ways you can help: * **Filing issues** - if you find a bug or would like to request a new rule or enhancement, [file an issue](docs/contributing/issues.md) * **Submitting pull requests** - pick one of the open [issues](https://github.com/cvisco/eslint-plugin-requirejs/issues) to work on and submit a [pull request](docs/contributing/pull-requests.md) ## License eslint-plugin-requirejs is licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php). [version-url]: https://www.npmjs.com/package/eslint-plugin-requirejs [version-image]: https://img.shields.io/npm/v/eslint-plugin-requirejs.svg?style=flat-square [status-url]: https://github.com/cvisco/eslint-plugin-requirejs/pulse [status-image]: http://img.shields.io/badge/status-maintained-brightgreen.svg?style=flat-square [travis-url]: https://travis-ci.org/cvisco/eslint-plugin-requirejs [travis-image]: http://img.shields.io/travis/cvisco/eslint-plugin-requirejs/master.svg?style=flat-square [coveralls-url]: https://coveralls.io/r/cvisco/eslint-plugin-requirejs?branch=master [coveralls-image]: https://img.shields.io/coveralls/cvisco/eslint-plugin-requirejs/master.svg?style=flat-square [packagequality-url]: http://packagequality.com/#?package=eslint-plugin-requirejs [packagequality-image]: http://npm.packagequality.com/shield/eslint-plugin-requirejs.svg?style=flat-square eslint-plugin-requirejs-4.0.0/docs/000077500000000000000000000000001344425206400172505ustar00rootroot00000000000000eslint-plugin-requirejs-4.0.0/docs/contributing/000077500000000000000000000000001344425206400217575ustar00rootroot00000000000000eslint-plugin-requirejs-4.0.0/docs/contributing/dev-environment.md000066400000000000000000000053051344425206400254240ustar00rootroot00000000000000# Development Environment This plugin has a lightweight development environment that's very similar to ESLint's own. ## Setup This is a step-by-step guide to setting up a local development environment that will let you contribute to the project. ### Step 1: Install Node.js and npm Download and install the latest stable version from http://nodejs.org/. Alternatively, you may use a version manager such as [Node Version Manager](https://github.com/creationix/nvm) or [n](https://github.com/tj/n). Most installers also include [npm](http://npmjs.org/). ### Step 2: Fork and checkout this repository Go to the [eslint-plugin-requirejs repo](https://github.com/cvisco/eslint-plugin-requirejs) and click the “Fork” button. Follow the GitHub documentation for forking and cloning. Once you’ve cloned the repository, run `npm install` to get all the necessary dependencies: $ cd eslint-plugin-requirejs $ npm install ### Step 3: Add the upstream source The upstream source is the main repository that active development happens on. Setting the upstream source will allow you to pull in the latest code whenever you want. To add the upstream source for eslint-plugin-requirejs, run the following in your repository: $ git remote add upstream git@github.com:cvisco/eslint-plugin-requirejs.git ### Step 4: Run the tests Running the tests is the best way to ensure you have correctly set up your development environment. Make sure you’re in the the eslint-plugin-requirejs directory and run: $ npm test The testing should only take a few seconds to complete. If any tests fail, that likely means one or more parts of the environment setup didn’t complete correctly. The upstream tests always pass. ## Development Workflow Whenever you make changes to the source files, you’ll need to run `npm test` to rerun the tests. The workflow is: 1. Make changes 2. Run `npm test` to run tests on the command line You’ll have to do this each time you make a change. The tests are run automatically whenever a pull request is received, so make sure to verify your changes work before submitting them. ## Build Scripts This project has several build scripts that help with various parts of development. ### npm test The primary script to use is `npm test`, which does several things: 1. Lints all JavaScript (including tests and makefile) 2. Runs all tests 3. Checks code coverage targets Be sure to run this after making changes and before sending a pull request with your changes. ### npm run unit If you need to skip the lint check for any reason (useful during debugging), you can use this script to run the tests by themselves. ### npm run lint You can use this script to lint the code without running the tests. eslint-plugin-requirejs-4.0.0/docs/contributing/issues.md000066400000000000000000000035111344425206400236140ustar00rootroot00000000000000# Filing Issues Before filing an issue, please be sure to read the guidelines for what you're reporting: ## Reporting Bugs If you think you’ve found a bug in the eslint-plugin-requirejs code, please [file an issue](https://github.com/cvisco/eslint-plugin-requirejs/issues) on GitHub. Be sure to include the following information: * The version of ESLint you are using * The version of the plugin you are using * The actual source code that is causing the issue * In the case of an exception, the _complete_ output from ESLint You can never have too much detail in your bug report, so please include as much detail as possible to help us properly address your issue. ## Requesting a New Rule All rules in this plugin focus on specific [RequireJS](http://requirejs.org) features, patterns or potential issues. Any proposed new rule should do the same. Rules must be as atomic as possible, and not overlap with other rules. If you would like to propose a new rule, please [file an issue](https://github.com/cvisco/eslint-plugin-requirejs/issues) on GitHub. Be sure to include the following information: * When the rule will warn. Include a description as well as sample code. * Whether the rule prevents an error or is stylistic. * If you are interested or willing to create the rule yourself ## Changes to Existing Rules In the event that a rule is found to be incomplete or inflexible, it may need an enhancement. If you would like to propose an enhancement to an existing rule, please [file an issue](https://github.com/cvisco/eslint-plugin-requirejs/issues) on GitHub. Be sure to include the following information: * The version of ESLint you are using * The version of the plugin you are using * The rule you want to change * The source code you want to be flagged as incorrect * What happens when the rule is applied to the code without your change eslint-plugin-requirejs-4.0.0/docs/contributing/pull-requests.md000066400000000000000000000121101344425206400251210ustar00rootroot00000000000000# Pull Requests If you want to contribute to the eslint-plugin-requirejs repo, please use a GitHub pull request. This is the fastest way for us to evaluate your code and to merge it into the code base. ## Getting Started If you’d like to work on a pull request, follow these steps: 1. Set up a [development environment](dev-environment.md). 2. Ensure there’s an issue that describes what you’re doing. You can [create a new issue](issues.md) or work on an [existing issue](https://github.com/cvisco/eslint-plugin-requirejs/issues). 3. Documentation-only changes do not require an issue and may be submitted directly from the GitHub website. ## Working with the Code The process of submitting a pull request for this plugin is almost identical to that of ESLint and follows the same pattern each time: ### Step 1: Create a new branch Create a new branch in your eslint-plugin-requirejs fork. Give the branch a descriptive name that describes what it is you’re fixing, such as: $ git checkout -b issue-12 You should do all of your development for the issue in this branch. **Note:** Do not combine fixes for multiple issues into one branch. Use a separate branch for each issue you’re working on. ### Step 2: Make your changes Make the changes to the code, tests and relevant documentation, following the existing code conventions as you go. Once you have finished, commit the changes to your branch: $ git add -A $ git commit Our commit message format is as follows: Tag: Short description (fixes #12) Longer description here if necessary The first line of the commit message (the summary) must have a specific format. The `Tag` is one of the following: * `Fix` - for a bug fix. * `Update` - for a backwards-compatible enhancement or change to an existing rule. * `New` - implemented a new feature or rule. * `Breaking` - for a backwards-_incompatible_ enhancement or feature. * `Docs` - changes to documentation only. * `Build` - changes to build process only. * `Upgrade` - for a dependency upgrade. * `Chore` - for refactoring, adding tests, etc. (anything that isn’t user-facing). The message summary should be a one-sentence description of the change, and it must be 72 characters in length or shorter. The issue number should be mentioned at the end. The commit message format is important because these messages are used to automatically generate a changelog for each release. The tag and issue number help to create more consistent and useful changelogs. ### Step 3: Rebase onto upstream Before you send the pull request, be sure to rebase onto the upstream source. This ensures your code is running on the latest available code. $ git fetch upstream $ git rebase upstream/master ### Step 4: Run the tests After rebasing, be sure to run all of the tests once again to make sure nothing broke: $ npm test If there are any failing tests, update your code until all tests pass. ### Step 5: Push your changes Next, push your changes to your clone: $ git push origin issue-12 If you are unable to push because some references are old, do a forced push instead: $ git push -f origin issue-12 ### Step 6: Submit the pull request Now you’re ready to send the pull request. Go to your eslint-plugin-requirejs fork and then follow the [GitHub documentation](https://help.github.com/articles/creating-a-pull-request/) on how to send a pull request. ## Code Review Once your pull request is sent, it may take some time to fully review. In the mean time, here are a few points to keep in mind: * Monitor the status of the Travis CI build for your pull request. If it fails, please investigate why. We will not merge pull requests with broken tests or reduced code coverage. * Respond to comments left on the pull request from reviewers. Remember, we want to help you land your code, so please be receptive to feedback. * We may ask you to make changes, rebase, or squash your commits. ### Updating the Commit Message If your commit message is in the incorrect format, you’ll be asked to update it. You can do so via: $ git commit --amend This will open up your editor so you can make changes. After that, you’ll need to do a forced push to your branch: $ git push -f origin issue-12 ### Updating the Code If you are asked to make code changes, there’s no need to close the pull request and create a new one. Just go back to the branch on your fork and make your changes. Then, when you’re ready, you can add your changes into the branch: $ git add -A $ git commit --amend $ git push -f origin issue-12 This adds all your new changes, then amends the previous commit with them. ### Rebasing If your code is out-of-date, you may be asked to rebase. That means we want you to apply your changes on top of the latest upstream code. Make sure you have set up a development environment and then you can rebase using these commands: $ git fetch upstream $ git rebase upstream/master You might find that there are merge conflicts when you attempt to rebase. Please resolve the conflicts and then do a forced push to your branch: $ git push -f origin issue-12 eslint-plugin-requirejs-4.0.0/docs/rules/000077500000000000000000000000001344425206400204025ustar00rootroot00000000000000eslint-plugin-requirejs-4.0.0/docs/rules/amd-function-arity.md000066400000000000000000000141001344425206400244320ustar00rootroot00000000000000# Ensure AMD callbacks have correct number of parameters (amd-function-arity) ## Rule Details This rule aims to ensure that AMD callbacks have the correct number of parameters in order to avoid confusion and maintainability issues. ### Options This rule takes one option, an object with the key `allowExtraDependencies`. This can either have a Boolean value (default is `false`) or be an array of named allowed dependency paths as strings. ```json "requirejs/amd-function-arity": [2, { "allowExtraDependencies": true }] ``` ```json "requirejs/amd-function-arity": [2, { "allowExtraDependencies": ["a", "b"] }] ``` #### Without allowing extra dependencies The following patterns are considered warnings: ```js /* eslint requirejs/amd-function-arity: [2, { "allowExtraDependencies": false }] */ define(["a", "b"], function (a, b, c) { // ... }); define(["a", "b"], function (a) { // ... }); define("my-module", ["a", "b"], function (a, b, c) { // ... }); define("my-module", ["a", "b"], function (a) { // ... }); require(["a", "b"], function (a, b, c) { // ... }); require(["a", "b"], function (a) { // ... }); require(["a", "b"], function (a, b, c) { // ... }, function (err) { }); require(["a", "b"], function (a) { // ... }, function (err) { }); require("a", function () { // ... }); require("a", function (a, b) { // ... }); requirejs(["a", "b"], function (a, b, c) { // ... }); requirejs(["a", "b"], function (a) { // ... }); requirejs(["a", "b"], function (a, b, c) { // ... }, function (err) { }); requirejs(["a", "b"], function (a) { // ... }, function (err) { }); requirejs("a", function () { // ... }); requirejs("a", function (a, b) { // ... }); ``` The following patterns are not considered warnings: ```js /* eslint requirejs/amd-function-arity: [2, { "allowExtraDependencies": false }] */ define(["a", "b"], function (a, b) { // ... }); define("my-module", ["a", "b"], function (a, b) { // ... }); require(["a", "b"], function (a, b) { // ... }); require(["a", "b"], function (a, b) { // ... }, function (err) { }); requirejs(["a", "b"], function (a, b) { // ... }); require("a", function (a) { // ... }); require("a", function (a) { // ... }, function (err) { }); ``` #### Allowing extra dependencies The following patterns are considered warnings: ```js /* eslint requirejs/amd-function-arity: [2, { "allowExtraDependencies": true }] */ define(["a", "b"], function (a, b, c) { // ... }); define("my-module", ["a", "b"], function (a, b, c) { // ... }); require(["a", "b"], function (a, b, c) { // ... }); require(["a", "b"], function (a, b, c) { // ... }, function (err) { }); require("a", function (a, b) { // ... }); requirejs(["a", "b"], function (a, b, c) { // ... }); requirejs(["a", "b"], function (a, b, c) { // ... }, function (err) { }); requirejs(["a", "b"], function (a) { // ... }, function (err) { }); requirejs("a", function (a, b) { // ... }); ``` The following patterns are not considered warnings: ```js /* eslint requirejs/amd-function-arity: [2, { "allowExtraDependencies": false }] */ define(["a", "b"], function (a) { // ... }); define(["a", "b"], function (a, b) { // ... }); define("my-module", ["a", "b"], function (a) { // ... }); define("my-module", ["a", "b"], function (a, b) { // ... }); require(["a", "b"], function (a) { // ... }); require(["a", "b"], function (a, b) { // ... }); require(["a", "b"], function (a) { // ... }, function (err) { }); require(["a", "b"], function (a, b) { // ... }, function (err) { }); requirejs(["a", "b"], function (a) { // ... }); requirejs(["a", "b"], function (a, b) { // ... }); require("a", function () { // ... }); require("a", function (a) { // ... }); requirejs("a", function () { // ... }); requirejs("a", function (a) { // ... }); require("a", function () { // ... }, function (err) { }); require("a", function (a) { // ... }, function (err) { }); ``` #### Allowing extra named dependencies The following patterns are considered warnings: ```js /* eslint requirejs/amd-function-arity: [2, { "allowExtraDependencies": ["x", "y", "z"] }] */ define(["a", "b"], function (a, b, c) { // ... }); define("my-module", ["a", "b"], function (a, b, c) { // ... }); require(["a", "b"], function (a, b, c) { // ... }); require(["a", "b"], function (a, b, c) { // ... }, function (err) { }); require("a", function (a, b) { // ... }); requirejs(["a", "b"], function (a, b, c) { // ... }); requirejs(["a", "b"], function (a, b, c) { // ... }, function (err) { }); requirejs(["a", "b"], function (a) { // ... }, function (err) { }); requirejs("a", function (a, b) { // ... }); ``` The following patterns are not considered warnings: ```js /* eslint requirejs/amd-function-arity: [2, { "allowExtraDependencies": ["a", "b"] }] */ define(["a", "b"], function (a) { // ... }); define(["a", "b"], function (a, b) { // ... }); define("my-module", ["a", "b"], function (a) { // ... }); define("my-module", ["a", "b"], function (a, b) { // ... }); require(["a", "b"], function (a) { // ... }); require(["a", "b"], function (a, b) { // ... }); require(["a", "b"], function (a) { // ... }, function (err) { }); require(["a", "b"], function (a, b) { // ... }, function (err) { }); requirejs(["a", "b"], function (a) { // ... }); requirejs(["a", "b"], function (a, b) { // ... }); require("a", function () { // ... }); require("a", function (a) { // ... }); requirejs("a", function () { // ... }); requirejs("a", function (a) { // ... }); require("a", function () { // ... }, function (err) { }); require("a", function (a) { // ... }, function (err) { }); ``` ## When Not To Use It If you do not care about potential errors from using extra (undefined) callback parameters and do not care about requiring dependencies for side effects only, you can disable this rule. ## Further Reading * [Define a Module](http://requirejs.org/docs/api.html#define) eslint-plugin-requirejs-4.0.0/docs/rules/enforce-define.md000066400000000000000000000030551344425206400236000ustar00rootroot00000000000000# Require that all files be wrapped in a `define` call (enforce-define) ## Rule Details This rule aims to enforce consistency in a project by requiring that all JavaScript files be wrapped in a call to `define`. It will warn if it encounters an expression other than `define` in the body of the program. ### Options This rule takes one option, which can be a string representing a filename to ignore, or an array of strings, to ignore multiple filenames. This is useful to prevent this rule from warning in your app's main file, for example. ```json "requirejs/enforce-define": [2, "main.js"] "requirejs/enforce-define": [2, ["main.js", "app.js"]] ``` #### With no ignored filename(s): The following pattern is considered a warning: ```js // main.js require(['foo', 'bar'], function (foo, bar) { /* ... */ }); ``` The following pattern is not considered a warning: ```js // some_module.js define(['baz'], function (baz) { /* ... */ }); ``` #### With options [2, "main.js"]: The following pattern is considered a warning: ```js // some_module.js require(['foo', 'bar'], function (foo, bar) { /* ... */ }); ``` The following patterns are not considered warnings: ```js // main.js require(['foo', 'bar'], function (foo, bar) { /* ... */ }); // some_module.js define(['baz'], function (baz) { /* ... */ }); ``` ## When Not To Use It If you wish you to allow files in your project that are not wrapped in a `define`, then it is safe to disable this rule. ## Further Reading * [Define a Module](http://requirejs.org/docs/api.html#define) eslint-plugin-requirejs-4.0.0/docs/rules/no-amd-define.md000066400000000000000000000031761344425206400233360ustar00rootroot00000000000000# Disallow use of AMD (dependency array) form of `define` (no-amd-define) Traditionally, RequireJS module definitions take the form of an array of dependencies for the module followed by a definition function. In this form, the dependencies are passed to the definition function as arguments. The trouble happens when you have a large number of dependencies for a module. Maintaining both the dependency list and the function arguments—and making sure they match—can be difficult and prone to error. In those cases it might be wise to discourage use of this pattern in favor of the Simplified CommonJS Wrapper. ## Rule Details This rule aims to prevent usage of AMD-style module definitions. The following patterns are considered warnings: ```js // Module Definition with Dependency Array define(['path/to/foo', 'path/to/bar'], function (foo, bar) { /* ... */ }); // Module Definition with Empty Dependency Array define([], function () { /* ... */ }); // Named Module Definition with Dependency Array define('path/to/baz', ['path/to/foo'], function (foo) { /* ... */ }); ``` The following patterns are not warnings: ```js // Simple Name/Value Pairs define({ a: 'foo', b: 'bar' }); // Simple Definition Function define(function () { /* ... */ }); // Simplified CommonJS Wrapper define(function (require) { var foo = require('path/to/foo'), bar = require('path/to/bar'); /* ... */ }); ``` ## When Not To Use It If you want to use AMD-style module definitions, then it is safe to disable this rule. ## Further Reading * [Definition Functions with Dependencies](http://requirejs.org/docs/api.html#defdep) eslint-plugin-requirejs-4.0.0/docs/rules/no-assign-exports.md000066400000000000000000000015171344425206400243300ustar00rootroot00000000000000# Disallow assignment to `exports` when using Simplified CommonJS Wrapper (no-assign-exports) ## Rule Details This rule aims to prevent assignment to the `exports` variable. This is generally an error, as assignment should be done to `module.exports` instead. This rule is only in effect when using the Simplified CommonJS Wrapper. The following patterns are considered warnings: ```js define(function (require, exports) { exports = function () { /* ... */ }; }); define(function (require, exports) { exports = { doSomething: function () { /* ... */ } }; }); ``` The following patterns are not warnings: ```js define(function (require, exports) { exports.doSomething: function () { /* ... */ }; }); ``` ## When Not To Use It You should probably *not* disable this rule. eslint-plugin-requirejs-4.0.0/docs/rules/no-assign-require.md000066400000000000000000000017651344425206400243050ustar00rootroot00000000000000# Disallow assignment to `require` or `window.require` (no-assign-require) RequireJS allows you to pass configuration options by assigning to global variable `require` before RequireJS is loaded. This form of passing config may not work with third-party module loaders such as [Almond](https://github.com/jrburke/almond), however. In other cases, overwriting `require` is probably an error, and should be avoided. ## Rule Details The following patterns are considered warnings: ```js var require = { /* ... config ... */ }; window.require = { /* ... config ... */ } ``` The following pattern is not a warning: ```js // Not a potential overwrite foo.require = 'bar'; ``` ## When Not To Use It If you aren't using a third-party module loader and you wish to pass configuration this way, then it is safe to disable this rule. ## Further Reading * [RequireJS Configuration Options](http://requirejs.org/docs/api.html#config) * [Almond Restrictions](https://github.com/jrburke/almond#restrictions) eslint-plugin-requirejs-4.0.0/docs/rules/no-commonjs-exports.md000066400000000000000000000031041344425206400246630ustar00rootroot00000000000000# Disallow use of `exports` in a module definition when using Simplified CommonJS Wrapper (no-commonjs-exports) When using the Simplified CommonJS Wrapper, module definition functions may export a value in one of three ways; by assigning to `module.exports`, adding a property to the `exports` object, or by directly returning a value. For stylistic reasons, you may wish to prevent modification of the `exports` object. Note that this rule is only in affect when using the Simplified CommonJS Wrapper form of `define`. It will *not* flag modifications of the `exports` object in any other function. ## Rule Details This rule aims to prevent exporting module values by modifying the `exports` object. The following patterns are considered warnings: ```js define(function (require, exports) { var foo = require('path/to/foo'), bar = require('path/to/bar'); exports.doSomething = function () { /* ... */ }; }); ``` The following patterns are not warnings: ```js define(function (require, exports, module) { var foo = require('path/to/foo'), bar = require('path/to/bar'); module.exports = { doSomething: function () { /* ... */ }; } }); define(function (require) { var foo = require('path/to/foo'), bar = require('path/to/bar'); return function () { /* ... */ }; }); ``` ## When Not To Use It If you want to allow exporting a module value by modifiying the `exports` object, then it is safe to disable this rule. ## Further Reading * [Define a Module with Simplified CommonJS Wrapper](http://requirejs.org/docs/api.html#cjsmodule) eslint-plugin-requirejs-4.0.0/docs/rules/no-commonjs-module-exports.md000066400000000000000000000031021344425206400261440ustar00rootroot00000000000000# Disallow use of `module.exports` in a module definition when using Simplified CommonJS Wrapper (no-commonjs-module-exports) When using the Simplified CommonJS Wrapper, module definition functions may export a value in one of three ways; by assigning to `module.exports`, adding a property to the `exports` object, or by directly returning a value. For stylistic reasons, you may wish to prevent assigning to `module.exports`. Note that this rule is only in affect when using the Simplified CommonJS Wrapper form of `define`. It will *not* flag assignments to `module.exports` in any other function. ## Rule Details This rule aims to prevent exporting module values by assigning to `module.exports`. The following patterns are considered warnings: ```js define(function (require, exports, module) { var foo = require('path/to/foo'), bar = require('path/to/bar'); module.exports = { doSomething: function () { /* ... */ }; } }); ``` The following patterns are not warnings: ```js define(function (require, exports) { var foo = require('path/to/foo'), bar = require('path/to/bar'); exports.doSomething = function () { /* ... */ }; }); define(function (require) { var foo = require('path/to/foo'), bar = require('path/to/bar'); return function () { /* ... */ }; }); ``` ## When Not To Use It If you want to allow exporting a module value by assigning to `module.exports`, then it is safe to disable this rule. ## Further Reading * [Define a Module with Simplified CommonJS Wrapper](http://requirejs.org/docs/api.html#cjsmodule) eslint-plugin-requirejs-4.0.0/docs/rules/no-commonjs-return.md000066400000000000000000000032161344425206400245020ustar00rootroot00000000000000# Disallow use of `return` statement in a module definition when using Simplified CommonJS Wrapper (no-commonjs-return) When using the Simplified CommonJS Wrapper, module definition functions may export a value in one of three ways; by assigning to `module.exports`, adding a property to the `exports` object, or by directly returning a value. Exporting a value via `return` is typical of AMD modules, but not CommonJS modules. If you're using the Simplified CommonJS Wrapper, you may wish to enable this rule. Note that this rule is only in affect when using the Simplified CommonJS Wrapper form of `define`. It will *not* flag `return` statements in AMD definitions or simple function definitions. ## Rule Details This rule aims to prevent exporting module values with `return`. The following patterns are considered warnings: ```js define(function (require) { var foo = require('path/to/foo'), bar = require('path/to/bar'); return function () { /* ... */ }; }); ``` The following patterns are not warnings: ```js define(function (require, exports) { var foo = require('path/to/foo'), bar = require('path/to/bar'); exports.doSomething = function () { /* ... */ }; }); define(function (require, exports, module) { var foo = require('path/to/foo'), bar = require('path/to/bar'); module.exports = { doSomething: function () { /* ... */ }; } }); ``` ## When Not To Use It If you want to allow exporting a module value using the `return` statement, then it is safe to disable this rule. ## Further Reading * [Define a Module with Simplified CommonJS Wrapper](http://requirejs.org/docs/api.html#cjsmodule) eslint-plugin-requirejs-4.0.0/docs/rules/no-commonjs-wrapper.md000066400000000000000000000034141344425206400246430ustar00rootroot00000000000000# Disallow use of the Simplified CommonJS Wrapper form of `define` (no-commonjs-wrapper) The Simplified CommonJS Wrapper is a way to easily reuse CommonJS modules in the browser. It may not work reliably in some cases, however. Depending on your projects needs or stylistic preference, you may wish to prevent use of this feature. ## Rule Details This rule aims to prevent usage of wrapped CommonJS-style module definitions. The following patterns are considered warnings: ```js define(function (require) { var foo = require('path/to/foo'), bar = require('path/to/bar'); return function () { /* ... */ }; }); define(function (require, exports) { var foo = require('path/to/foo'), bar = require('path/to/bar'); exports.doSomething = function () { /* ... */ }; }); define(function (require, exports, module) { var foo = require('path/to/foo'), bar = require('path/to/bar'); module.exports = { doSomething: function () { /* ... */ }; } }); // Named CommonJS module define('path/to/baz', function (require, exports, module) { var foo = require('path/to/foo'), bar = require('path/to/bar'); module.exports = { doSomething: function () { /* ... */ }; } }); ``` The following patterns are not warnings: ```js // Simple Name/Value Pairs define({ a: 'foo', b: 'bar' }); // Simple Definition Function define(function () { /* ... */ }); // Definition Function with Dependency Array define(['path/to/foo', 'path/to/bar'], function (foo, bar) { /* ... */ }); ``` ## When Not To Use It If you want to use the Simplified CommonJS Wrapper, then it is safe to disable this rule. ## Further Reading * [Define a Module with Simplified CommonJS Wrapper](http://requirejs.org/docs/api.html#cjsmodule) eslint-plugin-requirejs-4.0.0/docs/rules/no-conditional-require.md000066400000000000000000000024511344425206400253150ustar00rootroot00000000000000# Disallow use of conditional `require` calls (no-conditional-require) If you are using [r.js](http://requirejs.org/docs/optimization.html) to create an optimized build of your project, or using a third-party module loader such as [Almond](https://github.com/jrburke/almond), you may wish to avoid conditional loading of dependencies, as it might not be possible to optimize these. ## Rule Details This rule aims to prevent usage of `require` inside of a conditional statement or expression. The following patterns are considered warnings: ```js if (someCondition) { require(['a', 'b'], function (a, b) { /* ... */ }); } define(function (require) { if (someCondition) { var lib = require('lib'); /* ... */ } }); define(function (require) { var lib = someCondition ? require('a') : require('b'); /* ... */ }); ``` The following patterns are not warnings: ```js define(['a', 'b'], function (a, b) { /* ... */ }); define(function (require) { var a = require('a'); /* ... */ }); ``` ## When Not To Use It If you want to use conditionally loaded modules, then it is safe to disable this rule. ## Further Reading * [RequireJS Optimizer](http://requirejs.org/docs/optimization.html) * [Almond Restrictions](https://github.com/jrburke/almond#restrictions) eslint-plugin-requirejs-4.0.0/docs/rules/no-dynamic-require.md000066400000000000000000000026071344425206400244410ustar00rootroot00000000000000# Disallow use of dynamically generated paths in a `require` call (no-dynamic-require) If you are using [r.js](http://requirejs.org/docs/optimization.html) to create an optimized build of your project, or using a third-party module loader such as [Almond](https://github.com/jrburke/almond), you should avoid dynamic `require` calls, as these cannot be optimized. ## Rule Details This rule aims to prevent usage of dynamic `require` calls. The following patterns are considered warnings: ```js // AMD-Style Require var paths = someCondition ? ['a', 'b'] : ['c', 'd']; require(paths, function (a, b) { /* ... */ }); require(['path/to/' + name], function (mod) { /* ... */ }); // Simplified CommonJS Wrapped Require define(function (require) { var lib = require(someCondition ? 'a' : 'b'); /* ... */ }); define(function (require) { var lib = require('path/to/' + name); /* ... */ }); ``` The following patterns are not warnings: ```js define(['path/to/a', 'path/to/b'], function (a, b) { /* ... */ }); define(function (require) { var a = require('path/to/a'); /* ... */ }); ``` ## When Not To Use It If you want to use dynamically-generated paths in a `require` call, then it is safe to disable this rule. ## Further Reading * [RequireJS Optimizer](http://requirejs.org/docs/optimization.html) * [Almond Restrictions](https://github.com/jrburke/almond#restrictions) eslint-plugin-requirejs-4.0.0/docs/rules/no-function-define.md000066400000000000000000000021471344425206400244170ustar00rootroot00000000000000# Disallow use of simple function definition form of `define` (no-function-define) ## Rule Details This rule aims to prevent usage of simple function definitions. Note that this rule does not flag use of the Simplified CommonJS Wrapper form of `define`. That is considered a special form of definition function and is handled by a separate rule. The following patterns are considered warnings: ```js define(function () { /* ... */ }); define('path/to/baz', function () { /* ... */ }); ``` The following patterns are not warnings: ```js // Simple Name/Value Pairs define({ a: 'foo', b: 'bar' }); // Definition Function with Dependency Array define(['path/to/foo', 'path/to/bar'], function (foo, bar) { /* ... */ }); // Simplified CommonJS Wrapper define(function (require) { var foo = require('path/to/foo'), bar = require('path/to/bar'); /* ... */ }); ``` ## When Not To Use It If you want to use simple definition functions with no dependency array, then it is safe to disable this rule. ## Further Reading * [Definition Functions](http://requirejs.org/docs/api.html#deffunc) eslint-plugin-requirejs-4.0.0/docs/rules/no-invalid-define.md000066400000000000000000000015321344425206400242150ustar00rootroot00000000000000# Disallow invalid forms of `define` (no-invalid-define) ## Rule Details This rule aims to prevent malformed `define` calls. Any pattern except for the following are warnings: ```js // Simple Name/Value Pairs define({ a: 'foo', b: 'bar' }); // Definition Function define(function () { /* ... */ }); // Definition Function with Dependencies define(['path/to/foo', 'path/to/bar'], function (foo, bar) { /* ... */ }); // Named Module with Dependencies define('path/to/baz', ['path/to/foo'], function (foo) { /* ... */ }); // Simplified CommonJS Wrapper define(function (require) { var foo = require('path/to/foo'), bar = require('path/to/bar'); /* ... */ }); ``` ## When Not To Use It You should probably *not* disable this rule. ## Further Reading * [Define a Module](http://requirejs.org/docs/api.html#define) eslint-plugin-requirejs-4.0.0/docs/rules/no-invalid-require.md000066400000000000000000000015441344425206400244420ustar00rootroot00000000000000# Disallow invalid `require` or `requirejs` calls (no-invalid-require) ## Rule Details This rule aims to prevent malformed `require` calls. The following patterns are considered warnings: ```js // String literal for dependency list require('foo', function (foo) { /* ... */ }); // Missing dependency list require(function () { /* ... */ }); // `define` was probably what was intended here require({ foo: 'bar' }); ``` The following patterns are not warnings: ```js // Dependency list provided as array require(['foo'], function (foo) { /* ... */ }); // `require` inside Simplified CommonJS Wrapper define(function (require) { var foo = require('foo'); /* ... */ }); ``` ## When Not To Use It You should probably *not* disable this rule. ## Further Reading * [Invalid Require Call](http://requirejs.org/docs/errors.html#requireargs) eslint-plugin-requirejs-4.0.0/docs/rules/no-js-extension.md000066400000000000000000000040361344425206400237670ustar00rootroot00000000000000# Disallow `.js` extension in dependency paths (no-js-extension) ## Rule Details Dependency paths in RequireJS should not use a `.js` extension, since the path could be a for a package directory. Extensions may only be used in combination with a plugin prefix. ### Options This rule takes one argument, an array of strings where each string represents a plugin prefix. All paths starting with some of the listed plugin prefixes will be also checked for a missing `.js` extension. All other paths with unknown plugin prefixes will be skipped. By default, paths with a plugin prefix are not checked. #### With no argument The following patterns are considered warnings: ```js require(['foo.js'], function (foo) { /* ... */ }); define(['foo.js'], function (foo) { /* ... */ }); define(function (require) { var foo = require('foo.js'); /* ... */ }); ``` The following patterns are not warnings: ```js require(['foo'], function (foo) { /* ... */ }); define(['foo'], function (foo) { /* ... */ }); define(function (require) { var foo = require('foo'); /* ... */ }); require(['pluginname!foo'], function (foo) { /* ... */ }); define(['pluginname!foo'], function (foo) { /* ... */ }); define(function (require) { var foo = require('pluginname!foo'); /* ... */ }); ``` #### With options `[2, [ "first", "second", "third" ]]` The following patterns are considered warnings: ```js require(['first!foo.js'], function (foo) { /* ... */ }); define(['second!foo.js'], function (foo) { /* ... */ }); define(function (require) { var foo = require('third!foo.js'); /* ... */ }); ``` The following patterns are not warnings: ```js require(['unknownplugin!foo.js'], function (foo) { /* ... */ }); define(['anotherunknownplugin!foo.js'], function (foo) { /* ... */ }); define(function (require) { var foo = require('foo'); /* ... */ }); ``` ## When Not To Use It You should probably *not* disable this rule. ## Further Reading * [RequireJS Usage](http://requirejs.org/docs/api.html#usage) eslint-plugin-requirejs-4.0.0/docs/rules/no-multiple-define.md000066400000000000000000000012061344425206400244200ustar00rootroot00000000000000# Disallow multiple module definitions in one file (no-multiple-define) Due to how RequireJS' lookup algorithm works, only one module should be defined per file. ## Rule Details This rule aims to prevent definition of multiple modules in one file. The following pattern is considered a warning: ```js // MyModule.js define('MyModule/first', ['path/to/foo'], function (foo) { /* ... */ }); define('MyModule/second', ['path/to/bar'], function (bar) { /* ... */ }); ``` ## When Not To Use It You should probably *not* disable this rule. ## Further Reading * [RequireJS Module Notes](http://requirejs.org/docs/api.html#modulenotes) eslint-plugin-requirejs-4.0.0/docs/rules/no-named-define.md000066400000000000000000000021401344425206400236470ustar00rootroot00000000000000# Disallow use of named module form of `define` (no-named-define) ## Rule Details This rule aims to prevent usage of named module definitions. The following patterns are considered warnings: ```js // Named Object Definition define('path/to/baz', { a: 'foo', b: 'bar' }); // Named Function Defintion define('path/to/baz', function () { /* ... */ }); // Named AMD module define('path/to/baz', ['path/to/foo'], function (foo) { /* ... */ }); ``` The following patterns are not warnings: ```js // Simple Name/Value Pairs define({ a: 'foo', b: 'bar' }); // Definition Function define(function () { /* ... */ }); // Definition Function with Dependencies define(['path/to/foo', 'path/to/bar'], function (foo, bar) { /* ... */ }); // Simplified CommonJS Wrapper define(function (require) { var foo = require('path/to/foo'), bar = require('path/to/bar'); /* ... */ }); ``` ## When Not To Use It If you want to use named modules, then it is safe to disable this rule. ## Further Reading * [Define a Module with a Name](http://requirejs.org/docs/api.html#modulename) eslint-plugin-requirejs-4.0.0/docs/rules/no-object-define.md000066400000000000000000000017721344425206400240430ustar00rootroot00000000000000# Disallow use of Simple Name/Value Pairs form of `define` (no-object-define) ## Rule Details This rule aims to prevent usage of plain object module definitions. The following patterns are considered warnings: ```js define({ a: 'foo', b: 'bar' }); define('path/to/baz', { a: 'foo', b: 'bar' }); ``` The following patterns are not warnings: ```js // Definition Function define(function () { /* ... */ }); // Definition Function with Dependencies define(['path/to/foo', 'path/to/bar'], function (foo, bar) { /* ... */ }); // Named Module with Dependencies define('path/to/baz', ['path/to/foo'], function (foo) { /* ... */ }); // Simplified CommonJS Wrapper define(function (require) { var foo = require('path/to/foo'), bar = require('path/to/bar'); /* ... */ }); ``` ## When Not To Use It If you want to use plain object modules, then it is safe to disable this rule. ## Further Reading * [Simple Name/Value Pairs](http://requirejs.org/docs/api.html#defsimple) eslint-plugin-requirejs-4.0.0/docs/rules/no-require-tourl.md000066400000000000000000000015071344425206400241600ustar00rootroot00000000000000# Disallow use of `require.toUrl` and `require.nameToUrl` (no-require-tourl) RequireJS provides these methods as a way to generate a url that is relative to a module. Some third-party module loaders such as [Almond](https://github.com/jrburke/almond), do not support the use of these functions. ## Rule Details The following patterns are considered warnings: ```js define(['require'], function (require) { var cssUrl = require.toUrl('./style.css'); /* ... */ }); define(['require'], function (require) { var idUrl = require.nameToUrl('id'); /* ... */ }); ``` ## When Not To Use It If you are not using Almond, then it is safe to disable this rule. ## Further Reading * [RequireJS Module Notes](http://requirejs.org/docs/api.html#modulenotes) * [Almond Restrictions](https://github.com/jrburke/almond#restrictions) eslint-plugin-requirejs-4.0.0/docs/rules/no-restricted-amd-modules.md000066400000000000000000000045151344425206400257200ustar00rootroot00000000000000# Disallow specific amd modules (no-restricted-amd-modules) Disallowing usage of specific AMD modules can be useful if you want to limit the available methods a developer can use. For example, you can block usage of the `module-foo` module if you want to force using a more performant module named `module-bar`. ## Rule Details This rule allows you to specify modules that you don’t want to use in your application. ## Options The rule takes one or more strings as options: the names of restricted modules. ```json "no-restricted-amd-modules": ["error", "module-foo", "module-bar"] ``` It can also take an object with lists of `paths` and gitignore-style `patterns` strings. ```json "no-restricted-amd-modules": ["error", { "paths": ["module-foo", "module-bar"], "patterns": ["module-foo/private/*", "module-bar/*", "!module-bar/good"] }] ``` You may also specify a custom message for any paths you want to restrict as follows: ```json "no-restricted-amd-modules": ["error", { "name": "module-foo1", "message": "Please use module-foo2 instead." }, { "name": "module-bar2", "message": "Please use module-bar2 instead." } ] ``` or like this: ```json "no-restricted-amd-modules": ["error", { "paths": [{ "name": "module-foo", "message": "Please use module-bar instead." }] }] ``` The custom message will be appended to the default error message. Please note that you may not specify custom error messages for restricted patterns as a particular module may match more than one pattern. ## Examples Examples of **incorrect** code for this rule: ```js /*eslint no-restricted-amd-modules: ["error", "foo", "bar"]*/ define(['foo', 'bar', 'baz'], function () { /* ... */ }); ``` ```js /*eslint no-restricted-amd-modules: ["error", {"paths": ["foo/bar"] }]*/ define(['foo/bar', 'baz'], function () { /* ... */ }); ``` ```js /*eslint no-restricted-amd-modules: ["error", { "patterns": ["foo/bar/*"] }]*/ define(['foo/bar/baz'], function () { /* ... */ }); ``` Examples of **correct** code for this rule: ```js /*eslint no-restricted-amd-modules: ["error", "baz"]*/ define(['foo', 'bar'], function () { /* ... */ }); ``` ```js /*eslint no-restricted-amd-modules: ["error", { "paths": ["foo"], "patterns": ["baz/*", "!baz/pick"] }]*/ define(['bar', 'baz/pick'], function () { /* ... */ }); ``` eslint-plugin-requirejs-4.0.0/docs/rules/one-dependency-per-line.md000066400000000000000000000067411344425206400253420ustar00rootroot00000000000000# Enforce line-break rules for AMD dependencies (one-dependency-per-line) When more than a handful of dependencies are required in a module, the list can quickly become too long to fit on one line. Inconsistent line break usage can also make it hard to read and maintain long lists of dependencies. ## Rule Details This rule aims to enforce consistent line-break usage in dependency lists. ### Options The rule takes one option, an object, which has two keys, `paths` and `names`. These keys allow individual control over the line-break rules for, respectively, the dependency path list and the list of names (arguments) passed to the module definition function. Each key can either be a string `"always"` or `"never"`, or a numeric value representing the maximum number of dependencies each list can contain before enforcing the one-dependency-per-line rule. The default is `{ "paths": "always", "names": "always" }`. ```json "one-dependency-per-line": [2, { "paths": "always", "names": "never" }] "one-dependency-per-line": [2, { "paths": 3, "names": 3 }] ``` The following examples demonstate the behavior of these options. #### { "paths": "always", "names": "always" } When the mode is set to `"always"`, each dependency must be placed on a separate line. In this mode, the following pattern is considered a warning: ```js require(['jquery', 'underscore', 'backbone'], function ($, _, Backbone) { /* ... */ }); ``` Whereas, the following pattern is *not* considered a warning: ```js require([ 'jquery', 'underscore', 'backbone' ], function ( $, _, Backbone ) { /* ... */ }); ``` #### { "paths": "never", "names": "never" } When the mode is set to `"never"`, dependency lists must appear on one line. In this mode, the following pattern is considered a warning: ```js require([ 'jquery', 'underscore', 'backbone' ], function ( $, _, Backbone ) { /* ... */ }); ``` Whereas, the following pattern is *not* considered a warning: ```js require(['jquery', 'underscore', 'backbone'], function ($, _, Backbone) { /* ... */ }); ``` #### { "paths": 3, "names": 3 } When a number value is provided, it defines the maximum number of dependencies a list can contain before line-breaking is enforced for all dependencies in that list. This allows for very short dependency lists to appear on a single line, but longer ones to spaced appropriately. In this mode, the following patterns are considered warnings: ```js // "one-dependency-per-line": [2, { "paths": "always", "names": 3 }] require([ 'jquery', 'underscore', 'backbone', 'some/other/module' ], function ($, _, Backbone, SomeOtherModule) { /* ... */ }); // "one-dependency-per-line": [2, { "paths": 2, "names": 2 }] require(['jquery', 'underscore', 'backbone'], function ($, _, Backbone) { /* ... */ }); ``` Whereas, the following patterns are *not* considered warnings: ```js // "one-dependency-per-line": [2, { "paths": "always", "names": 3 }] require([ 'jquery', 'underscore', 'backbone', 'some/other/module' ], function ( $, _, Backbone, SomeOtherModule ) { /* ... */ }); // "one-dependency-per-line": [2, { "paths": 2, "names": 2 }] require(['jquery', 'underscore'], function ($, _) { /* ... */ }); ``` ## When Not To Use It If your project will not be following any consistent line-break pattern for dependencies, it is safe to turn off this rule. ## Further Reading * [Define a Module](http://requirejs.org/docs/api.html#define) eslint-plugin-requirejs-4.0.0/docs/rules/sort-amd-paths.md000066400000000000000000000241201344425206400235660ustar00rootroot00000000000000# Ensure that required paths are in alphabetical order (sort-amd-paths) ## Rule Details This rule checks whether the required paths in `define` and `require` statements are ordered alphabetically or not. ### Options This rule takes one argument, an object, which has three keys, `"compare"`, `"sortPlugins"` and `"ignoreCase"`. #### `compare` Determines which part (or parts) of the path will be used to sort by. The possible values are: * `dirname-basename` (default) - Performs a compound sort. First, sorts by directory name only, then, within the same directory, sorts by module file name. * `fullpath` - Sorts by the full path, including the module file name. * `basename` - Sorts by module file name only, ignoring the directory name. #### `sortPlugins` Determines how paths with plugin prefix will be sorted. The possible values are: * `preserve` (default) - Treats plugin prefix as part of full path when sorting. * `ignore` - Ignores plugin prefix completely when sorting. * `first` - Paths with plugin prefix will be sorted before non-prefixed paths. * `last` - Paths with plugin prefix will be sorted after non-prfixed paths. #### `ignoreCase` Accepts a boolean value. Determines whether the comparison should be case-sensitive or not. The default is `true`. ```json "requirejs/sort-amd-paths": [ 2, { "compare": "dirname-basename", "sortPlugins": "preserve", "ignoreCase": true } ] ``` #### With no argument, with options `[2, { "compare": "dirname-basename" }]`, `[2, { "compare": "dirname-basename", "ignoreCase": true }]` and `[2, { "compare": "dirname-basename", "sortPlugins": "preserve", "ignoreCase": true }]`: The following pattern is considered a warning: ```js define([ 'aaa/bbb/ccc', 'aaa/bbb/aaa' ], function (ccc, aaa) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'aaa/ddd', 'aaa/bbb/aaa' ], function (ddd, aaa) { /* ... */ }); ``` #### With options `[2, { "compare": "dirname-basename", "ignoreCase": false }]`: The following pattern is considered a warning: ```js define([ 'aaa/bbb/aaa', 'aaa/bbb/Ccc' ], function (aaa, ccc) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'aaa/bbb/Aaa', 'aaa/bbb/Ccc' ], function (aaa, ccc) { /* ... */ }); ``` #### With options `[2, { "compare": "dirname-basename", "sortPlugins": "preserve" }]`: The following pattern is considered a warning: ```js define([ 'aaa/aaa/aaa', 'ccc/ccc/ccc', 'bbb!fff/fff/fff1', 'bbb!fff/fff/fff2', 'ggg/ggg/ggg' ], function (aaa, ccc, fff1, fff2, ggg) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'aaa/aaa/aaa', 'bbb!fff/fff/fff', 'ccc/ccc/ccc', 'ggg/ggg/ggg', 'hhh!ddd/ddd/ddd' ], function (aaa, fff, ccc, ggg, ddd) { /* ... */ }); ``` #### With options `[2, { "compare": "dirname-basename", "sortPlugins": "ignore" }]`: The following pattern is considered a warning: ```js define([ 'aaa/aaa/aaa', 'bbb!fff/fff/fff', 'ccc/ccc/ccc', 'ggg/ggg/ggg', 'hhh!ddd/ddd/ddd' ], function (aaa, fff, ccc, ggg, ddd) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'aaa/aaa/aaa', 'ccc/ccc/ccc', 'bbb!fff/fff/fff1', 'bbb!fff/fff/fff2', 'ggg/ggg/ggg' ], function (aaa, ccc, fff1, fff2, ggg) { /* ... */ }); ``` #### With options `[2, { "compare": "dirname-basename", "sortPlugins": "first" }]`: The following pattern is considered a warning: ```js define([ 'aaa/aaa/aaa', 'ccc/ccc/ccc', 'ggg/ggg/ggg', 'bbb!fff/fff/fff1', 'bbb!fff/fff/fff2' ], function (aaa, ccc, ggg, fff1, fff2) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'bbb!fff/fff/fff1', 'bbb!fff/fff/fff2', 'aaa/aaa/aaa', 'ccc/ccc/ccc', 'ggg/ggg/ggg' ], function (fff1, fff2, aaa, ccc, ggg) { /* ... */ }); ``` #### With options `[2, { "compare": "dirname-basename", "sortPlugins": "last" }]`: The following pattern is considered a warning: ```js define([ 'bbb!fff/fff/fff1', 'bbb!fff/fff/fff2', 'aaa/aaa/aaa', 'ccc/ccc/ccc', 'ggg/ggg/ggg' ], function (fff1, fff2, aaa, ccc, ggg) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'aaa/aaa/aaa', 'ccc/ccc/ccc', 'ggg/ggg/ggg', 'bbb!fff/fff/fff1', 'bbb!fff/fff/fff2' ], function (aaa, ccc, ggg, fff1, fff2) { /* ... */ }); ``` #### With options `[2, { "compare": "fullpath" }]` and `[2, { "compare": "fullpath", "ignoreCase": true }]`: The following pattern is considered a warning: ```js define([ 'aaa/bbb/xxx', 'aaa/bbb/ccc/ddd' ], function (xxx, ddd) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'aaa/bbb/ccc/ddd', 'aaa/bbb/xxx' ], function (ddd, xxx) { /* ... */ }); ``` #### With options `[2, { "compare": "fullpath", "ignoreCase": false }]`: The following pattern is considered a warning: ```js define([ 'aaa/bbb/aaa', 'aaa/bbb/Ccc' ], function (aaa, ccc) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'aaa/bbb/Aaa', 'aaa/bbb/Ccc' ], function (aaa, ccc) { /* ... */ }); ``` #### With options `[2, { "compare": "fullpath", "sortPlugins": "preserve" }]`: The following pattern is considered a warning: ```js define([ 'aaa/aaa/aaa', 'ccc/ccc/ccc', 'bbb!fff/fff/fff1', 'bbb!fff/fff/fff2', 'ggg/ggg/ggg' ], function (aaa, ccc, fff1, fff2, ggg) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'aaa/aaa/aaa', 'bbb!fff/fff/fff', 'ccc/ccc/ccc', 'ggg/ggg/ggg', 'hhh!ddd/ddd/ddd' ], function (aaa, fff, ccc, ggg, ddd) { /* ... */ }); ``` #### With options `[2, { "compare": "fullpath", "sortPlugins": "ignore" }]`: The following pattern is considered a warning: ```js define([ 'aaa/aaa/aaa', 'bbb!fff/fff/fff', 'ccc/ccc/ccc', 'ggg/ggg/ggg', 'hhh!ddd/ddd/ddd' ], function (aaa, fff, ccc, ggg, ddd) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'aaa/aaa/aaa', 'ccc/ccc/ccc', 'bbb!fff/fff/fff1', 'bbb!fff/fff/fff2', 'ggg/ggg/ggg' ], function (aaa, ccc, fff1, fff2, ggg) { /* ... */ }); ``` #### With options `[2, { "compare": "fullpath", "sortPlugins": "first" }]`: The following pattern is considered a warning: ```js define([ 'aaa/aaa/aaa', 'ccc/ccc/ccc', 'ggg/ggg/ggg', 'bbb!fff/fff/fff1', 'bbb!fff/fff/fff2' ], function (aaa, ccc, ggg, fff1, fff2) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'bbb!fff/fff/fff1', 'bbb!fff/fff/fff2', 'aaa/aaa/aaa', 'ccc/ccc/ccc', 'ggg/ggg/ggg' ], function (fff1, fff2, aaa, ccc, ggg) { /* ... */ }); ``` #### With options `[2, { "compare": "fullpath", "sortPlugins": "last" }]`: The following pattern is considered a warning: ```js define([ 'bbb!fff/fff/fff1', 'bbb!fff/fff/fff2', 'aaa/aaa/aaa', 'ccc/ccc/ccc', 'ggg/ggg/ggg' ], function (fff1, fff2, aaa, ccc, ggg) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'aaa/aaa/aaa', 'ccc/ccc/ccc', 'ggg/ggg/ggg', 'bbb!fff/fff/fff1', 'bbb!fff/fff/fff2' ], function (aaa, ccc, ggg, fff1, fff2) { /* ... */ }); ``` #### With options `[2, { "compare": "basename" }]` and `[2, { "compare": "basename", "ignoreCase": true }]`: The following pattern is considered a warning: ```js define([ 'aaa/xxx', 'xxx/aaa' ], function (xxx, aaa) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'xxx/aaa', 'aaa/xxx' ], function (aaa, xxx) { /* ... */ }); ``` #### With options `[2, { "compare": "basename", "ignoreCase": false }]`: The following pattern is considered a warning: ```js define([ 'aaa/aaa', 'aaa/bbb/Ccc' ], function (aaa, ccc) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'aaa/Aaa', 'aaa/bbb/Ccc' ], function (aaa, ccc) { /* ... */ }); ``` #### With options `[2, { "compare": "basename", "sortPlugins": "preserve" }]` and `[2, { "compare": "basename", "sortPlugins": "ignore" }]`: The following pattern is considered a warning: ```js define([ 'hhh!dwhat/ever5/ddd', 'bbb!fwhat/ever2/fff', 'awhat/ever1/aaa', 'cwhat/ever3/ccc', 'gwhat/ever4/ggg' ], function (ddd, fff, aaa, ccc, ggg) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'awhat/ever1/aaa', 'cwhat/ever3/ccc', 'hhh!dwhat/ever5/ddd', 'bbb!fwhat/ever2/fff', 'gwhat/ever4/ggg' ], function (aaa, ccc, ddd, fff, ggg) { /* ... */ }); ``` #### With options `[2, { "compare": "basename", "sortPlugins": "first" }]`: The following pattern is considered a warning: ```js define([ 'awhat/ever1/aaa', 'cwhat/ever3/ccc', 'gwhat/ever4/ggg', 'hhh!dwhat/ever5/ddd', 'bbb!fwhat/ever2/fff' ], function (aaa, ccc, ggg, ddd, fff) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'hhh!dwhat/ever5/ddd', 'bbb!fwhat/ever2/fff', 'awhat/ever1/aaa', 'cwhat/ever3/ccc', 'gwhat/ever4/ggg' ], function (ddd, fff, aaa, ccc, ggg) { /* ... */ }); ``` #### With options `[2, { "compare": "basename", "sortPlugins": "last" }]`: The following pattern is considered a warning: ```js define([ 'hhh!dwhat/ever5/ddd', 'bbb!fwhat/ever2/fff', 'awhat/ever1/aaa', 'cwhat/ever3/ccc', 'gwhat/ever4/ggg' ], function (ddd, fff, aaa, ccc, ggg) { /* ... */ }); ``` The following pattern is not considered a warning: ```js define([ 'awhat/ever1/aaa', 'cwhat/ever3/ccc', 'gwhat/ever4/ggg', 'hhh!dwhat/ever5/ddd', 'bbb!fwhat/ever2/fff' ], function (aaa, ccc, ggg, ddd, fff) { /* ... */ }); ``` ## When Not To Use It If you don't want to have required paths in alphabetical order, then it is safe to disable this rule. ## Further Reading * [Definition Functions with Dependencies](http://requirejs.org/docs/api.html#defdep)eslint-plugin-requirejs-4.0.0/index.js000066400000000000000000000040521344425206400177660ustar00rootroot00000000000000"use strict"; module.exports = { rules: { "no-invalid-define": require("./lib/rules/no-invalid-define"), "no-invalid-require": require("./lib/rules/no-invalid-require"), "no-multiple-define": require("./lib/rules/no-multiple-define"), "no-assign-exports": require("./lib/rules/no-assign-exports"), "no-js-extension": require("./lib/rules/no-js-extension"), "no-object-define": require("./lib/rules/no-object-define"), "no-function-define": require("./lib/rules/no-function-define"), "no-amd-define": require("./lib/rules/no-amd-define"), "no-named-define": require("./lib/rules/no-named-define"), "no-commonjs-wrapper": require("./lib/rules/no-commonjs-wrapper"), "no-commonjs-return": require("./lib/rules/no-commonjs-return"), "no-commonjs-exports": require("./lib/rules/no-commonjs-exports"), "no-commonjs-module-exports": require("./lib/rules/no-commonjs-module-exports"), "no-dynamic-require": require("./lib/rules/no-dynamic-require"), "no-conditional-require": require("./lib/rules/no-conditional-require"), "no-assign-require": require("./lib/rules/no-assign-require"), "no-require-tourl": require("./lib/rules/no-require-tourl"), "enforce-define": require("./lib/rules/enforce-define"), "one-dependency-per-line": require("./lib/rules/one-dependency-per-line"), "amd-function-arity": require("./lib/rules/amd-function-arity"), "sort-amd-paths": require("./lib/rules/sort-amd-paths"), "no-restricted-amd-modules": require("./lib/rules/no-restricted-amd-modules") }, configs: { recommended: { env: { amd: true }, rules: { "requirejs/no-invalid-define": "error", "requirejs/no-invalid-require": "error", "requirejs/no-multiple-define": "error", "requirejs/no-assign-exports": "error", "requirejs/no-js-extension": "error" } } } }; eslint-plugin-requirejs-4.0.0/lib/000077500000000000000000000000001344425206400170665ustar00rootroot00000000000000eslint-plugin-requirejs-4.0.0/lib/rules/000077500000000000000000000000001344425206400202205ustar00rootroot00000000000000eslint-plugin-requirejs-4.0.0/lib/rules/amd-function-arity.js000066400000000000000000000065021344425206400242730ustar00rootroot00000000000000/** * @file Rule to ensure AMD-style callbacks contain correct number of * arguments * @author Kevin Partington */ "use strict"; const rjs = require("../utils/rjs"); const ast = require("../utils/ast"); const hasCallback = ast.hasCallback; const getDependencyNodes = rjs.getDependencyNodes; const getModuleFunction = rjs.getModuleFunction; const isAmdDefine = rjs.isAmdDefine; const isRequireCall = rjs.isRequireCall; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Ensure AMD-style callbacks contain correct number of arguments", category: "Stylistic Choices", recommended: false, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/amd-function-arity.md" }; const schema = [ { type: "object", properties: { allowExtraDependencies: { anyOf: [ { type: "boolean", default: false }, { type: "array", uniqueItems: true, items: { type: "string" } } ] } }, additionalProperties: false } ]; const defaults = { allowExtraDependencies: false }; // ----------------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------------- const isBoolean = (value) => typeof value === "boolean"; const unassigned = (paths, params) => paths.slice(params.length); const includes = (list) => (path) => list.indexOf(path.value) !== -1; const isAmdWithCallback = (node) => isAmdDefine(node) || isRequireCall(node) && hasCallback(node); const reportTooFew = (expected, actual) => `Not enough parameters in callback (expected ${expected}, found ${actual}).`; const reportTooMany = (expected, actual) => `Too many parameters in callback (expected ${expected}, found ${actual}).`; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { const opts = Object.assign({}, defaults, context.options[0]); const allowed = opts.allowExtraDependencies; const isAllowed = (paths) => isBoolean(allowed) ? allowed : paths.every(includes(allowed)); return { CallExpression(node) { if (!isAmdWithCallback(node)) return; const paths = getDependencyNodes(node); const pathCount = paths.length; if (!pathCount) return; const params = getModuleFunction(node).params; const paramCount = params.length; if (pathCount < paramCount) { context.report(node, reportTooMany(pathCount, paramCount)); } if (pathCount > paramCount && !isAllowed(unassigned(paths, params))) { context.report(node, reportTooFew(pathCount, paramCount)); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/enforce-define.js000066400000000000000000000040631344425206400234320ustar00rootroot00000000000000/** * @file Rule to disallow files that are not wrapped in a call to `define` * @author Casey Visco */ "use strict"; const path = require("path"); const rjs = require("../utils/rjs"); const ast = require("../utils/ast"); const isDefineCall = rjs.isDefineCall; const isExprStatement = ast.isExprStatement; const basename = path.basename; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow files that are not wrapped in a call to `define`", category: "Stylistic Choices", recommended: false, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/enforce-define.md" }; const schema = [ { anyOf: [ { type: "string" }, { type: "array", uniqueItems: true, items: { type: "string" } } ] } ]; const message = "File must be wrapped in a `define` call"; // ----------------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------------- const includes = (list, item) => list.indexOf(item) !== -1; const isDefineExpr = (child) => isExprStatement(child) && isDefineCall(child.expression); // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { const ignoredFiles = context.options[0] || []; return { Program(node) { const filename = basename(context.getFilename()); if (includes(ignoredFiles, filename)) return; if (!node.body.every(isDefineExpr)) { context.report(node, message); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-amd-define.js000066400000000000000000000022131344425206400231570ustar00rootroot00000000000000/** * @file Rule to disallow use of AMD (dependency array) form of `define` * @author Casey Visco */ "use strict"; const rjs = require("../utils/rjs"); const isAmdDefine = rjs.isAmdDefine; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow use of AMD (dependency array) form of `define`", category: "Stylistic Choices", recommended: false, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-amd-define.md" }; const schema = []; const message = "AMD form of `define` is not allowed."; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { return { CallExpression(node) { if (isAmdDefine(node)) { context.report(node, message); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-assign-exports.js000066400000000000000000000031171344425206400241600ustar00rootroot00000000000000/** * @file Rule to disallow assignment to `exports` when using Simplified * CommonJS Wrapper * @author Casey Visco */ "use strict"; const ast = require("../utils/ast"); const rjs = require("../utils/rjs"); const ancestor = ast.ancestor; const isCommonJsWrapper = rjs.isCommonJsWrapper; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow assignment to `exports` when using Simplified CommonJS Wrapper", category: "Possible Errors", recommended: true, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-assign-exports.md" }; const schema = []; const message = "Invalid assignment to `exports`."; // ----------------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------------- const assignsToExports = (node) => node.left.type === "Identifier" && node.left.name === "exports"; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { return { AssignmentExpression(node) { if (assignsToExports(node) && ancestor(isCommonJsWrapper, node)) { context.report(node, message); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-assign-require.js000066400000000000000000000034531344425206400241330ustar00rootroot00000000000000/** * @file Rule to disallow assignment to `require` or `window.require` * @author Casey Visco */ "use strict"; const ast = require("../utils/ast"); const isIdentifier = ast.isIdentifier; const isMemberExpr = ast.isMemberExpr; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow assignment to `require` or `window.require`", category: "Stylistic Choices", recommended: false, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-assign-require.md" }; const schema = []; const message = "Invalid assignment to `require`."; // ----------------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------------- const isWindow = (node) => isIdentifier(node) && node.name === "window"; const isRequire = (node) => isIdentifier(node) && node.name === "require"; const isWindowRequire = (node) => isMemberExpr(node) && isWindow(node.object) && isRequire(node.property); // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { return { AssignmentExpression(node) { if (isRequire(node.left) || isWindowRequire(node.left)) { context.report(node, message); } }, VariableDeclarator(node) { if (isRequire(node.id)) { context.report(node, message); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-commonjs-exports.js000066400000000000000000000032741344425206400245250ustar00rootroot00000000000000/** * @file Rule to disallow use of `exports` in a module definition when using * Simplified CommonJS Wrapper * @author Casey Visco */ "use strict"; const ast = require("../utils/ast"); const rjs = require("../utils/rjs"); const ancestor = ast.ancestor; const isMemberExpr = ast.isMemberExpr; const isCommonJsWrapper = rjs.isCommonJsWrapper; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow use of `exports` in a module definition when using Simplified CommonJS Wrapper", category: "Stylistic Choices", recommended: true, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-commonjs-exports.md" }; const schema = []; const messages = "Unexpected use of `exports` in module definition."; // ----------------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------------- const assignsToExportsProperty = (node) => isMemberExpr(node.left) && node.left.object.name === "exports"; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { return { AssignmentExpression(node) { if (assignsToExportsProperty(node) && ancestor(isCommonJsWrapper, node)) { context.report(node, messages); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-commonjs-module-exports.js000066400000000000000000000033761344425206400260130ustar00rootroot00000000000000/** * @file Rule to disallow use of `module.exports` in a module definition when * using Simplified CommonJS Wrapper * @author Casey Visco */ "use strict"; const ast = require("../utils/ast"); const rjs = require("../utils/rjs"); const ancestor = ast.ancestor; const isMemberExpr = ast.isMemberExpr; const isCommonJsWrapper = rjs.isCommonJsWrapper; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow use of `module.exports` in a module definition when using Simplified CommonJS Wrapper", category: "Stylistic Choices", recommended: true, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-commonjs-module-exports.md" }; const schema = []; const message = "Unexpected use of `module.exports` in module definition."; // ----------------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------------- const assignsToModuleExports = (node) => isMemberExpr(node.left) && node.left.object.name === "module" && node.left.property.name === "exports"; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { return { AssignmentExpression(node) { if (assignsToModuleExports(node) && ancestor(isCommonJsWrapper, node)) { context.report(node, message); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-commonjs-return.js000066400000000000000000000032321344425206400243320ustar00rootroot00000000000000/** * @file Rule to disallow use of `return` statement in a module definition * when using Simplified CommonJS Wrapper * @author Casey Visco */ "use strict"; const ast = require("../utils/ast"); const rjs = require("../utils/rjs"); const nearest = ast.nearest; const isCommonJsWrapper = rjs.isCommonJsWrapper; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow use of `return` statement in a module definition when", category: "Stylistic Choices", recommended: true, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-commonjs-return.md" }; const schema = []; const message = "Unexpected `return` in module definition."; // ----------------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------------- const isFunction = (node) => node.type === "FunctionDeclaration" || node.type === "FunctionExpression"; const nearestFunction = (node) => nearest(isFunction, node); // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { return { ReturnStatement(node) { if (isCommonJsWrapper(nearestFunction(node).parent)) { context.report(node, message); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-commonjs-wrapper.js000066400000000000000000000023031344425206400244710ustar00rootroot00000000000000/** * @file Rule to disallow use of Simplified CommonJS Wrapper form of `define` * @author Casey Visco */ "use strict"; const rjs = require("../utils/rjs"); const isCommonJsWrapper = rjs.isCommonJsWrapper; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow use of Simplified CommonJS Wrapper form of `define`", category: "Stylistic Choices", recommended: true, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-commonjs-wrapper.md" }; const schema = []; const message = "Simplified CommonJS Wrapper form of `define` is not allowed"; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { return { CallExpression(node) { if (isCommonJsWrapper(node)) { context.report(node, message); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-conditional-require.js000066400000000000000000000030131344425206400251420ustar00rootroot00000000000000/** * @file Rule to disallow use of conditional `require` calls * @author Casey Visco */ "use strict"; const ast = require("../utils/ast"); const rjs = require("../utils/rjs"); const ancestor = ast.ancestor; const isRequireCall = rjs.isRequireCall; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow use of conditional `require` calls", category: "Stylistic Choices", recommended: true, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-conditional-require.md" }; const schema = []; const message = "Conditional `require` calls are not allowed."; // ----------------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------------- const isConditional = (node) => node.type === "IfStatement" || node.type === "ConditionalExpression"; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { return { CallExpression(node) { if (isRequireCall(node) && ancestor(isConditional, node)) { context.report(node, message); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-dynamic-require.js000066400000000000000000000031661344425206400242740ustar00rootroot00000000000000/** * @file Rule to disallow dynamically generated paths in `require` call * @author Casey Visco */ "use strict"; const rjs = require("../utils/rjs"); const ast = require("../utils/ast"); const isRequireCall = rjs.isRequireCall; const isStringLiteral = ast.isStringLiteral; const isStringLiteralArray = ast.isStringLiteralArray; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow use of dynamically generated paths in a require call", category: "Stylistic Choices", recommended: false, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-dynamic-require.md" }; const schema = []; const message = "Dynamic `require` calls are not allowed."; // ----------------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------------- const hasStaticDependencies = (node) => isStringLiteral(node.arguments[0]) || isStringLiteralArray(node.arguments[0]); // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { return { CallExpression(node) { if (isRequireCall(node) && !hasStaticDependencies(node)) { context.report(node, message); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-function-define.js000066400000000000000000000022341344425206400242460ustar00rootroot00000000000000/** * @file Rule to disallow use of simple function form of `define` * @author Casey Visco */ "use strict"; const rjs = require("../utils/rjs"); const isFunctionDefine = rjs.isFunctionDefine; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow use of simple function form of `define`", category: "Stylistic Choices", recommended: false, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-function-define.md" }; const schema = []; const message = "Simple function form of `define` is not allowed"; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { return { CallExpression(node) { if (isFunctionDefine(node)) { context.report(node, message); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-invalid-define.js000066400000000000000000000022651344425206400240530ustar00rootroot00000000000000/** * @file Rule to disallow invalid or undesired forms of `define` * @author Casey Visco */ "use strict"; const rjs = require("../utils/rjs"); const isDefineCall = rjs.isDefineCall; const isValidDefine = rjs.isValidDefine; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow invalid or undesired forms of `define`", category: "Possible Errors", recommended: true, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-invalid-define.md" }; const schema = []; const message = "Invalid module definition"; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { return { CallExpression(node) { if (isDefineCall(node) && !isValidDefine(node)) { context.report(node, message); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-invalid-require.js000066400000000000000000000023221344425206400242670ustar00rootroot00000000000000/** * @file Rule to disallow invalid or undesired forms of `require` * @author Casey Visco */ "use strict"; const rjs = require("../utils/rjs"); const isRequireCall = rjs.isRequireCall; const isValidRequire = rjs.isValidRequire; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow invalid or undesired forms of `require`", category: "Possible Errors", recommended: true, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-invalid-require.md" }; const schema = []; const message = "Invalid arguments provided to `require` call."; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { return { CallExpression(node) { if (isRequireCall(node) && !isValidRequire(node)) { context.report(node, message); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-js-extension.js000066400000000000000000000041121344425206400236140ustar00rootroot00000000000000/** * @file Rule to disallow `.js` extension in dependency paths * @author Casey Visco */ "use strict"; const rjs = require("../utils/rjs"); const isAmdCall = rjs.isAmdCall; const getDependencyStringNodes = rjs.getDependencyStringNodes; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow `.js` extension in dependency paths", category: "Possible Errors", recommended: true, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-js-extension.md" }; const schema = [ { type: "array", uniqueItems: true, items: { type: "string" } } ]; const message = "Don't use .js extension in dependency path."; // ----------------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------------- const append = (str) => (val) => val + str; const report = (context) => (node) => context.report(node, message); const hasJsExtension = (node) => node.value.trim().endsWith(".js"); const startsWithOneOf = (list, str) => list.some((val) => str.startsWith(val)); const hasNoPlugin = (str) => !str.includes("!"); const shouldBeChecked = (plugins) => (node) => startsWithOneOf(plugins, node.value) || hasNoPlugin(node.value); // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { const plugins = (context.options[0] || []).map(append("!")); return { CallExpression(node) { if (!isAmdCall(node)) return; getDependencyStringNodes(node) .filter(shouldBeChecked(plugins)) .filter(hasJsExtension) .forEach(report(context)); } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-multiple-define.js000066400000000000000000000023271344425206400242570ustar00rootroot00000000000000/** * @file Rule to disallow multiple `define` calls in a single file * @author Casey Visco */ "use strict"; const rjs = require("../utils/rjs"); const isDefineCall = rjs.isDefineCall; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow multiple `define` calls in a single file", category: "Stylistic Choices", recommended: false, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-multiple-define.md" }; const schema = []; const message = "Multiple `define` calls in a single file are not permitted"; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { let defineCalls = 0; return { CallExpression: function (node) { if (isDefineCall(node) && ++defineCalls > 1) { context.report(node, message); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-named-define.js000066400000000000000000000022071344425206400235050ustar00rootroot00000000000000/** * @file Rule to disallow use of named module form of `define` * @author Casey Visco */ "use strict"; const rjs = require("../utils/rjs"); const isNamedDefine = rjs.isNamedDefine; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow use of named module form of `define`", category: "Stylistic Choices", recommended: false, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-named-define.md" }; const schema = []; const message = "Named module form of `define` is not allowed"; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { return { CallExpression(node) { if (isNamedDefine(node)) { context.report(node, message); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-object-define.js000066400000000000000000000022541344425206400236710ustar00rootroot00000000000000/** * @file Rule to disallow use of Simple Name/Value Pairs form of `define` * @author Casey Visco */ "use strict"; const rjs = require("../utils/rjs"); const isObjectDefine = rjs.isObjectDefine; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow use of Simple Name/Value Pairs form of `define`", category: "Stylistic Choices", recommended: false, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-object-define.md" }; const schema = []; const message = "Simple Name/Value Pairs form of `define` is not allowed"; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { return { CallExpression(node) { if (isObjectDefine(node)) { context.report(node, message); } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-require-tourl.js000066400000000000000000000034541344425206400240150ustar00rootroot00000000000000/** * @file Rule to disallow use of `require.toUrl` and `require.nameToUrl` * @author Casey Visco */ "use strict"; const rjs = require("../utils/rjs"); const ast = require("../utils/ast"); const isMemberExpr = ast.isMemberExpr; const isIdentifier = ast.isIdentifier; const isRequireIdentifier = rjs.isRequireIdentifier; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow use of `require.toUrl` and `require.nameToUrl`", category: "Stylistic Choices", recommended: false, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-require-tourl.md" }; const schema = []; // ----------------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------------- const isRequireMemberCall = (node, method) => isMemberExpr(node) && isIdentifier(node.object) && isRequireIdentifier(node.object) && isIdentifier(node.property) && node.property.name === method; const message = (prop) => `Use of \`require.${prop}\` is not allowed.`; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { function check(node, method) { if (isRequireMemberCall(node.callee, method)) { context.report(node, message(method)); } } return { CallExpression(node) { check(node, "toUrl"); check(node, "nameToUrl"); } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/no-restricted-amd-modules.js000066400000000000000000000122441344425206400255500ustar00rootroot00000000000000/** * @file Rule to disallow specified modules when loaded by `define` * @author Stefan Buck */ "use strict"; const ignore = require("ignore"); const rjs = require("../utils/rjs"); const isAmdDefine = rjs.isAmdDefine; const isAmdRequire = rjs.isAmdRequire; const getDependencyStringNodes = rjs.getDependencyStringNodes; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Disallow specified modules when loaded by `define`", category: "Stylistic Choices", recommended: false, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/no-restricted-amd-modules.md" }; const arrayOfStrings = { type: "array", items: { type: "string" }, uniqueItems: true }; const arrayOfStringsOrObjects = { type: "array", items: { anyOf: [ { type: "string" }, { type: "object", properties: { name: { type: "string" }, message: { type: "string", minLength: 1 } }, additionalProperties: false, required: ["name"] } ] }, uniqueItems: true }; const schema = { anyOf: [ arrayOfStringsOrObjects, { type: "array", items: { type: "object", properties: { paths: arrayOfStringsOrObjects, patterns: arrayOfStrings }, additionalProperties: false }, additionalItems: false } ] }; const DEFAULT_MESSAGE_TEMPLATE = "'{{moduleName}}' module is restricted from being used."; const CUSTOM_MESSAGE_TEMPLATE = "'{{moduleName}}' module is restricted from being used. {{customMessage}}"; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { const options = Array.isArray(context.options) ? context.options : []; const isPathAndPatternsObject = typeof options[0] === "object" && (Object.prototype.hasOwnProperty.call(options[0], "paths") || Object.prototype.hasOwnProperty.call(options[0], "patterns")); const restrictedPaths = (isPathAndPatternsObject ? options[0].paths : options) || []; const restrictedPatterns = (isPathAndPatternsObject ? options[0].patterns : []) || []; const restrictedPathMessages = restrictedPaths.reduce( (memo, importName) => { if (typeof importName === "string") { memo[importName] = null; } else { memo[importName.name] = importName.message; } return memo; }, {} ); // if no modules are restricted we don"t need to check if ( Object.keys(restrictedPaths).length === 0 && restrictedPatterns.length === 0 ) { return {}; } const ig = ignore().add(restrictedPatterns); /** * Report a restricted path. * @param {node} node representing the restricted path reference * @returns {void} * @private */ function reportPath(node) { const moduleName = node.value.trim(); const customMessage = restrictedPathMessages[moduleName]; const message = customMessage ? CUSTOM_MESSAGE_TEMPLATE : DEFAULT_MESSAGE_TEMPLATE; context.report({ node, message, data: { moduleName, customMessage } }); } /** * Check if the given name is a restricted path name * @param {string} name name of a variable * @returns {boolean} whether the variable is a restricted path or not * @private */ function isRestrictedPath(name) { return Object.prototype.hasOwnProperty.call( restrictedPathMessages, name ); } return { CallExpression(node) { if (!isAmdDefine(node) && !isAmdRequire(node)) return; const paths = getDependencyStringNodes(node); for (let i = 0; i < paths.length; i++) { const nodeCurrent = paths[i]; const moduleName = nodeCurrent.value.trim(); // check if argument value is in restricted modules array if (isRestrictedPath(moduleName)) { reportPath(nodeCurrent); } if (restrictedPatterns.length > 0 && ig.ignores(moduleName)) { context.report({ node, message: "'{{moduleName}}' module is restricted from being used by a pattern.", data: { moduleName } }); break; } } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/one-dependency-per-line.js000066400000000000000000000110351344425206400251640ustar00rootroot00000000000000/** * @file Rule to enforce or disallow one dependency per line. * @author Casey Visco */ "use strict"; const rjs = require("../utils/rjs"); const ast = require("../utils/ast"); const isAmdCall = rjs.isAmdCall; const withoutModuleId = rjs.withoutModuleId; const isArrayExpr = ast.isArrayExpr; const isFunctionExpr = ast.isFunctionExpr; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Require or disallow one dependency per line", category: "Stylistic Choices", recommended: false, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/one-dependency-per-line.md" }; const schema = [ { type: "object", properties: { paths: { oneOf: [ { enum: ["always", "never"] }, { type: "number", minimum: 0 } ] }, names: { oneOf: [ { enum: ["always", "never"] }, { type: "number", minimum: 0 } ] } }, additionalProperties: false } ]; const defaults = { paths: "always", names: "always" }; const messages = { always: { paths: "Only one dependency path is permitted per line.", names: "Only one dependency name is permitted per line." }, never: { paths: "Dependency paths must appear on one line.", names: "Dependency names must appear on one line." } }; // ----------------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------------- const pad = (amount) => (val) => " ".repeat(amount) + val; const line = (node) => node.loc.start.line; const column = (node) => node.loc.start.column; const unique = (list) => Array.from(new Set(list)); const hasDuplicates = (list) => unique(list).length < list.length; const hasMultiple = (list) => unique(list).length > 1; const isLongerThan = (val, list) => Number.isInteger(val) && list.length > val; const isAlways = (val) => val === "always"; const isNever = (val) => val === "never"; const indentation = (node) => { const statement = node.type === "ArrowFunctionExpression" ? node.body : node.body.body[0]; return statement && line(node) !== line(statement) ? column(statement) : 0; }; const formatPaths = (indent) => (node) => { const paths = node.elements.map(v => v.raw).map(pad(indent)).join(",\n"); return `[\n${paths}\n]`; }; const formatNames = (indent, context) => (node) => { const names = node.params.map(v => v.name).map(pad(indent)).join(",\n"); const body = context.getSourceCode().getText(node.body); return `function (\n${names}\n) ${body}`; }; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- function create(context) { const settings = Object.assign({}, defaults, context.options[0]); function check(setting, node, list, format) { const val = settings[setting]; const lines = list.map(line); if ((isLongerThan(val, lines) || isAlways(val)) && hasDuplicates(lines)) { const message = messages.always[setting]; const fix = (f) => f.replaceTextRange(node.range, format(node)); context.report({ node, message, fix }); } if (isNever(val) && hasMultiple(lines)) { const message = messages.never[setting]; context.report({ node, message }); } } return { CallExpression(node) { if (!isAmdCall(node) || node.arguments.length < 2) return; const args = withoutModuleId(node.arguments); const deps = args[0]; const func = args[1]; if (!isArrayExpr(deps) || !isFunctionExpr(func)) return; const indent = indentation(func); check("paths", deps, deps.elements, formatPaths(indent)); check("names", func, func.params, formatNames(indent, context)); } }; } module.exports = { meta: { docs, schema, fixable: "code" }, create }; eslint-plugin-requirejs-4.0.0/lib/rules/sort-amd-paths.js000066400000000000000000000140521344425206400234230ustar00rootroot00000000000000/** * @file Rule to ensure that required paths are ordered alphabetically * @author Ondřej Brejla * @author Casey Visco */ "use strict"; const rjs = require("../utils/rjs"); const isAmdDefine = rjs.isAmdDefine; const isAmdRequire = rjs.isAmdRequire; const getModuleFunction = rjs.getModuleFunction; const getDependencyStringNodes = rjs.getDependencyStringNodes; // ----------------------------------------------------------------------------- // Configuration // ----------------------------------------------------------------------------- const docs = { description: "Ensure that required paths are ordered alphabetically", category: "Stylistic Choices", recommended: false, url: "https://github.com/cvisco/eslint-plugin-requirejs/blob/master/docs/rules/sort-amd-paths.md" }; const schema = [ { type: "object", properties: { compare: { enum: ["dirname-basename", "fullpath", "basename"] }, sortPlugins: { enum: ["preserve", "first", "last", "ignore"] }, ignoreCase: { type: "boolean" } }, additionalProperties: false } ]; const defaults = { "compare": "dirname-basename", "sortPlugins": "preserve", "ignoreCase": true }; // ----------------------------------------------------------------------------- // Helpers // ----------------------------------------------------------------------------- const PLUGIN_REGEX = /^\w+\!/; const PATH_SEPARATOR = "/"; /** * Create a function that returns the additive inverse of the provided function. * @param {Function} fn - function to invert * @returns {Function} inverted function */ const inverse = (fn) => function () { return fn.apply(null, arguments) * -1; }; /** * Create a comparator that iteratively applies each provided function. Each * function should itself be a valid comparator (returning a negative number, * positive number or zero). This allows for sorting based on multiple criteria. * @param {Function[]} fns - array of comparator functions to apply * @returns {Function} multi-criteria comparator */ const comparator = (fns) => (a, b) => fns.reduce((n, f) => n ? n : f(a, b), 0); /** * Compare two string values. Comparison is done based on character value, so * uppercase letters are placed before lowercase ones. * @param {String} a - first value to compare * @param {String} b - second value to compare * @returns {Number} negative if `a` occurs before `b`; positive if `a` occurs * after `b`; 0 if they are equivalent in sort order */ const stringCompare = (a, b) => { if (a < b) return -1; if (a > b) return 1; return 0; }; /** * Compare two values based on existence, with values that exist sorted * before those that don't. * @param {*} a - first value to compare * @param {*} b - second value to compare * @returns {Number} negative if `a` occurs before `b`; positive if `a` occurs * after `b`; 0 if they are equivalent in sort order */ const existentialCompare = (a, b) => { if (a && !b) return -1; if (!a && b) return 1; return 0; }; /** * Compare two array values. * @param {Array} a - first array to compare * @param {Array} b - second array to compare * @returns {Number} negative if `a` occurs before `b`; positive if `a` occurs * after `b`; 0 if they are equivalent in sort order */ const arrayCompare = (a, b) => { const length = Math.max(a.length, b.length); for (let i = 0; i < length; i += 1) { if (!(i in a)) return -1; if (!(i in b)) return 1; if (a[i] < b[i]) return -1; if (a[i] > b[i]) return 1; } return 0; }; const toPathDescriptor = (opts) => (node) => { let value = opts.ignoreCase ? node.value.toLowerCase() : node.value; if (opts.sortPlugins === "ignore") { value = value.replace(PLUGIN_REGEX, ""); } const plugin = PLUGIN_REGEX.test(value); const path = value.split(PATH_SEPARATOR); const basename = path.slice(-1)[0]; const dirnames = path.slice(0, -1); return { node, value, plugin, basename, dirnames }; }; // Specific Comparators const comparePlugins = (a, b) => existentialCompare(a.plugin, b.plugin); const compareDirnames = (a, b) => arrayCompare(a.dirnames, b.dirnames); const compareBasenames = (a, b) => stringCompare(a.basename, b.basename); const compareFullPath = (a, b) => stringCompare(a.value, b.value); const message = (expected) => `Required paths are not in alphabetical order (expected '${expected}').`; // ----------------------------------------------------------------------------- // Rule Definition // ----------------------------------------------------------------------------- const comparators = { plugin: { "first": [comparePlugins], "last": [inverse(comparePlugins)], "ignore": [], "preserve": [] }, path: { "dirname-basename": [compareDirnames, compareBasenames], "basename": [compareBasenames], "fullpath": [compareFullPath] } }; function create(context) { const opts = Object.assign({}, defaults, context.options[0]); return { CallExpression(node) { if (!isAmdDefine(node) && !isAmdRequire(node)) return; const arity = getModuleFunction(node).params.length; const paths = getDependencyStringNodes(node).slice(0, arity); const criteria = [] .concat(comparators.plugin[opts.sortPlugins]) .concat(comparators.path[opts.compare]); const sorted = paths.slice() .map(toPathDescriptor(opts)) .sort(comparator(criteria)); for (let i = 0; i < paths.length; i++) { if (paths[i] !== sorted[i].node) { context.report(paths[i], message(sorted[i].node.value)); break; } } } }; } module.exports = { meta: { docs, schema }, create }; eslint-plugin-requirejs-4.0.0/lib/utils/000077500000000000000000000000001344425206400202265ustar00rootroot00000000000000eslint-plugin-requirejs-4.0.0/lib/utils/ast.js000066400000000000000000000112321344425206400213520ustar00rootroot00000000000000/** * @file Helper functions for working with AST Nodes * @author Casey Visco */ "use strict"; const isArray = Array.isArray; /** * Test if supplied `value` is an object. * @private * @param {*} value - value to test * @returns {Boolean} true if value is an object */ function isObject(value) { const type = typeof value; return type === "object" || type === "function"; } /** * Test if supplied `node` represents an identifier. * @param {ASTNode} node - node to test * @returns {Boolean} true if node represents an identifier */ function isIdentifier(node) { return isObject(node) && node.type === "Identifier"; } /** * Test if supplied `node` represents a literal of any kind. * @param {ASTNode} node - node to test * @returns {Boolean} true if node represents a literal */ function isLiteral(node) { return isObject(node) && node.type === "Literal"; } /** * Test if supplied `node` represents a string literal. * @param {ASTNode} node - node to test * @returns {Boolean} true if node represents a string literal */ function isStringLiteral(node) { return isLiteral(node) && typeof node.value === "string"; } /** * Test if supplied `node` represents an array expression. * @param {ASTNode} node - node to test * @returns {Boolean} true if node represents an array expression */ function isArrayExpr(node) { return isObject(node) && node.type === "ArrayExpression"; } /** * Test if supplied `node` represents an object expression. * @param {ASTNode} node - node to test * @returns {Boolean} true if node represents an object expression */ function isObjectExpr(node) { return isObject(node) && node.type === "ObjectExpression"; } /** * Test if supplied `node` represents a function expression. * @param {ASTNode} node - node to test * @returns {Boolean} true if node represents a function expression */ function isFunctionExpr(node) { return isObject(node) && (node.type === "FunctionExpression" || node.type === "ArrowFunctionExpression"); } /** * Test if supplied `node` represents a member expression. * @param {ASTNode} node - node to test * @returns {Boolean} true if node represents a member expression */ function isMemberExpr(node) { return isObject(node) && node.type === "MemberExpression"; } /** * Test if supplied `node` represents an expression of any kind. * @param {ASTNode} node - node to test * @returns {Boolean} true if node represents an expression statement */ function isExprStatement(node) { return isObject(node) && node.type === "ExpressionStatement"; } /** * Test if supplied `node` represents an array of string literals. Empty * arrays are also valid here. * @param {ASTNode} node - ArrayExpression node to test * @returns {Boolean} true if node represents an array of string literals */ function isStringLiteralArray(node) { return isArrayExpr(node) && isArray(node.elements) && node.elements.every(isStringLiteral); } /** * Test if supplied `node` has parameters. * @param {ASTNode} node - FunctionExpression node to test * @returns {Boolean} true if node has at least one parameter */ function hasParams(node) { return isObject(node) && isArray(node.params) && node.params.length > 0; } /** * Test if supplied `node` has at least one callback argument * @param {ASTNode} node - CallExpression node to test * @returns {Boolean} true if node has at least one callback */ function hasCallback(node) { return isObject(node) && isArray(node.arguments) && node.arguments.some(isFunctionExpr); } /** * Determine if `node` has an ancestor satisfying `predicate`. * @param {Function} predicate - predicate to test each ancestor against * @param {ASTNode} node - child node to begin search at * @returns {Boolean} true if an ancestor satisfies `predicate` */ function ancestor(predicate, node) { while ((node = node.parent)) { if (predicate(node)) return true; } return false; } /** * Find the nearest ancestor satisfying `predicate`. * @param {Function} predicate - predicate to test each ancestor against * @param {ASTNode} node - child node to begin search at * @returns {ASTNode|undefined} nearest ancestor satisfying `predicate`, if any */ function nearest(predicate, node) { while ((node = node.parent)) { if (predicate(node)) return node; } return undefined; } module.exports = { isIdentifier, isLiteral, isStringLiteral, isArrayExpr, isObjectExpr, isMemberExpr, isFunctionExpr, isExprStatement, isStringLiteralArray, hasParams, hasCallback, ancestor, nearest }; eslint-plugin-requirejs-4.0.0/lib/utils/rjs.js000066400000000000000000000220631344425206400213650ustar00rootroot00000000000000/** * @file Helper functions for working with RequireJS-related nodes * @author Casey Visco */ "use strict"; const ast = require("./ast"); const hasParams = ast.hasParams; const isLiteral = ast.isLiteral; const isStringLiteral = ast.isStringLiteral; const isArrayExpr = ast.isArrayExpr; const isObjectExpr = ast.isObjectExpr; const isFunctionExpr = ast.isFunctionExpr; const CJS_PARAMS = ["require", "exports", "module"]; /** * Determine if supplied `node` has a parameter list that satisfies the * requirements for a Simplified CommonJS Wrapper. * @private * @param {Array} params list of function parameters to test * @returns {Boolean} true if `params` satisfies a CommonJS Wrapper format */ const hasCommonJsParams = (params) => params.length && params.every((param, i) => param.name === CJS_PARAMS[i]); /** * Determine if supplied `node` represents a function expression compatible with * the Simplfied CommonJS Wrapper. * @private * @param {ASTNode} node - node to test * @returns {Boolean} true if represents a CommonJS function expression */ const isCommonJsFuncExpr = (node) => isFunctionExpr(node) && hasCommonJsParams(node.params); /** * Determine if supplied `node` represents a "simple" function expression. That * is, one without any parameter list. * @private * @param {ASTNode} node - node to test * @returns {Boolean} true if represents a simple function expression */ const isSimpleFuncExpr = (node) => isFunctionExpr(node) && !hasParams(node); /** * Determine if supplied `node` represents a call to `define`. * @param {ASTNode} node - CallExpression node to test * @returns {Boolean} true if represents a call to `define` */ const isDefineCall = (node) => node && node.type === "CallExpression" && node.callee.type === "Identifier" && node.callee.name === "define"; /** * Determine if supplied `node` represents a module definition function with * a dependency array. This is the classic AMD style module definition. * @see http://requirejs.org/docs/api.html#defdep * @param {ASTNode} node - node to test * @returns {Boolean} true if represents an AMD style module definition */ const isAmdDefine = (node) => isDefineCall(node) && isAmdArgs(withoutModuleId(node.arguments)); /** * Determine if supplied `node` represents a require function with * a dependency array. * @param {ASTNode} node - CallExpression node to test * @returns {Boolean} true if represents an AMD style require function */ const isAmdRequire = (node) => isRequireCall(node) && isAmdArgs(node.arguments); const isAmdArgs = (args) => args.length === 2 && isArrayExpr(args[0]) && isFunctionExpr(args[1]); const withoutModuleId = (args) => isStringLiteral(args[0]) ? args.slice(1) : args; /** * Determine if supplied `node` represents a plain object module. This is * referred to as the "Simple Name/Value Pairs" form of module in the * RequireJS documentation. * @see http://requirejs.org/docs/api.html#defsimple * @param {ASTNode} node - CallExpression node to test * @returns {Boolean} true if represents an Object Module Definition */ const isObjectDefine = (node) => isDefineCall(node) && isObjectArgs(withoutModuleId(node.arguments)); const isObjectArgs = (args) => args.length === 1 && isObjectExpr(args[0]); /** * Determine if supplied `node` represents a module definition function with * no dependency array. * @see http://requirejs.org/docs/api.html#deffunc * @param {ASTNode} node - CallExpression node to test * @returns {Boolean} true if represents a Simple Function Definition */ const isFunctionDefine = (node) => isDefineCall(node) && isFunctionArgs(withoutModuleId(node.arguments)); const isFunctionArgs = (args) => args.length === 1 && isSimpleFuncExpr(args[0]); /** * Determine if supplied `node` represents a module definition using the * "Simplified CommonJS Wrapper" form. * @see http://requirejs.org/docs/api.html#cjsmodule * @param {ASTNode} node - CallExpression node to test * @returns {Boolean} true if represents a Simplified CommonJS Wrapper */ const isCommonJsWrapper = (node) => isDefineCall(node) && isCommonJsArgs(withoutModuleId(node.arguments)); const isCommonJsArgs = (args) => args.length === 1 && isCommonJsFuncExpr(args[0]); /** * Determine if supplied `node` represents a named (or aliased) module * definition function. * @see http://requirejs.org/docs/api.html#modulename * @param {ASTNode} node - CallExpression node to test * @returns {Boolean} true if represents a named module definition function */ const isNamedDefine = (node) => isDefineCall(node) && isNamedArgs(node.arguments); const isNamedArgs = (args) => (args.length === 2 || args.length === 3) && isStringLiteral(args[0]); /** * Determine if supplied `node` represents a valid `define` format. * @param {ASTNode} node - CallExpression node to test * @returns {Boolean} true if represents a valid module definition function */ const isValidDefine = (node) => { const args = withoutModuleId(node.arguments); if (args.length === 1) return isObjectExpr(args[0]) || isFunctionExpr(args[0]); if (args.length === 2) return isArrayExpr(args[0]) && isFunctionExpr(args[1]); return false; }; /** * Determine if supplied `node` represents a `require` or `requirejs` * identifier. Both are synonymous commands. * @param {ASTNode} node - Identifier node to test * @returns {Boolean} true if represents a require identifier. */ const isRequireIdentifier = (node) => node.name === "require" || node.name === "requirejs"; /** * Determine if supplied `node` represents a call to `require`. * @param {ASTNode} node - CallExpression node to test * @returns {Boolean} true if represents a call to `require` */ const isRequireCall = (node) => node.type === "CallExpression" && node.callee.type === "Identifier" && isRequireIdentifier(node.callee); /** * Determine if supplied `node` represents a valid `require` format. * @param {ASTNode} node - CallExpression node to test * @returns {Boolean} true if represents a valid `require` call */ const isValidRequire = (node) => { const args = node.arguments; // If the wrong number of arguments is present, we know it's invalid, // so just return immediately if (args.length < 1 || args.length > 3) return false; // Single argument form should be a string literal, an array expression, // or something that evalutes to one of those. Realistically, we can only // test for a few obviously incorrect cases if (args.length === 1) { return !isObjectExpr(args[0]) && !isFunctionExpr(args[0]); } // For 2 or 3-argument forms, the tail arguments should be function // expressions, or something that could evaluate to a function expression. // Realistically, we can only test for a few obviously incorrect cases. if (args.length > 1 && isInvalidRequireArg(args[1])) return false; if (args.length > 2 && isInvalidRequireArg(args[2])) return false; // For 2 or 3-argument forms, the first argument should be an array // expression or something that evaluates to one. Again, realistically, we // can only test for a few obviously incorrect cases return !isLiteral(args[0]) && !isObjectExpr(args[0]) && !isFunctionExpr(args[0]); }; const isInvalidRequireArg = (arg) => isObjectExpr(arg) || isArrayExpr(arg) || isLiteral(arg); /** * Retrieve the dependency list from the provided `node`, without any filtering * by dependency node type. * @param {ASTNode} node - CallExpression to inspect * @returns {Array} list of dependency path nodes */ const getDependencyNodes = (node) => { const args = node.arguments; if (isDefineCall(node) && args.length > 1) { if (isArrayExpr(args[0])) return args[0].elements; if (isArrayExpr(args[1])) return args[1].elements; } else if (isRequireCall(node)) { if (isArrayExpr(args[0])) return args[0].elements; if (isStringLiteral(args[0])) return [ args[0] ]; } return []; }; /** * Retrieve the dependency list from the provided `node`, filtering by node * type to return only string literal dependencies. * @param {ASTNode} node - CallExpression to inspect * @returns {Array} list of dependency path literals */ const getDependencyStringNodes = (node) => getDependencyNodes(node).filter(isStringLiteral); /** * Retrieve the module definition function from the provided `node`. It will * always be the first FunctionExpression in the arguments list. * @param {ASTNode} node - node to check * @returns {ASTNode} module definition function */ const getModuleFunction = (node) => node.arguments.find(isFunctionExpr); const isAmdCall = (node) => isDefineCall(node) || isRequireCall(node); module.exports = { isRequireCall, isDefineCall, isAmdDefine, isAmdRequire, isObjectDefine, isFunctionDefine, isCommonJsWrapper, isNamedDefine, isValidDefine, isRequireIdentifier, isValidRequire, getDependencyNodes, getDependencyStringNodes, getModuleFunction, withoutModuleId, isAmdCall }; eslint-plugin-requirejs-4.0.0/makefile.js000066400000000000000000000150041344425206400204330ustar00rootroot00000000000000/** * @fileoverview Build file. Based in large part on functionality found in * eslint's own makefile, with necessary tweaks for building an * eslint plugin instead. * * @author Casey Visco */ "use strict"; /* eslint-env shelljs */ require("shelljs/make"); const path = require("path"); const semver = require("semver"); const dateformat = require("dateformat"); const nodeCLI = require("shelljs-nodecli"); // Tools const MOCHA = path.normalize("./node_modules/mocha/bin/_mocha"); // Files const MAKEFILE = "./makefile.js"; const JS_FILES = find("lib/").filter(fileType("js")).join(" "); const TEST_FILES = find("tests/lib/").filter(fileType("js")).join(" "); /** * Generate a function that matches files with a particular extension. * * @private * @param {String} extension - the file extension (i.e. "js") * @returns {Function} function to pass into a filter method */ function fileType(extension) { return function (filename) { return filename.substring(filename.lastIndexOf(".") + 1) === extension; }; } /** * Execute a command and return the output instead of printing it to stdout. * * @private * @param {String} cmd - command to execute * @returns {String} result of executed command */ function execSilent(cmd) { return exec(cmd, { silent: true }).output; } /** * Push supplied `tag` to supplied `list` only if it is a valid semver. This is * a reducer function. * * @private * @param {Array} list - array of valid semver tags * @param {String} tag - tag to push if valid * @returns {Array} modified `list` */ function validSemverTag(list, tag) { if (semver.valid(tag)) { list.push(tag); } return list; } /** * Retrieve a list of semver tags in descending order. * * @private * @returns {Array} list of version tags */ function getVersionTags() { return execSilent("git tag") .trim() .split("\n") .reduce(validSemverTag, []) .sort(semver.compare); } /** * Create a release version, push tags and publish. * * @private * @param {String} type - type of release to do (patch, minor, major) * @returns {void} */ function release(type) { target.test(); echo("Generating new version"); const newVersion = execSilent("npm version " + type).trim(); target.changelog(); // add changelog to commit exec("git add CHANGELOG.md"); exec("git commit --amend --no-edit"); // replace existing tag exec("git tag -f " + newVersion); // push all the things echo("Publishing to git"); exec("git push origin master --tags"); echo("Publishing to npm"); exec("npm publish"); } target.lint = function () { let errors = 0; echo("Linting makefile"); errors += nodeCLI.exec("eslint", MAKEFILE).code; echo("Linting JavaScript files"); errors += nodeCLI.exec("eslint", JS_FILES).code; echo("Linting JavaScript test files"); errors += nodeCLI.exec("eslint", TEST_FILES).code; if (errors) { exit(1); } }; /** * Verify that each rule is defined in index.js with the correct default * setting, has documentation and has tests. * @returns {void} */ target.checkRules = function () { echo("Verifying rules"); const ruleFiles = find("lib/rules/").filter(fileType("js")); const configFile = require("./index"); const readmeText = cat("./README.md"); let errors = 0; function isDefinedInConfig(rule) { return configFile.rules.hasOwnProperty(rule); } function hasIdInTitle(docFile, id) { const docText = cat(docFile); const idInTitleRegExp = new RegExp("^# (.*?) \\(" + id + "\\)"); return idInTitleRegExp.test(docText); } ruleFiles.forEach(function (filename) { const basename = path.basename(filename, ".js"); const docFilename = "docs/rules/" + basename + ".md"; const testFilename = "tests/lib/rules/" + basename + ".js"; // Verify rule has documentation if (!test("-f", docFilename)) { console.error("Missing documentation for rule %s", basename); errors++; } else { if (readmeText.indexOf("(" + docFilename + ")") === -1) { console.error("Missing link to documentation for rule %s in index", basename); errors++; } // check for proper doc format if (!hasIdInTitle(docFilename, basename)) { console.error("Missing id in the doc page's title of rule %s", basename); errors++; } } // Verify rule has tests if (!test("-f", testFilename)) { console.error("Missing tests for rule %s", basename); errors++; } // Verify config if (!isDefinedInConfig(basename)) { console.error("Missing rule entry for %s in index.js", basename); errors++; } }); if (errors) { exit(1); } }; target.unit = function () { let errors = 0; echo("Running test suite"); errors += nodeCLI.exec("istanbul", "cover", MOCHA, "-- -R progress -t 3000 -c", TEST_FILES).code; errors += nodeCLI.exec("istanbul", "check-coverage", "--statement 100 --branch 95 --function 100 --lines 100").code; if (errors) { exit(1); } }; target.test = function () { target.lint(); target.checkRules(); target.unit(); }; target.changelog = function () { echo("Generating changelog"); // get most recent two tags const tags = getVersionTags(); const rangeTags = tags.slice(tags.length - 2); const timestamp = dateformat(new Date(), "mmmm d, yyyy"); const semverRe = /^\* \d+\.\d+.\d+/; // output header ("### " + rangeTags[1] + " - " + timestamp + "\n").to("CHANGELOG.tmp"); // get log statements let logs = execSilent("git log --pretty=format:\"* %s (%an)\" " + rangeTags.join("..")).split(/\n/g); logs = logs.filter(function (line) { return line.indexOf("Merge pull request") === -1 && line.indexOf("Merge branch") === -1 && !semverRe.test(line); }); logs.push(""); // to create empty lines logs.unshift(""); // output log statements logs.join("\n").toEnd("CHANGELOG.tmp"); cat("CHANGELOG.tmp", "CHANGELOG.md").to("CHANGELOG.md.tmp"); rm("CHANGELOG.tmp"); rm("CHANGELOG.md"); mv("CHANGELOG.md.tmp", "CHANGELOG.md"); }; target.patch = function () { release("patch"); }; target.minor = function () { release("minor"); }; target.major = function () { release("major"); }; eslint-plugin-requirejs-4.0.0/package-lock.json000066400000000000000000002304151344425206400215410ustar00rootroot00000000000000{ "name": "eslint-plugin-requirejs", "version": "4.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { "abbrev": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", "integrity": "sha1-kbR5JYinc4wl813W9jdSovh3YTU=", "dev": true }, "acorn": { "version": "5.5.3", "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.3.tgz", "integrity": "sha512-jd5MkIUlbbmb07nXH0DT3y7rDVtkzDi4XZOUVWAer8ajmF/DTSSbl5oNFyDOl/OXA33Bl79+ypHhl2pN20VeOQ==", "dev": true }, "acorn-jsx": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz", "integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=", "dev": true, "requires": { "acorn": "^3.0.4" }, "dependencies": { "acorn": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", "dev": true } } }, "ajv": { "version": "4.11.8", "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", "dev": true, "requires": { "co": "^4.6.0", "json-stable-stringify": "^1.0.1" } }, "ajv-keywords": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-1.5.1.tgz", "integrity": "sha1-MU3QpLM2j609/NxU7eYXG4htrzw=", "dev": true }, "amdefine": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", "dev": true, "optional": true }, "ansi-escapes": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", "dev": true }, "ansi-regex": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.0.0.tgz", "integrity": "sha1-xQYbbg74qBd15Q9dZhUb9r83EQc=", "dev": true }, "ansi-styles": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", "dev": true }, "argparse": { "version": "0.1.16", "resolved": "https://registry.npmjs.org/argparse/-/argparse-0.1.16.tgz", "integrity": "sha1-z9AeD7uj1srtBJ+9dY1A9lGW9Xw=", "dev": true, "requires": { "underscore": "~1.7.0", "underscore.string": "~2.4.0" } }, "array-find-index": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.1.tgz", "integrity": "sha1-C8Jd2slB7IpJauJY/UrBiAA+868=", "dev": true }, "array-union": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", "dev": true, "requires": { "array-uniq": "^1.0.1" } }, "array-uniq": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", "dev": true }, "arrify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, "asn1": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=", "dev": true }, "assert-plus": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", "dev": true }, "async": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", "dev": true }, "aws-sign2": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", "dev": true }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, "bl": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/bl/-/bl-1.0.3.tgz", "integrity": "sha1-/FQhoo/UImA2w7OJGmaiW8ZNIm4=", "dev": true, "requires": { "readable-stream": "~2.0.5" } }, "boom": { "version": "2.10.1", "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", "dev": true, "requires": { "hoek": "2.x.x" } }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "buffer-from": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.0.0.tgz", "integrity": "sha512-83apNb8KK0Se60UE1+4Ukbe3HbfELJ6UlI4ldtOGs7So4KD26orJM8hIY9lxdzP+UpItH1Yh/Y8GUvNFWFFRxA==", "dev": true }, "builtin-modules": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", "dev": true }, "caller-path": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", "dev": true, "requires": { "callsites": "^0.2.0" } }, "callsites": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", "dev": true }, "camelcase": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", "dev": true }, "camelcase-keys": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/camelcase-keys/-/camelcase-keys-2.1.0.tgz", "integrity": "sha1-MIvur/3ygRkFHvodkyITyRuPkuc=", "dev": true, "requires": { "camelcase": "^2.0.0", "map-obj": "^1.0.0" } }, "caseless": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=", "dev": true }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { "ansi-styles": "^2.2.1", "escape-string-regexp": "^1.0.2", "has-ansi": "^2.0.0", "strip-ansi": "^3.0.0", "supports-color": "^2.0.0" } }, "circular-json": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", "dev": true }, "cli-cursor": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", "dev": true, "requires": { "restore-cursor": "^1.0.1" } }, "cli-width": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", "dev": true }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", "dev": true }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, "combined-stream": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", "dev": true, "requires": { "delayed-stream": "~1.0.0" } }, "commander": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", "dev": true, "requires": { "graceful-readlink": ">= 1.0.0" } }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, "concat-stream": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", "dev": true, "requires": { "buffer-from": "^1.0.0", "inherits": "^2.0.3", "readable-stream": "^2.2.2", "typedarray": "^0.0.6" }, "dependencies": { "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, "process-nextick-args": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, "readable-stream": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", "isarray": "~1.0.0", "process-nextick-args": "~2.0.0", "safe-buffer": "~5.1.1", "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" } }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { "safe-buffer": "~5.1.0" } } } }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, "coveralls": { "version": "2.11.9", "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-2.11.9.tgz", "integrity": "sha1-+f8Boa2/IqEp41qNYjRaUqeBs5U=", "dev": true, "requires": { "js-yaml": "3.0.1", "lcov-parse": "0.0.6", "log-driver": "1.2.4", "minimist": "1.2.0", "request": "2.67.0" } }, "cryptiles": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", "dev": true, "requires": { "boom": "2.x.x" } }, "currently-unhandled": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", "integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=", "dev": true, "requires": { "array-find-index": "^1.0.1" } }, "d": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", "dev": true, "requires": { "es5-ext": "^0.10.9" } }, "dashdash": { "version": "1.14.0", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.0.tgz", "integrity": "sha1-KeSGxUGL8PNWA0qZPVFoajPoQUE=", "dev": true, "requires": { "assert-plus": "^1.0.0" }, "dependencies": { "assert-plus": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "dev": true } } }, "dateformat": { "version": "1.0.12", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.12.tgz", "integrity": "sha1-nxJLZ1lMk3/3BpMuSmQsyo27/uk=", "dev": true, "requires": { "get-stdin": "^4.0.1", "meow": "^3.3.0" } }, "debug": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", "dev": true, "requires": { "ms": "0.7.1" } }, "decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, "del": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", "dev": true, "requires": { "globby": "^5.0.0", "is-path-cwd": "^1.0.0", "is-path-in-cwd": "^1.0.0", "object-assign": "^4.0.1", "pify": "^2.0.0", "pinkie-promise": "^2.0.0", "rimraf": "^2.2.8" } }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", "dev": true }, "diff": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", "integrity": "sha1-fyjS657nsVqX79ic5j3P2qPMur8=", "dev": true }, "doctrine": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", "dev": true, "requires": { "esutils": "^2.0.2", "isarray": "^1.0.0" } }, "ecc-jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", "dev": true, "optional": true, "requires": { "jsbn": "~0.1.0" } }, "error-ex": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.0.tgz", "integrity": "sha1-5ntD8+gsluo6WE/+4Ln8MyXYAtk=", "dev": true, "requires": { "is-arrayish": "^0.2.1" } }, "es5-ext": { "version": "0.10.42", "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.42.tgz", "integrity": "sha512-AJxO1rmPe1bDEfSR6TJ/FgMFYuTBhR5R57KW58iCkYACMyFbrkqVyzXSurYoScDGvgyMpk7uRF/lPUPPTmsRSA==", "dev": true, "requires": { "es6-iterator": "~2.0.3", "es6-symbol": "~3.1.1", "next-tick": "1" } }, "es6-iterator": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", "dev": true, "requires": { "d": "1", "es5-ext": "^0.10.35", "es6-symbol": "^3.1.1" } }, "es6-map": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/es6-map/-/es6-map-0.1.5.tgz", "integrity": "sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA=", "dev": true, "requires": { "d": "1", "es5-ext": "~0.10.14", "es6-iterator": "~2.0.1", "es6-set": "~0.1.5", "es6-symbol": "~3.1.1", "event-emitter": "~0.3.5" } }, "es6-set": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", "dev": true, "requires": { "d": "1", "es5-ext": "~0.10.14", "es6-iterator": "~2.0.1", "es6-symbol": "3.1.1", "event-emitter": "~0.3.5" } }, "es6-symbol": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", "dev": true, "requires": { "d": "1", "es5-ext": "~0.10.14" } }, "es6-weak-map": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", "dev": true, "requires": { "d": "1", "es5-ext": "^0.10.14", "es6-iterator": "^2.0.1", "es6-symbol": "^3.1.1" } }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, "escodegen": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.8.1.tgz", "integrity": "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=", "dev": true, "requires": { "esprima": "^2.7.1", "estraverse": "^1.9.1", "esutils": "^2.0.2", "optionator": "^0.8.1", "source-map": "~0.2.0" }, "dependencies": { "esprima": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", "dev": true }, "estraverse": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", "integrity": "sha1-r2fy3JIlgkFZUJJgkaQAXSnJu0Q=", "dev": true } } }, "escope": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/escope/-/escope-3.6.0.tgz", "integrity": "sha1-4Bl16BJ4GhY6ba392AOY3GTIicM=", "dev": true, "requires": { "es6-map": "^0.1.3", "es6-weak-map": "^2.0.1", "esrecurse": "^4.1.0", "estraverse": "^4.1.1" } }, "eslint": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-3.3.0.tgz", "integrity": "sha1-lSRwDPlPkPBEfzQVLmjpnTkDT1c=", "dev": true, "requires": { "chalk": "^1.1.3", "concat-stream": "^1.4.6", "debug": "^2.1.1", "doctrine": "^1.2.2", "escope": "^3.6.0", "espree": "^3.1.6", "estraverse": "^4.2.0", "esutils": "^2.0.2", "file-entry-cache": "^1.3.1", "glob": "^7.0.3", "globals": "^9.2.0", "ignore": "^3.1.2", "imurmurhash": "^0.1.4", "inquirer": "^0.12.0", "is-my-json-valid": "^2.10.0", "is-resolvable": "^1.0.0", "js-yaml": "^3.5.1", "json-stable-stringify": "^1.0.0", "levn": "^0.3.0", "lodash": "^4.0.0", "mkdirp": "^0.5.0", "natural-compare": "^1.4.0", "optionator": "^0.8.1", "path-is-inside": "^1.0.1", "pluralize": "^1.2.1", "progress": "^1.1.8", "require-uncached": "^1.0.2", "shelljs": "^0.6.0", "strip-bom": "^3.0.0", "strip-json-comments": "~1.0.1", "table": "^3.7.8", "text-table": "~0.2.0", "user-home": "^2.0.0" }, "dependencies": { "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "~1.0.2" } }, "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "ignore": { "version": "3.3.10", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", "dev": true }, "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" } }, "shelljs": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.6.1.tgz", "integrity": "sha1-7GIRvtGSBEIIj+D3Cyg3Iy7SyKg=", "dev": true }, "strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", "dev": true } } }, "eslint-config-eslint": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/eslint-config-eslint/-/eslint-config-eslint-3.0.0.tgz", "integrity": "sha1-WK+8rzSV9TAapN6iAgbKESVShxY=", "dev": true, "requires": { "js-yaml": "^3.5.1" }, "dependencies": { "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "~1.0.2" } }, "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, "js-yaml": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", "dev": true, "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" } } } }, "eslint-plugin-node": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-2.0.0.tgz", "integrity": "sha1-1J3EJ87cDfQ2I4zcsGrNlh+jjeU=", "dev": true, "requires": { "ignore": "^3.0.11", "minimatch": "^3.0.2", "object-assign": "^4.0.1", "resolve": "^1.1.7", "semver": "5.2.0" }, "dependencies": { "ignore": { "version": "3.3.10", "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", "dev": true } } }, "espree": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", "dev": true, "requires": { "acorn": "^5.5.0", "acorn-jsx": "^3.0.0" } }, "esprima": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=", "dev": true }, "esrecurse": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", "dev": true, "requires": { "estraverse": "^4.1.0" } }, "estraverse": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", "dev": true }, "esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", "dev": true }, "event-emitter": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", "dev": true, "requires": { "d": "1", "es5-ext": "~0.10.14" } }, "exit-hook": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=", "dev": true }, "extend": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.0.tgz", "integrity": "sha1-WkdDU7nzNT3dgXbf03uRyDpG8dQ=", "dev": true }, "extsprintf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz", "integrity": "sha1-4QgOBljjALBilJkMxw4VAiNf1VA=", "dev": true }, "fast-levenshtein": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-1.1.3.tgz", "integrity": "sha1-KuezKrweYS2kik4ThJuIii9h5+k=", "dev": true }, "figures": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", "dev": true, "requires": { "escape-string-regexp": "^1.0.5", "object-assign": "^4.1.0" } }, "file-entry-cache": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-1.3.1.tgz", "integrity": "sha1-RMYepgeuS+nBQC9B9EJwy/4zT/g=", "dev": true, "requires": { "flat-cache": "^1.2.1", "object-assign": "^4.0.1" } }, "find-up": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", "dev": true, "requires": { "path-exists": "^2.0.0", "pinkie-promise": "^2.0.0" } }, "flat-cache": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz", "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", "dev": true, "requires": { "circular-json": "^0.3.1", "del": "^2.0.2", "graceful-fs": "^4.1.2", "write": "^0.2.1" } }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", "dev": true }, "form-data": { "version": "1.0.0-rc4", "resolved": "https://registry.npmjs.org/form-data/-/form-data-1.0.0-rc4.tgz", "integrity": "sha1-BaxrwiIntD5EYfSIFhVUaZ1Pi14=", "dev": true, "requires": { "async": "^1.5.2", "combined-stream": "^1.0.5", "mime-types": "^2.1.10" } }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, "generate-function": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", "dev": true }, "generate-object-property": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", "dev": true, "requires": { "is-property": "^1.0.0" } }, "get-stdin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", "dev": true }, "getpass": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.6.tgz", "integrity": "sha1-KD/9n8ElaECHUxHBtg6MQBhxEOY=", "dev": true, "requires": { "assert-plus": "^1.0.0" }, "dependencies": { "assert-plus": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "dev": true } } }, "glob": { "version": "7.0.5", "resolved": "https://registry.npmjs.org/glob/-/glob-7.0.5.tgz", "integrity": "sha1-tCAqaQmbu00pKnwblbZoK2fr3JU=", "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.0.2", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } }, "globals": { "version": "9.18.0", "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==", "dev": true }, "globby": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", "dev": true, "requires": { "array-union": "^1.0.1", "arrify": "^1.0.0", "glob": "^7.0.3", "object-assign": "^4.0.1", "pify": "^2.0.0", "pinkie-promise": "^2.0.0" } }, "graceful-fs": { "version": "4.1.4", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.4.tgz", "integrity": "sha1-7widKIDwM7ARgjzlyPrnmNp3Xb0=", "dev": true }, "graceful-readlink": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", "dev": true }, "growl": { "version": "1.9.2", "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=", "dev": true }, "handlebars": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.1.tgz", "integrity": "sha512-3Zhi6C0euYZL5sM0Zcy7lInLXKQ+YLcF/olbN010mzGQ4XVm50JeyBnMqofHh696GrciGruC7kCcApPDJvVgwA==", "dev": true, "requires": { "neo-async": "^2.6.0", "optimist": "^0.6.1", "source-map": "^0.6.1", "uglify-js": "^3.1.4" }, "dependencies": { "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true } } }, "har-validator": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", "integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=", "dev": true, "requires": { "chalk": "^1.1.1", "commander": "^2.9.0", "is-my-json-valid": "^2.12.4", "pinkie-promise": "^2.0.0" } }, "has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { "ansi-regex": "^2.0.0" } }, "has-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", "dev": true }, "hawk": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", "dev": true, "requires": { "boom": "2.x.x", "cryptiles": "2.x.x", "hoek": "2.x.x", "sntp": "1.x.x" } }, "hoek": { "version": "2.16.3", "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", "dev": true }, "hosted-git-info": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.1.5.tgz", "integrity": "sha1-C6gdkNouJas0ozLm7HeTbhWYEYs=", "dev": true }, "http-signature": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", "dev": true, "requires": { "assert-plus": "^0.2.0", "jsprim": "^1.2.2", "sshpk": "^1.7.0" } }, "ignore": { "version": "5.0.5", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.0.5.tgz", "integrity": "sha512-kOC8IUb8HSDMVcYrDVezCxpJkzSQWTAzf3olpKM6o9rM5zpojx23O0Fl8Wr4+qJ6ZbPEHqf1fdwev/DS7v7pmA==" }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "dev": true }, "indent-string": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", "integrity": "sha1-ji1INIdCEhtKghi3oTfppSBJ3IA=", "dev": true, "requires": { "repeating": "^2.0.0" } }, "inflight": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.5.tgz", "integrity": "sha1-2zIEzVqd4ubNiQuFxuL2a89PYgo=", "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" } }, "inherits": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", "dev": true }, "inquirer": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz", "integrity": "sha1-HvK/1jUE3wvHV4X/+MLEHfEvB34=", "dev": true, "requires": { "ansi-escapes": "^1.1.0", "ansi-regex": "^2.0.0", "chalk": "^1.0.0", "cli-cursor": "^1.0.1", "cli-width": "^2.0.0", "figures": "^1.3.5", "lodash": "^4.3.0", "readline2": "^1.0.1", "run-async": "^0.1.0", "rx-lite": "^3.1.2", "string-width": "^1.0.1", "strip-ansi": "^3.0.0", "through": "^2.3.6" } }, "interpret": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.0.1.tgz", "integrity": "sha1-1Xn7f2k7hYAElHrzn6DbSfeVYCw=", "dev": true }, "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true }, "is-builtin-module": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", "dev": true, "requires": { "builtin-modules": "^1.0.0" } }, "is-finite": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.1.tgz", "integrity": "sha1-ZDhgPq6+J5OUj/SkJi7I2z1iWXs=", "dev": true, "requires": { "number-is-nan": "^1.0.0" } }, "is-fullwidth-code-point": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, "requires": { "number-is-nan": "^1.0.0" } }, "is-my-json-valid": { "version": "2.13.1", "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.13.1.tgz", "integrity": "sha1-1Vd4qC/rawlj/0vhEdXRaE6JBwc=", "dev": true, "requires": { "generate-function": "^2.0.0", "generate-object-property": "^1.1.0", "jsonpointer": "2.0.0", "xtend": "^4.0.0" } }, "is-path-cwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", "dev": true }, "is-path-in-cwd": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz", "integrity": "sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ==", "dev": true, "requires": { "is-path-inside": "^1.0.0" } }, "is-path-inside": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", "dev": true, "requires": { "path-is-inside": "^1.0.1" } }, "is-property": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", "dev": true }, "is-resolvable": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", "dev": true }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "dev": true }, "is-utf8": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", "dev": true }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", "dev": true }, "istanbul": { "version": "0.4.5", "resolved": "https://registry.npmjs.org/istanbul/-/istanbul-0.4.5.tgz", "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", "dev": true, "requires": { "abbrev": "1.0.x", "async": "1.x", "escodegen": "1.8.x", "esprima": "2.7.x", "glob": "^5.0.15", "handlebars": "^4.0.1", "js-yaml": "3.x", "mkdirp": "0.5.x", "nopt": "3.x", "once": "1.x", "resolve": "1.1.x", "supports-color": "^3.1.0", "which": "^1.1.1", "wordwrap": "^1.0.0" }, "dependencies": { "esprima": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", "dev": true }, "glob": { "version": "5.0.15", "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", "dev": true, "requires": { "inflight": "^1.0.4", "inherits": "2", "minimatch": "2 || 3", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } }, "supports-color": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", "dev": true, "requires": { "has-flag": "^1.0.0" } } } }, "jade": { "version": "0.26.3", "resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz", "integrity": "sha1-jxDXl32NefL2/4YqgbBRPMslaGw=", "dev": true, "requires": { "commander": "0.6.1", "mkdirp": "0.3.0" }, "dependencies": { "commander": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz", "integrity": "sha1-+mihT2qUXVTbvlDYzbMyDp47GgY=", "dev": true }, "mkdirp": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz", "integrity": "sha1-G79asbqCevI1dRQ0kEJkVfSB/h4=", "dev": true } } }, "jodid25519": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/jodid25519/-/jodid25519-1.0.2.tgz", "integrity": "sha1-BtSRIlUJNBlHfUJWM2BuDpB4KWc=", "dev": true, "optional": true, "requires": { "jsbn": "~0.1.0" } }, "js-yaml": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.0.1.tgz", "integrity": "sha1-dkBf6lvOMPyPQF1Ixtyn8KMsav4=", "dev": true, "requires": { "argparse": "~ 0.1.11", "esprima": "~ 1.0.2" } }, "jsbn": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.0.tgz", "integrity": "sha1-ZQmH2g3XT06/WhE3eiqi0nPpff0=", "dev": true, "optional": true }, "json-schema": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.2.tgz", "integrity": "sha1-UDVPGfYDkXxpX3C4Wvp3w7DyNQY=", "dev": true }, "json-stable-stringify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", "dev": true, "requires": { "jsonify": "~0.0.0" } }, "json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "dev": true }, "jsonify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", "dev": true }, "jsonpointer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-2.0.0.tgz", "integrity": "sha1-OvHdIP6FRjkQ1GmjheMwF9KgMNk=", "dev": true }, "jsprim": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.3.0.tgz", "integrity": "sha1-zi4b74NSBLTzCZkoxgL4tq5hVlA=", "dev": true, "requires": { "extsprintf": "1.0.2", "json-schema": "0.2.2", "verror": "1.3.6" } }, "lcov-parse": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-0.0.6.tgz", "integrity": "sha1-gZ5dqL8HkfnT857qXtGGgYfxEXU=", "dev": true }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", "dev": true, "requires": { "prelude-ls": "~1.1.2", "type-check": "~0.3.2" } }, "load-json-file": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", "dev": true, "requires": { "graceful-fs": "^4.1.2", "parse-json": "^2.2.0", "pify": "^2.0.0", "pinkie-promise": "^2.0.0", "strip-bom": "^2.0.0" } }, "lodash": { "version": "4.17.10", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", "dev": true }, "log-driver": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.4.tgz", "integrity": "sha1-LWLX+u9F2KcTQZYaBLB2HsqZz6M=", "dev": true }, "loud-rejection": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", "integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=", "dev": true, "requires": { "currently-unhandled": "^0.4.1", "signal-exit": "^3.0.0" } }, "lru-cache": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", "dev": true }, "map-obj": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", "dev": true }, "meow": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/meow/-/meow-3.7.0.tgz", "integrity": "sha1-cstmi0JSKCkKu/qFaJJYcwioAfs=", "dev": true, "requires": { "camelcase-keys": "^2.0.0", "decamelize": "^1.1.2", "loud-rejection": "^1.0.0", "map-obj": "^1.0.1", "minimist": "^1.1.3", "normalize-package-data": "^2.3.4", "object-assign": "^4.0.1", "read-pkg-up": "^1.0.1", "redent": "^1.0.0", "trim-newlines": "^1.0.0" } }, "mime-db": { "version": "1.23.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.23.0.tgz", "integrity": "sha1-oxtAcK2uon1zLqMzdApk0OyaZlk=", "dev": true }, "mime-types": { "version": "2.1.11", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.11.tgz", "integrity": "sha1-wlnEcb2oCKhdbNGTtDCl+uRHOzw=", "dev": true, "requires": { "mime-db": "~1.23.0" } }, "minimatch": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.2.tgz", "integrity": "sha1-DzmKcwDqRB6cNIyD2Yq4ydv5xAo=", "dev": true, "requires": { "brace-expansion": "^1.0.0" } }, "minimist": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", "dev": true }, "mkdirp": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { "minimist": "0.0.8" }, "dependencies": { "minimist": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", "dev": true } } }, "mocha": { "version": "2.5.3", "resolved": "https://registry.npmjs.org/mocha/-/mocha-2.5.3.tgz", "integrity": "sha1-FhvlvetJZ3HrmzV0UFC2IrWu/Fg=", "dev": true, "requires": { "commander": "2.3.0", "debug": "2.2.0", "diff": "1.4.0", "escape-string-regexp": "1.0.2", "glob": "3.2.11", "growl": "1.9.2", "jade": "0.26.3", "mkdirp": "0.5.1", "supports-color": "1.2.0", "to-iso-string": "0.0.2" }, "dependencies": { "commander": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz", "integrity": "sha1-/UMOiJgy7DU7ms0d4hfBHLPu+HM=", "dev": true }, "escape-string-regexp": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz", "integrity": "sha1-Tbwv5nTnGUnK8/smlc5/LcHZqNE=", "dev": true }, "glob": { "version": "3.2.11", "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", "dev": true, "requires": { "inherits": "2", "minimatch": "0.3" } }, "minimatch": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", "dev": true, "requires": { "lru-cache": "2", "sigmund": "~1.0.0" } }, "supports-color": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz", "integrity": "sha1-/x7R5hFp0Gs88tWI4YixjYhH4X4=", "dev": true } } }, "ms": { "version": "0.7.1", "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", "dev": true }, "mute-stream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", "dev": true }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, "neo-async": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.0.tgz", "integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==", "dev": true }, "next-tick": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", "dev": true }, "node-uuid": { "version": "1.4.7", "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.7.tgz", "integrity": "sha1-baWhdmjEs91ZYjvaEc9/pMH2Cm8=", "dev": true }, "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", "dev": true, "requires": { "abbrev": "1" } }, "normalize-package-data": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.3.5.tgz", "integrity": "sha1-jZJPFClg4Xd+f/4XBUNjHMfLAt8=", "dev": true, "requires": { "hosted-git-info": "^2.1.4", "is-builtin-module": "^1.0.0", "semver": "2 || 3 || 4 || 5", "validate-npm-package-license": "^3.0.1" } }, "number-is-nan": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.0.tgz", "integrity": "sha1-wCD1KcUoKt/dIz2R1LGBw9aG3Es=", "dev": true }, "oauth-sign": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", "dev": true }, "object-assign": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz", "integrity": "sha1-ejs9DpgGPUP0wD8uiubNUahog6A=", "dev": true }, "once": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz", "integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=", "dev": true, "requires": { "wrappy": "1" } }, "onetime": { "version": "1.1.0", "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", "dev": true }, "optimist": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", "dev": true, "requires": { "minimist": "~0.0.1", "wordwrap": "~0.0.2" }, "dependencies": { "minimist": { "version": "0.0.10", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", "dev": true }, "wordwrap": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", "dev": true } } }, "optionator": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.1.tgz", "integrity": "sha1-4xtJMs3V+4Yqiw0QvGPT7h7H14s=", "dev": true, "requires": { "deep-is": "~0.1.3", "fast-levenshtein": "^1.1.0", "levn": "~0.3.0", "prelude-ls": "~1.1.2", "type-check": "~0.3.2", "wordwrap": "~1.0.0" } }, "os-homedir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", "dev": true }, "parse-json": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", "dev": true, "requires": { "error-ex": "^1.2.0" } }, "path-exists": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", "dev": true, "requires": { "pinkie-promise": "^2.0.0" } }, "path-is-absolute": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz", "integrity": "sha1-Jj2tpmqz8vsQv3+dJN2PPlcO+RI=", "dev": true }, "path-is-inside": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", "dev": true }, "path-type": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", "dev": true, "requires": { "graceful-fs": "^4.1.2", "pify": "^2.0.0", "pinkie-promise": "^2.0.0" } }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, "pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", "dev": true }, "pinkie-promise": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", "dev": true, "requires": { "pinkie": "^2.0.0" } }, "pluralize": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-1.2.1.tgz", "integrity": "sha1-0aIUg/0iu0HlihL6NCGCMUCJfEU=", "dev": true }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", "dev": true }, "process-nextick-args": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", "dev": true }, "progress": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/progress/-/progress-1.1.8.tgz", "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", "dev": true }, "qs": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/qs/-/qs-5.2.0.tgz", "integrity": "sha1-qfMRQq9GjLcrJbMBNrokVoNJFr4=", "dev": true }, "read-pkg": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", "dev": true, "requires": { "load-json-file": "^1.0.0", "normalize-package-data": "^2.3.2", "path-type": "^1.0.0" } }, "read-pkg-up": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", "dev": true, "requires": { "find-up": "^1.0.0", "read-pkg": "^1.0.0" } }, "readable-stream": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", "dev": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.1", "isarray": "~1.0.0", "process-nextick-args": "~1.0.6", "string_decoder": "~0.10.x", "util-deprecate": "~1.0.1" } }, "readline2": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz", "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", "dev": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", "mute-stream": "0.0.5" } }, "rechoir": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", "dev": true, "requires": { "resolve": "^1.1.6" } }, "redent": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/redent/-/redent-1.0.0.tgz", "integrity": "sha1-z5Fqsf1fHxbfsggi3W7H9zDCr94=", "dev": true, "requires": { "indent-string": "^2.1.0", "strip-indent": "^1.0.1" } }, "repeating": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/repeating/-/repeating-2.0.1.tgz", "integrity": "sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo=", "dev": true, "requires": { "is-finite": "^1.0.0" } }, "request": { "version": "2.67.0", "resolved": "https://registry.npmjs.org/request/-/request-2.67.0.tgz", "integrity": "sha1-ivdHgOK/EeoK6aqWXBHxGv0nJ0I=", "dev": true, "requires": { "aws-sign2": "~0.6.0", "bl": "~1.0.0", "caseless": "~0.11.0", "combined-stream": "~1.0.5", "extend": "~3.0.0", "forever-agent": "~0.6.1", "form-data": "~1.0.0-rc3", "har-validator": "~2.0.2", "hawk": "~3.1.0", "http-signature": "~1.1.0", "is-typedarray": "~1.0.0", "isstream": "~0.1.2", "json-stringify-safe": "~5.0.1", "mime-types": "~2.1.7", "node-uuid": "~1.4.7", "oauth-sign": "~0.8.0", "qs": "~5.2.0", "stringstream": "~0.0.4", "tough-cookie": "~2.2.0", "tunnel-agent": "~0.4.1" } }, "require-uncached": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", "integrity": "sha1-Tg1W1slmL9MeQwEcS5WqSZVUIdM=", "dev": true, "requires": { "caller-path": "^0.1.0", "resolve-from": "^1.0.0" } }, "resolve": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", "dev": true }, "resolve-from": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", "integrity": "sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=", "dev": true }, "restore-cursor": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", "dev": true, "requires": { "exit-hook": "^1.0.0", "onetime": "^1.0.0" } }, "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", "dev": true, "requires": { "glob": "^7.0.5" } }, "run-async": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", "dev": true, "requires": { "once": "^1.3.0" } }, "rx-lite": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", "dev": true }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "dev": true }, "semver": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.2.0.tgz", "integrity": "sha1-KBmVuAwUSCCUFd28TPUMJpzvVcU=", "dev": true }, "shelljs": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.0.tgz", "integrity": "sha1-P28uSWXOxWX2X/OGHWRPh5KBpXY=", "dev": true, "requires": { "glob": "^7.0.0", "interpret": "^1.0.0", "rechoir": "^0.6.2" } }, "shelljs-nodecli": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/shelljs-nodecli/-/shelljs-nodecli-0.1.1.tgz", "integrity": "sha1-8b61VjdUxHXQb30IM+D2B15GLTs=", "dev": true, "requires": { "shelljs": "~0.2" }, "dependencies": { "shelljs": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.2.6.tgz", "integrity": "sha1-kEktcv/MgVmXa6umL7D2iE8MM3g=", "dev": true } } }, "sigmund": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", "dev": true }, "signal-exit": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.0.tgz", "integrity": "sha1-PAVDtl17T7xgts2UWT2b9DZzm+g=", "dev": true }, "slice-ansi": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", "dev": true }, "sntp": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", "dev": true, "requires": { "hoek": "2.x.x" } }, "source-map": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", "integrity": "sha1-2rc/vPwrqBm03gO9b26qSBZLP50=", "dev": true, "optional": true, "requires": { "amdefine": ">=0.0.4" } }, "spdx-correct": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz", "integrity": "sha1-SzBz2TP/UfORLwOsVRlJikFQ20A=", "dev": true, "requires": { "spdx-license-ids": "^1.0.2" } }, "spdx-exceptions": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-1.0.4.tgz", "integrity": "sha1-IguEI5EZrpBFqJLbgag/TOFvgP0=", "dev": true }, "spdx-expression-parse": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-1.0.2.tgz", "integrity": "sha1-1SsUtelnB3FECvIlvLVjEirEUvY=", "dev": true, "requires": { "spdx-exceptions": "^1.0.4", "spdx-license-ids": "^1.0.0" } }, "spdx-license-ids": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.1.tgz", "integrity": "sha1-0H6hek0v2TUfnZTi/5zsdBgP6PM=", "dev": true }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, "sshpk": { "version": "1.8.3", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.8.3.tgz", "integrity": "sha1-iQzJ1hTcUpLlyxpUOwPJq6pcN04=", "dev": true, "requires": { "asn1": "~0.2.3", "assert-plus": "^1.0.0", "dashdash": "^1.12.0", "ecc-jsbn": "~0.1.1", "getpass": "^0.1.1", "jodid25519": "^1.0.0", "jsbn": "~0.1.0", "tweetnacl": "~0.13.0" }, "dependencies": { "assert-plus": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "dev": true } } }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", "strip-ansi": "^3.0.0" } }, "string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", "dev": true }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", "dev": true }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { "ansi-regex": "^2.0.0" } }, "strip-bom": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", "dev": true, "requires": { "is-utf8": "^0.2.0" } }, "strip-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", "dev": true, "requires": { "get-stdin": "^4.0.1" } }, "strip-json-comments": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", "dev": true }, "supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", "dev": true }, "table": { "version": "3.8.3", "resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", "integrity": "sha1-K7xULw/amGGnVdOUf+/Ys/UThV8=", "dev": true, "requires": { "ajv": "^4.7.0", "ajv-keywords": "^1.0.0", "chalk": "^1.1.1", "lodash": "^4.0.0", "slice-ansi": "0.0.4", "string-width": "^2.0.0" }, "dependencies": { "ansi-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", "dev": true }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, "string-width": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "dev": true, "requires": { "is-fullwidth-code-point": "^2.0.0", "strip-ansi": "^4.0.0" } }, "strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "dev": true, "requires": { "ansi-regex": "^3.0.0" } } } }, "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", "dev": true }, "to-iso-string": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/to-iso-string/-/to-iso-string-0.0.2.tgz", "integrity": "sha1-TcGeZk38y+Jb2NtQiwDG2hWCVdE=", "dev": true }, "tough-cookie": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.2.2.tgz", "integrity": "sha1-yDoYMPTl7wuT7yo0iOck+N4Basc=", "dev": true }, "trim-newlines": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", "dev": true }, "tunnel-agent": { "version": "0.4.3", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz", "integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us=", "dev": true }, "tweetnacl": { "version": "0.13.3", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.13.3.tgz", "integrity": "sha1-1ii1bzvMPVrnS6nUwacE3vWrS1Y=", "dev": true, "optional": true }, "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", "dev": true, "requires": { "prelude-ls": "~1.1.2" } }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, "uglify-js": { "version": "3.4.10", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz", "integrity": "sha512-Y2VsbPVs0FIshJztycsO2SfPk7/KAF/T72qzv9u5EpQ4kB2hQoHlhNQTsNyy6ul7lQtqJN/AoWeS23OzEiEFxw==", "dev": true, "optional": true, "requires": { "commander": "~2.19.0", "source-map": "~0.6.1" }, "dependencies": { "commander": { "version": "2.19.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==", "dev": true, "optional": true }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true, "optional": true } } }, "underscore": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=", "dev": true }, "underscore.string": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.4.0.tgz", "integrity": "sha1-jN2PusTi0uoefi6Al8QvRCKA+Fs=", "dev": true }, "user-home": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", "dev": true, "requires": { "os-homedir": "^1.0.0" } }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, "validate-npm-package-license": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz", "integrity": "sha1-KAS6vnEq0zeUWaz74kdGqywwP7w=", "dev": true, "requires": { "spdx-correct": "~1.0.0", "spdx-expression-parse": "~1.0.0" } }, "verror": { "version": "1.3.6", "resolved": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz", "integrity": "sha1-z/XfEpRtKX0rqu+qJoniW+AcAFw=", "dev": true, "requires": { "extsprintf": "1.0.2" } }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "dev": true, "requires": { "isexe": "^2.0.0" } }, "wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", "dev": true }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, "write": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", "dev": true, "requires": { "mkdirp": "^0.5.1" } }, "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", "dev": true } } } eslint-plugin-requirejs-4.0.0/package.json000066400000000000000000000026471344425206400206170ustar00rootroot00000000000000{ "name": "eslint-plugin-requirejs", "author": "Casey Visco ", "version": "4.0.0", "description": "Enforce code conventions for RequireJS modules with ESLint", "homepage": "https://github.com/cvisco/eslint-plugin-requirejs", "main": "index.js", "files": [ "index.js", "lib" ], "repository": { "type": "git", "url": "https://github.com/cvisco/eslint-plugin-requirejs.git" }, "keywords": [ "eslint", "plugin", "eslintplugin", "eslint-plugin", "require", "requirejs", "amd", "lint" ], "license": "MIT", "bugs": { "url": "https://github.com/cvisco/eslint-plugin-requirejs/issues" }, "engines": { "node": ">=6" }, "devDependencies": { "coveralls": "2.11.9", "dateformat": "1.0.12", "eslint": "3.3.0", "eslint-config-eslint": "3.0.0", "eslint-plugin-node": "2.0.0", "istanbul": "0.4.5", "mocha": "2.5.3", "semver": "5.2.0", "shelljs": "0.7.0", "shelljs-nodecli": "0.1.1" }, "peerDependencies": { "eslint": ">=3.0.0" }, "scripts": { "unit": "node makefile.js unit", "test": "node makefile.js test", "lint": "node makefile.js lint", "patch": "node makefile.js patch", "minor": "node makefile.js minor", "major": "node makefile.js major", "coveralls": "cat ./coverage/lcov.info | coveralls", "mocha": "mocha" }, "dependencies": { "ignore": "5.0.5" } } eslint-plugin-requirejs-4.0.0/tests/000077500000000000000000000000001344425206400174625ustar00rootroot00000000000000eslint-plugin-requirejs-4.0.0/tests/.eslintrc.yml000066400000000000000000000000251344425206400221030ustar00rootroot00000000000000env: mocha: true eslint-plugin-requirejs-4.0.0/tests/fixtures.js000066400000000000000000000407521344425206400217010ustar00rootroot00000000000000"use strict"; exports.AMD_DEFINE = ` define(['path/to/a', 'path/to/b'], function (a, b) { return { foo: 'bar' }; }); `; exports.AMD_DEFINE_TOO_FEW_CALLBACK_PARAMS = ` define(["a", "b"], function (a) { /* ... */ }); `; exports.AMD_DEFINE_TOO_MANY_CALLBACK_PARAMS = ` define(["a", "b"], function (a, b, c) { /* ... */ }); `; exports.AMD_DEFINE_WITH_FOO_PLUGIN_AND_JS_EXT = ` define([ 'foo!aaa/bbb/ccc.js' ], function () { /* ... */ }); `; exports.AMD_DEFINE_WITH_JS_EXT = ` define(['path/to/a.js'], function (a) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_MULTI_LINE_FOUR = ` define([ 'path/to/a', 'path/to/b', 'path/to/c', 'path/to/d' ], function ( a, b, c, d ) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_MULTI_LINE_NAMES_FOUR = ` define(['path/to/a', 'path/to/b', 'path/to/c', 'path/to/d'], function ( a, b, c, d ) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_MULTI_LINE_NAMES_ONE = ` define(['path/to/a'], function (a) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_MULTI_LINE_NAMES_THREE = ` define(['path/to/a', 'path/to/b', 'path/to/c'], function ( a, b, c ) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_MULTI_LINE_NAMES_TWO = ` define(['path/to/a', 'path/to/b'], function ( a, b ) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_MULTI_LINE_NO_INDENT_FOUR = ` define([ 'path/to/a', 'path/to/b', 'path/to/c', 'path/to/d' ], function ( a, b, c, d ) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_MULTI_LINE_NO_INDENT_THREE = ` define([ 'path/to/a', 'path/to/b', 'path/to/c' ], function ( a, b, c ) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_MULTI_LINE_NO_INDENT_TWO = ` define([ 'path/to/a', 'path/to/b' ], function ( a, b ) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_MULTI_LINE_ONE = ` define([ 'path/to/a' ], function ( a ) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_MULTI_LINE_PATHS_FOUR = ` define([ 'path/to/a', 'path/to/b', 'path/to/c', 'path/to/d' ], function (a, b, c, d) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_MULTI_LINE_PATHS_ONE = ` define([ 'path/to/a' ], function (a) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_MULTI_LINE_PATHS_THREE = ` define([ 'path/to/a', 'path/to/b', 'path/to/c' ], function (a, b, c) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_MULTI_LINE_PATHS_TWO = ` define([ 'path/to/a', 'path/to/b' ], function (a, b) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_MULTI_LINE_THREE = ` define([ 'path/to/a', 'path/to/b', 'path/to/c' ], function ( a, b, c ) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_MULTI_LINE_TWO = ` define([ 'path/to/a', 'path/to/b' ], function ( a, b ) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_NONE = ` define([], function () { return { foo: 'bar' }; }); `; exports.AMD_DEPS_SINGLE_LINE_FOUR = ` define(['path/to/a', 'path/to/b', 'path/to/c', 'path/to/d'], function (a, b, c, d) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_SINGLE_LINE_NO_INDENT_FOUR = ` define(['path/to/a', 'path/to/b', 'path/to/c', 'path/to/d'], function (a, b, c, d) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_SINGLE_LINE_NO_INDENT_THREE = ` define(['path/to/a', 'path/to/b', 'path/to/c'], function (a, b, c) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_SINGLE_LINE_NO_INDENT_TWO = ` define(['path/to/a', 'path/to/b'], function (a, b) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_SINGLE_LINE_ONE = ` define(['path/to/a'], function (a) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_SINGLE_LINE_THREE = ` define(['path/to/a', 'path/to/b', 'path/to/c'], function (a, b, c) { return { foo: 'bar' }; }); `; exports.AMD_DEPS_SINGLE_LINE_TWO = ` define(['path/to/a', 'path/to/b'], function (a, b) { return { foo: 'bar' }; }); `; exports.AMD_EMPTY_DEFINE = ` define([], function () { return { foo: 'bar' }; }); `; exports.AMD_EMPTY_REQUIRE = ` require([], function () { return { foo: 'bar' }; }); `; exports.AMD_EMPTY_REQUIREJS = ` requirejs([], function () { return { foo: 'bar' }; }); `; exports.AMD_NAMED_DEFINE_TOO_FEW_CALLBACK_PARAMS = ` define("module", ["a", "b"], function (a) { /* ... */ }); `; exports.AMD_NAMED_DEFINE_TOO_MANY_CALLBACK_PARAMS = ` define("module", ["a", "b"], function (a, b, c) { /* ... */ }); `; exports.AMD_REQUIRE = ` require(['path/to/a', 'path/to/b'], function (a, b) { /* ... */ }); `; exports.AMD_REQUIREJS = ` requirejs(['path/to/a', 'path/to/b'], function (a, b) { /* ... */ }); `; exports.AMD_REQUIREJS_CALLEXPRESSION_CALLBACK = ` requirejs(["path/to/a"], getCallback()); `; exports.AMD_REQUIREJS_IDENTIFIER_CALLBACK = ` requirejs(["path/to/a"], callback); `; exports.AMD_REQUIREJS_MEMBEREXPRESSION_CALLBACK = ` requirejs(["path/to/a"], foo.callback); `; exports.AMD_REQUIREJS_RELATIVE = ` define(['require'], function (require) { var foo = requirejs('./foo'); }); `; exports.AMD_REQUIREJS_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS = ` requirejs("a", function () { /* ... */ }); `; exports.AMD_REQUIREJS_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK = ` requirejs("a", function () { /* ... */ }, function (err) { /* ... */ }); `; exports.AMD_REQUIREJS_SINGLEDEP_TOO_MANY_CALLBACK_PARAMS = ` requirejs("a", function (a, b) { /* ... */ }); `; exports.AMD_REQUIREJS_SINGLEDEP_TOO_MANY_CALLBACK_PARAMS_WITH_ERRBACK = ` requirejs("a", function (a, b) { /* ... */ }, function (err) { /* ... */ }); `; exports.AMD_REQUIREJS_TOO_FEW_CALLBACK_PARAMS = ` requirejs(["a", "b"], function (a) { /* ... */ }); `; exports.AMD_REQUIREJS_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK = ` requirejs(["a", "b"], function (a) { /* ... */ }, function (err) { /* ... */ }); `; exports.AMD_REQUIREJS_TOO_MANY_CALLBACK_PARAMS = ` requirejs(["a", "b"], function (a, b, c) { /* ... */ }); `; exports.AMD_REQUIREJS_TOO_MANY_CALLBACK_PARAMS_WITH_ERRBACK = ` requirejs(["a", "b"], function (a, b, c) { /* ... */ }, function (err) { /* ... */ }); `; exports.AMD_REQUIREJS_WITH_ERRBACK = ` requirejs( ['path/to/a', 'path/to/b'], function (a, b) { /* ... */ }, function (err) { /* ... */ } ); `; exports.AMD_REQUIREJS_WITH_FOO_PLUGIN_AND_JS_EXT = ` requirejs([ 'foo!aaa/bbb/ccc.js' ], function () { /* ... */ }); `; exports.AMD_REQUIREJS_WITH_JS_EXT = ` requirejs(['path/to/a.js'], function (a) { /* ... */ }); `; exports.AMD_REQUIRE_CALLEXPRESSION_CALLBACK = ` require(["path/to/a"], getCallback()); `; exports.AMD_REQUIRE_IDENTIFIER_CALLBACK = ` require(["path/to/a"], callback); `; exports.AMD_REQUIRE_MEMBEREXPRESSION_CALLBACK = ` require(["path/to/a"], foo.callback); `; exports.AMD_REQUIRE_RELATIVE = ` define(['require'], function (require) { var foo = require('./foo'); }); `; exports.AMD_REQUIRE_RELATIVE_WITH_JS_EXT = ` define(['require'], function (require) { var foo = require('./foo.js'); }); `; exports.AMD_REQUIRE_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS = ` require("a", function () { /* ... */ }); `; exports.AMD_REQUIRE_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK = ` require("a", function () { /* ... */ }, function (err) { /* ... */ }); `; exports.AMD_REQUIRE_SINGLEDEP_TOO_MANY_CALLBACK_PARAMS = ` require("a", function (a, b) { /* ... */ }); `; exports.AMD_REQUIRE_SINGLEDEP_TOO_MANY_CALLBACK_PARAMS_WITH_ERRBACK = ` require("a", function (a, b) { /* ... */ }, function (err) { /* ... */ }); `; exports.AMD_REQUIRE_TOO_FEW_CALLBACK_PARAMS = ` require(["a", "b"], function (a) { /* ... */ }); `; exports.AMD_REQUIRE_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK = ` require(["a", "b"], function (a) { /* ... */ }, function (err) { /* ... */ }); `; exports.AMD_REQUIRE_TOO_MANY_CALLBACK_PARAMS = ` require(["a", "b"], function (a, b, c) { /* ... */ }); `; exports.AMD_REQUIRE_TOO_MANY_CALLBACK_PARAMS_WITH_ERRBACK = ` require(["a", "b"], function (a, b, c) { /* ... */ }, function (err) { /* ... */ }); `; exports.AMD_REQUIRE_WITH_ERRBACK = ` require( ['path/to/a', 'path/to/b'], function (a, b) { /* ... */ }, function (err) { /* ... */ } ); `; exports.AMD_REQUIRE_WITH_FOO_PLUGIN_AND_JS_EXT = ` require([ 'foo!aaa/bbb/ccc.js' ], function () { /* ... */ }); `; exports.AMD_REQUIRE_WITH_JS_EXT = ` require(['path/to/a.js'], function (a) { /* ... */ }); `; exports.BAD_DEFINE = ` define('foo', 'bar', false); `; exports.BAD_REQUIREJS_STRING_DEP = ` requirejs('path/to/a', function (a) { /* ... */ }); `; exports.BAD_REQUIRE_EMPTY = ` require(); `; exports.BAD_REQUIRE_INVALID_CALLBACK = ` require(['path/to/a'], { foo: 'bar' }); `; exports.BAD_REQUIRE_INVALID_CALLBACK_ARRAY = ` require(["path/to/a"], ["not a callback"]); `; exports.BAD_REQUIRE_INVALID_ERRBACK = ` require( ['path/to/a'], function (a) { /* ... */ }, { /* ... */ } ); `; exports.BAD_REQUIRE_INVALID_ERRBACK_ARRAY = ` require( ['path/to/a'], function (a) { /* ... */ }, [ /* ... */ ] ); `; exports.BAD_REQUIRE_NO_DEPS = ` require(function () { /* ... */ }); `; exports.BAD_REQUIRE_OBJECT = ` require({ foo: 'bar' }); `; exports.BAD_REQUIRE_STRING_DEP = ` require('path/to/a', function (a) { /* ... */ }); `; exports.BAD_REQUIRE_TOO_MANY_ARGS = ` require( ['path/to/a'], function (a) { /* ... */ }, function (err) { /* ... */ }, false ); `; exports.CJS_WITH_EXPORTS = ` define(function (require, exports) { var a = require('path/to/a'), b = require('path/to/b'); exports.doSomething = function () { /* ... */ }; }); `; exports.CJS_WITH_FOO_PLUGIN_AND_JS_EXT = ` define(function (require) { var a = require('foo!aaa/bbb/ccc.js'); /* ... */ }); `; exports.CJS_WITH_FUNC_EXPR = ` define(function (require, exports, module) { var a = require('path/to/a'), b = require('path/to/b'); var f = function () { return 'foo'; }; var b = function () { return 'bar'; }; module.exports = { doSomething: function () { /* ... */ }, foo: f, bar: b }; }); `; exports.CJS_WITH_INVALID_EXPORTS = ` define(function (require, exports) { var a = require('path/to/a'), b = require('path/to/b'); exports = { doSomething: function () { /* ... */ } }; }); `; exports.CJS_WITH_JS_EXT = ` define(function (require) { var a = require('path/to/a.js'); return { foo: 'bar' }; }); `; exports.CJS_WITH_MODULE_EXPORTS = ` define(function (require, exports, module) { var a = require('path/to/a'), b = require('path/to/b'); module.exports = { doSomething: function () { /* ... */ } }; }); `; exports.CJS_WITH_NESTED_RETURNS = ` define(function (require, exports) { var a = require('path/to/a'), b = require('path/to/b'); function bar() { return 'bar'; } exports.foo = function () { return 'foo' + bar(); } }); `; exports.CJS_WITH_RETURN = ` define(function (require) { var a = require('path/to/a'), b = require('path/to/b'); return { foo: 'bar' }; }); `; exports.CONDITIONAL_AMD_REQUIRE = ` if (someCondition) { require(['path/to/a', 'path/to/b'], function (a, b) { return { foo: 'bar' }; }); } `; exports.CONDITIONAL_AMD_REQUIREJS = ` if (someCondition) { requirejs(['path/to/a', 'path/to/b'], function (a, b) { return { foo: 'bar' }; }); } `; exports.CONDITIONAL_CJS_REQUIRE = ` define(function (require) { if (someCondition) { var lib = require('path/to/lib'); } }); `; exports.CONDITIONAL_CJS_REQUIREJS = ` define(function (require) { if (someCondition) { var lib = requirejs('path/to/lib'); } }); `; exports.CONDITIONAL_NESTED_AMD_REQUIRE = ` require(['a', 'b'], function (a, b) { if (someCondition) { require(['c'], function (c) { return { foo: 'bar' }; }); } }); `; exports.CONDITIONAL_NESTED_AMD_REQUIREJS = ` requirejs(['a', 'b'], function (a, b) { if (someCondition) { requirejs(['c'], function (c) { return { foo: 'bar' }; }); } }); `; exports.CONDITIONAL_TERNARY_CJS_REQUIRE = ` define(function (require) { var lib = someCondition ? require('path/to/a') : require('path/to/b'); }); `; exports.CONDITIONAL_TERNARY_CJS_REQUIREJS = ` define(function (require) { var lib = someCondition ? requirejs('path/to/a') : requirejs('path/to/b'); }); `; exports.DYNAMIC_AMD_REQUIREJS_WITH_ERRBACK = ` requirejs( [someCondition ? 'path/to/a' : 'path/to/b'], function (mod) { return { foo: 'bar' }; }, function (err) { /* handle error... */ } ); `; exports.DYNAMIC_AMD_REQUIRE_WITH_ERRBACK = ` require( [someCondition ? 'path/to/a' : 'path/to/b'], function (mod) { return { foo: 'bar' }; }, function (err) { /* handle error... */ } ); `; exports.DYNAMIC_MIXED_AMD_REQUIRE = ` var pathB = 'path/to/b'; require(['path/to/a', pathB], function (a, b) { return { foo: 'bar' }; }); `; exports.DYNAMIC_MIXED_AMD_REQUIREJS = ` var pathB = 'path/to/b'; requirejs(['path/to/a', pathB], function (a, b) { return { foo: 'bar' }; }); `; exports.DYNAMIC_TERNARY_AMD_REQUIRE = ` require(someCondition ? ['a', 'b'] : ['c', 'd'], function (a, b) { return { foo: 'bar' }; }); `; exports.DYNAMIC_TERNARY_AMD_REQUIREJS = ` requirejs(someCondition ? ['a', 'b'] : ['c', 'd'], function (a, b) { return { foo: 'bar' }; }); `; exports.DYNAMIC_TERNARY_CJS_REQUIRE = ` define(function (require) { var lib = require(lang === 'fr' ? 'lib_fr' : 'lib_en'); }); `; exports.DYNAMIC_TERNARY_CJS_REQUIREJS = ` define(function (require) { var lib = requirejs(lang === 'fr' ? 'lib_fr' : 'lib_en'); }); `; exports.DYNAMIC_VARIABLE_AMD_DEFINE = ` define(getDefinePaths(), function (a, b) { }); `; exports.DYNAMIC_VARIABLE_AMD_NAMED_DEFINE = ` define("myModule", getDefinePaths(), function (a, b) { }); `; exports.DYNAMIC_VARIABLE_AMD_REQUIRE = ` var paths = ['path/to/a', 'path/to/b']; require(paths, function (a, b) { return { foo: 'bar' }; }); `; exports.DYNAMIC_VARIABLE_AMD_REQUIREJS = ` var paths = ['path/to/a', 'path/to/b']; requirejs(paths, function (a, b) { return { foo: 'bar' }; }); `; exports.DYNAMIC_VARIABLE_CJS_REQUIRE = ` define(function (require) { var path = 'path/to/lib'; var lib = require(path); }); `; exports.DYNAMIC_VARIABLE_CJS_REQUIREJS = ` define(function (require) { var path = 'path/to/lib'; var lib = requirejs(path); }); `; exports.EMPTY_DEFINE = ` define(); `; exports.FUNCTION_DEFINE = ` define(function () { return { foo: 'bar' }; }); `; exports.MULTIPLE_DEFINE = ` define({ foo: 'bar' }); define(function () { return { foo: 'bar' }; }); `; exports.NAMED_AMD_DEFINE = ` define('path/to/c', [ 'path/to/a', 'path/to/b' ], function (a, b) { return { foo: 'bar' }; }); `; exports.NAMED_AMD_DEFINE_WITH_JS_EXT = ` define('path/to/c', ['path/to/a.js'], function (a) { return { foo: 'bar' }; }); `; exports.NAMED_AMD_EMPTY_DEFINE = ` define('path/to/c', [], function () { return { foo: 'bar' }; }); `; exports.NAMED_CJS_DEFINE = ` define('path/to/c', function (require, exports, module) { var a = require('path/to/a'), b = require('path/to/b'); module.exports = { doSomething: function () { /* ... */ } }; }); `; exports.NAMED_CJS_DEFINE_WITH_JS_EXT = ` define('path/to/c', function (require, exports, module) { var a = require('path/to/a.js'); module.exports = { doSomething: function () { /* ... */ } }; }); `; exports.NAMED_FUNCTION_DEFINE = ` define('path/to/a', function () { return { foo: 'bar' }; }); `; exports.NAMED_OBJECT_DEFINE = ` define('path/to/a', { foo: 'bar' }); `; exports.NESTED_AMD_REQUIRE = ` require(['a', 'b'], function (a, b) { require(['c'], function (c) { return { foo: 'bar' }; }); }); `; exports.NESTED_AMD_REQUIREJS = ` requirejs(['a', 'b'], function (a, b) { requirejs(['c'], function (c) { return { foo: 'bar' }; }); }); `; exports.NESTED_AMD_REQUIREJS_NO_CALLBACK = ` requirejs(['a', 'b'], function (a, b) { requirejs(['c']); }); `; exports.NESTED_AMD_REQUIRE_NO_CALLBACK = ` require(['a', 'b'], function (a, b) { require(['c']); }); `; exports.NON_WRAPPED_EXPORTS = ` exports = { foo: 'bar' }; `; exports.OBJECT_DEFINE = ` define({ a: 'foo', b: 'bar' }); `; exports.DEFINE_WITH_ARROW_FUNCTION = ` define('underscore', [], () => window._); `; eslint-plugin-requirejs-4.0.0/tests/lib/000077500000000000000000000000001344425206400202305ustar00rootroot00000000000000eslint-plugin-requirejs-4.0.0/tests/lib/rules/000077500000000000000000000000001344425206400213625ustar00rootroot00000000000000eslint-plugin-requirejs-4.0.0/tests/lib/rules/amd-function-arity.js000066400000000000000000000301521344425206400254330ustar00rootroot00000000000000/** * @file Tests for `amd-function-arity` rule * @author Kevin Partington */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/amd-function-arity"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- function tooManyParams(expected, actual) { return { message: `Too many parameters in callback (expected ${expected}, found ${actual}).` }; } function tooFewParams(expected, actual) { return { message: `Not enough parameters in callback (expected ${expected}, found ${actual}).` }; } testRule("amd-function-arity", rule, { valid: [ // Dependency count and parameter counts equal-- always valid fixtures.AMD_DEFINE, fixtures.AMD_EMPTY_DEFINE, fixtures.AMD_EMPTY_REQUIRE, fixtures.AMD_EMPTY_REQUIREJS, fixtures.AMD_REQUIRE, fixtures.AMD_REQUIRE_WITH_ERRBACK, fixtures.AMD_REQUIREJS, fixtures.AMD_REQUIREJS_WITH_ERRBACK, fixtures.NAMED_AMD_DEFINE, fixtures.NAMED_AMD_EMPTY_DEFINE, fixtures.DYNAMIC_AMD_REQUIRE_WITH_ERRBACK, fixtures.DYNAMIC_AMD_REQUIREJS_WITH_ERRBACK, fixtures.DYNAMIC_MIXED_AMD_REQUIRE, fixtures.DYNAMIC_MIXED_AMD_REQUIREJS, // Valid because dependency array arity is unknowable fixtures.DYNAMIC_VARIABLE_AMD_DEFINE, fixtures.DYNAMIC_VARIABLE_AMD_NAMED_DEFINE, fixtures.DYNAMIC_VARIABLE_AMD_REQUIRE, // Valid only if allowExtraDependencies is enabled { code: fixtures.AMD_DEFINE_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: true }] }, { code: fixtures.AMD_NAMED_DEFINE_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: true }] }, { code: fixtures.AMD_REQUIRE_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: true }] }, { code: fixtures.AMD_REQUIREJS_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: true }] }, { code: fixtures.AMD_REQUIRE_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: true }] }, { code: fixtures.AMD_REQUIREJS_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: true }] }, { code: fixtures.AMD_REQUIRE_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: true }] }, { code: fixtures.AMD_REQUIREJS_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: true }] }, { code: fixtures.AMD_REQUIRE_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: true }] }, { code: fixtures.AMD_REQUIREJS_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: true }] }, // Valid only if allowedExtraDependencies are specified { code: fixtures.AMD_DEFINE_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: ["b"] }] }, { code: fixtures.AMD_NAMED_DEFINE_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: ["b"] }] }, { code: fixtures.AMD_REQUIRE_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: ["b"] }] }, { code: fixtures.AMD_REQUIREJS_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: ["b"] }] }, { code: fixtures.AMD_REQUIRE_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: ["b"] }] }, { code: fixtures.AMD_REQUIREJS_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: ["b"] }] }, { code: fixtures.AMD_REQUIRE_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: ["a"] }] }, { code: fixtures.AMD_REQUIREJS_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: ["a"] }] }, { code: fixtures.AMD_REQUIRE_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: ["a"] }] }, { code: fixtures.AMD_REQUIREJS_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: ["a"] }] } ], invalid: [ // Too few dependencies (invalid even with allowExtraDependencies option) { code: fixtures.AMD_DEFINE_TOO_MANY_CALLBACK_PARAMS, options: [{ allowExtraDependencies: true }], errors: [tooManyParams(2, 3)] }, { code: fixtures.AMD_NAMED_DEFINE_TOO_MANY_CALLBACK_PARAMS, options: [{ allowExtraDependencies: true }], errors: [tooManyParams(2, 3)] }, { code: fixtures.AMD_REQUIRE_TOO_MANY_CALLBACK_PARAMS, options: [{ allowExtraDependencies: true }], errors: [tooManyParams(2, 3)] }, { code: fixtures.AMD_REQUIREJS_TOO_MANY_CALLBACK_PARAMS, options: [{ allowExtraDependencies: true }], errors: [tooManyParams(2, 3)] }, { code: fixtures.AMD_REQUIRE_TOO_MANY_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: true }], errors: [tooManyParams(2, 3)] }, { code: fixtures.AMD_REQUIREJS_TOO_MANY_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: true }], errors: [tooManyParams(2, 3)] }, { code: fixtures.AMD_REQUIRE_SINGLEDEP_TOO_MANY_CALLBACK_PARAMS, options: [{ allowExtraDependencies: true }], errors: [tooManyParams(1, 2)] }, { code: fixtures.AMD_REQUIREJS_SINGLEDEP_TOO_MANY_CALLBACK_PARAMS, options: [{ allowExtraDependencies: true }], errors: [tooManyParams(1, 2)] }, { code: fixtures.AMD_REQUIRE_SINGLEDEP_TOO_MANY_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: true }], errors: [tooManyParams(1, 2)] }, { code: fixtures.AMD_REQUIREJS_SINGLEDEP_TOO_MANY_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: true }], errors: [tooManyParams(1, 2)] }, // Extra dependencies (invalid since option not specified) { code: fixtures.AMD_DEFINE_TOO_FEW_CALLBACK_PARAMS, errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_NAMED_DEFINE_TOO_FEW_CALLBACK_PARAMS, errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_REQUIRE_TOO_FEW_CALLBACK_PARAMS, errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_REQUIREJS_TOO_FEW_CALLBACK_PARAMS, errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_REQUIRE_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_REQUIREJS_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_REQUIRE_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS, errors: [tooFewParams(1, 0)] }, { code: fixtures.AMD_REQUIREJS_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS, errors: [tooFewParams(1, 0)] }, { code: fixtures.AMD_REQUIRE_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, errors: [tooFewParams(1, 0)] }, { code: fixtures.AMD_REQUIREJS_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, errors: [tooFewParams(1, 0)] }, // Extra dependencies (invalid since option set to false) { code: fixtures.AMD_DEFINE_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: false }], errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_NAMED_DEFINE_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: false }], errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_REQUIRE_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: false }], errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_REQUIREJS_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: false }], errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_REQUIRE_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: false }], errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_REQUIREJS_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: false }], errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_REQUIRE_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: false }], errors: [tooFewParams(1, 0)] }, { code: fixtures.AMD_REQUIREJS_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: false }], errors: [tooFewParams(1, 0)] }, { code: fixtures.AMD_REQUIRE_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: false }], errors: [tooFewParams(1, 0)] }, { code: fixtures.AMD_REQUIREJS_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: false }], errors: [tooFewParams(1, 0)] }, // Extra dependencies (invalid since allowed paths are not the extra dependencies) { code: fixtures.AMD_DEFINE_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: ["x", "y"] }], errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_NAMED_DEFINE_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: ["x", "y"] }], errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_REQUIRE_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: ["x", "y"] }], errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_REQUIREJS_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: ["x", "y"] }], errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_REQUIRE_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: ["x", "y"] }], errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_REQUIREJS_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: ["x", "y"] }], errors: [tooFewParams(2, 1)] }, { code: fixtures.AMD_REQUIRE_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: ["x", "y"] }], errors: [tooFewParams(1, 0)] }, { code: fixtures.AMD_REQUIREJS_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS, options: [{ allowExtraDependencies: ["x", "y"] }], errors: [tooFewParams(1, 0)] }, { code: fixtures.AMD_REQUIRE_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: ["x", "y"] }], errors: [tooFewParams(1, 0)] }, { code: fixtures.AMD_REQUIREJS_SINGLEDEP_TOO_FEW_CALLBACK_PARAMS_WITH_ERRBACK, options: [{ allowExtraDependencies: ["x", "y"] }], errors: [tooFewParams(1, 0)] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/enforce-define.js000066400000000000000000000076361344425206400246050ustar00rootroot00000000000000/** * @file Tests for `enforce-define` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/enforce-define"); // ----------------------------------------------------------------------------- // Fixtures // ----------------------------------------------------------------------------- const UNWRAPPED_FILE_NO_EXPRESSIONSTATEMENT = ` var foo = 'foo'; function bar() { return foo; } `; const UNWRAPPED_FILE = ` var foo = 'foo'; function bar() { return foo; } window.bar = bar; `; // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR = { message: "File must be wrapped in a `define` call", type: "Program" }; testRule("enforce-define", rule, { valid: [ // Any sort of define should work fixtures.MULTIPLE_DEFINE, fixtures.OBJECT_DEFINE, fixtures.FUNCTION_DEFINE, fixtures.AMD_DEFINE, fixtures.AMD_EMPTY_DEFINE, fixtures.CJS_WITH_RETURN, fixtures.CJS_WITH_EXPORTS, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.CJS_WITH_FUNC_EXPR, fixtures.CJS_WITH_INVALID_EXPORTS, fixtures.NAMED_AMD_DEFINE, fixtures.NAMED_AMD_EMPTY_DEFINE, fixtures.NAMED_FUNCTION_DEFINE, fixtures.NAMED_OBJECT_DEFINE, fixtures.NAMED_CJS_DEFINE, fixtures.AMD_DEFINE_WITH_JS_EXT, fixtures.CJS_WITH_JS_EXT, fixtures.NAMED_AMD_DEFINE_WITH_JS_EXT, fixtures.NAMED_CJS_DEFINE_WITH_JS_EXT, // All of the invalid cases should work if we ignore the file { code: UNWRAPPED_FILE, filename: "main.js", options: [ "main.js" ] }, { code: fixtures.NON_WRAPPED_EXPORTS, filename: "main.js", options: [ "main.js" ] }, { code: fixtures.AMD_REQUIRE, filename: "main.js", options: [ "main.js" ] }, { code: fixtures.AMD_REQUIREJS, filename: "main.js", options: [ "main.js" ] }, // Ignore should work with full path { code: UNWRAPPED_FILE, filename: "path/to/main.js", options: [ [ "main.js" ] ] }, // Ignore should support multiple filenames { code: UNWRAPPED_FILE, filename: "main.js", options: [ [ "main.js", "index.js" ] ] }, { code: UNWRAPPED_FILE, filename: "index.js", options: [ [ "main.js", "index.js" ] ] } ], invalid: [ { code: UNWRAPPED_FILE, errors: [ERROR] }, { code: UNWRAPPED_FILE_NO_EXPRESSIONSTATEMENT, errors: [ERROR] }, { code: fixtures.NON_WRAPPED_EXPORTS, errors: [ERROR] }, { code: fixtures.AMD_REQUIRE, errors: [ERROR] }, { code: fixtures.AMD_REQUIREJS, errors: [ERROR] }, { code: UNWRAPPED_FILE, filename: "foo.js", args: [ 1, "main.js" ], errors: [ERROR] }, { code: UNWRAPPED_FILE, filename: "foo.js", args: [ 1, [ "main.js", "index.js" ] ], errors: [ERROR] }, { code: UNWRAPPED_FILE, filename: "path/to/foo.js", args: [ 1, "main.js" ], errors: [ERROR] }, { code: UNWRAPPED_FILE, filename: "path/to/main.js/foo.js", args: [ 1, "main.js" ], errors: [ERROR] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-amd-define.js000066400000000000000000000021761344425206400243310ustar00rootroot00000000000000/** * @file Tests for `no-amd-define` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-amd-define"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR = { message: "AMD form of `define` is not allowed.", type: "CallExpression" }; testRule("no-amd-define", rule, { valid: [ fixtures.OBJECT_DEFINE, fixtures.FUNCTION_DEFINE, fixtures.CJS_WITH_RETURN, fixtures.CJS_WITH_EXPORTS, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.NAMED_OBJECT_DEFINE, fixtures.NAMED_FUNCTION_DEFINE, fixtures.NAMED_CJS_DEFINE ], invalid: [ { code: fixtures.AMD_DEFINE, errors: [ERROR] }, { code: fixtures.AMD_EMPTY_DEFINE, errors: [ERROR] }, { code: fixtures.NAMED_AMD_DEFINE, errors: [ERROR] }, { code: fixtures.NAMED_AMD_EMPTY_DEFINE, errors: [ERROR] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-assign-exports.js000066400000000000000000000014531344425206400253230ustar00rootroot00000000000000/** * @file Tests for `no-assign-exports` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-assign-exports"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR = { message: "Invalid assignment to `exports`.", type: "AssignmentExpression" }; testRule("no-assign-exports", rule, { valid: [ fixtures.CJS_WITH_EXPORTS, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.NON_WRAPPED_EXPORTS ], invalid: [ { code: fixtures.CJS_WITH_INVALID_EXPORTS, errors: [ERROR] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-assign-require.js000066400000000000000000000037201344425206400252720ustar00rootroot00000000000000/** * @file Tests for `no-assign-require` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const rule = require("../../../lib/rules/no-assign-require"); // ----------------------------------------------------------------------------- // Fixtures // ----------------------------------------------------------------------------- const OK_PROPERTY_ASSIGNMENT = ` foo.require = { bar: 'bar' }; `; const OK_SIMILAR_VARIABLE = ` var required = true; `; const BAD_DECLARE_REQUIRE = ` var require = { deps: ['path/to/a', 'path/to/b'], callback: function (a, b) { a.foo(); b.bar(); } }; `; const BAD_ASSIGN_TO_REQUIRE = ` require = { deps: ['path/to/a', 'path/to/b'], callback: function (a, b) { a.foo(); b.bar(); } }; `; const BAD_ASSIGN_TO_WINDOW_REQUIRE = ` window.require = { deps: ['path/to/a', 'path/to/b'], callback: function (a, b) { a.foo(); b.bar(); } }; `; // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR_MSG = "Invalid assignment to `require`."; testRule("no-assign-require", rule, { valid: [ OK_PROPERTY_ASSIGNMENT, OK_SIMILAR_VARIABLE ], invalid: [ { code: BAD_DECLARE_REQUIRE, errors: [ { message: ERROR_MSG, type: "VariableDeclarator" } ] }, { code: BAD_ASSIGN_TO_REQUIRE, errors: [ { message: ERROR_MSG, type: "AssignmentExpression" } ] }, { code: BAD_ASSIGN_TO_WINDOW_REQUIRE, errors: [ { message: ERROR_MSG, type: "AssignmentExpression" } ] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-commonjs-exports.js000066400000000000000000000022351344425206400256630ustar00rootroot00000000000000/** * @file Tests for `no-commonjs-exports` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-commonjs-exports"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR = { message: "Unexpected use of `exports` in module definition.", type: "AssignmentExpression" }; testRule("no-commonjs-exports", rule, { valid: [ fixtures.OBJECT_DEFINE, fixtures.FUNCTION_DEFINE, fixtures.AMD_DEFINE, fixtures.AMD_EMPTY_DEFINE, fixtures.NAMED_OBJECT_DEFINE, fixtures.NAMED_FUNCTION_DEFINE, fixtures.NAMED_AMD_DEFINE, fixtures.NAMED_AMD_EMPTY_DEFINE, fixtures.NAMED_CJS_DEFINE, fixtures.CJS_WITH_RETURN, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.CJS_WITH_FUNC_EXPR, fixtures.NON_WRAPPED_EXPORTS ], invalid: [ { code: fixtures.CJS_WITH_EXPORTS, errors: [ERROR] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-commonjs-module-exports.js000066400000000000000000000023571344425206400271530ustar00rootroot00000000000000/** * @file Tests for `no-commonjs-module-exports` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-commonjs-module-exports"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR = { message: "Unexpected use of `module.exports` in module definition.", type: "AssignmentExpression" }; testRule("no-commonjs-module-exports", rule, { valid: [ fixtures.OBJECT_DEFINE, fixtures.FUNCTION_DEFINE, fixtures.AMD_DEFINE, fixtures.AMD_EMPTY_DEFINE, fixtures.NAMED_OBJECT_DEFINE, fixtures.NAMED_FUNCTION_DEFINE, fixtures.NAMED_AMD_DEFINE, fixtures.NAMED_AMD_EMPTY_DEFINE, fixtures.CJS_WITH_RETURN, fixtures.CJS_WITH_EXPORTS, fixtures.NON_WRAPPED_EXPORTS ], invalid: [ { code: fixtures.CJS_WITH_MODULE_EXPORTS, errors: [ERROR] }, { code: fixtures.CJS_WITH_FUNC_EXPR, errors: [ERROR] }, { code: fixtures.NAMED_CJS_DEFINE, errors: [ERROR] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-commonjs-return.js000066400000000000000000000022611344425206400254750ustar00rootroot00000000000000/** * @file Tests for `no-commonjs-return` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-commonjs-return"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR = { message: "Unexpected `return` in module definition.", type: "ReturnStatement" }; testRule("no-commonjs-return", rule, { valid: [ fixtures.OBJECT_DEFINE, fixtures.FUNCTION_DEFINE, fixtures.AMD_DEFINE, fixtures.AMD_EMPTY_DEFINE, fixtures.NAMED_OBJECT_DEFINE, fixtures.NAMED_FUNCTION_DEFINE, fixtures.NAMED_AMD_DEFINE, fixtures.NAMED_AMD_EMPTY_DEFINE, fixtures.NAMED_CJS_DEFINE, fixtures.CJS_WITH_EXPORTS, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.CJS_WITH_FUNC_EXPR, fixtures.CJS_WITH_NESTED_RETURNS ], invalid: [ { code: fixtures.CJS_WITH_RETURN, errors: [ERROR] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-commonjs-wrapper.js000066400000000000000000000022471344425206400256420ustar00rootroot00000000000000/** * @file Tests for `no-commonjs-wrapper` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-commonjs-wrapper"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR = { message: "Simplified CommonJS Wrapper form of `define` is not allowed", type: "CallExpression" }; testRule("no-commonjs-wrapper", rule, { valid: [ fixtures.OBJECT_DEFINE, fixtures.FUNCTION_DEFINE, fixtures.AMD_DEFINE, fixtures.AMD_EMPTY_DEFINE, fixtures.NAMED_OBJECT_DEFINE, fixtures.NAMED_FUNCTION_DEFINE, fixtures.NAMED_AMD_DEFINE, fixtures.NAMED_AMD_EMPTY_DEFINE ], invalid: [ { code: fixtures.CJS_WITH_RETURN, errors: [ERROR] }, { code: fixtures.CJS_WITH_EXPORTS, errors: [ERROR] }, { code: fixtures.CJS_WITH_MODULE_EXPORTS, errors: [ERROR] }, { code: fixtures.NAMED_CJS_DEFINE, errors: [ERROR] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-conditional-require.js000066400000000000000000000046231344425206400263140ustar00rootroot00000000000000/** * @file Tests for `no-conditional-require` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-conditional-require"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR = { message: "Conditional `require` calls are not allowed.", type: "CallExpression" }; testRule("no-conditional-require", rule, { valid: [ fixtures.AMD_REQUIRE, fixtures.AMD_REQUIRE_RELATIVE, fixtures.AMD_EMPTY_REQUIRE, fixtures.AMD_REQUIRE_WITH_ERRBACK, fixtures.AMD_REQUIREJS, fixtures.AMD_REQUIREJS_RELATIVE, fixtures.AMD_EMPTY_REQUIREJS, fixtures.AMD_REQUIREJS_WITH_ERRBACK, fixtures.NESTED_AMD_REQUIRE, fixtures.NESTED_AMD_REQUIREJS, fixtures.NESTED_AMD_REQUIRE_NO_CALLBACK, fixtures.NESTED_AMD_REQUIREJS_NO_CALLBACK, fixtures.CJS_WITH_RETURN, fixtures.CJS_WITH_EXPORTS, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.NAMED_CJS_DEFINE, fixtures.DYNAMIC_MIXED_AMD_REQUIRE, fixtures.DYNAMIC_TERNARY_AMD_REQUIRE, fixtures.DYNAMIC_VARIABLE_AMD_REQUIRE, fixtures.DYNAMIC_TERNARY_CJS_REQUIRE, fixtures.DYNAMIC_VARIABLE_CJS_REQUIRE, fixtures.DYNAMIC_AMD_REQUIRE_WITH_ERRBACK, fixtures.DYNAMIC_MIXED_AMD_REQUIREJS, fixtures.DYNAMIC_TERNARY_AMD_REQUIREJS, fixtures.DYNAMIC_VARIABLE_AMD_REQUIREJS, fixtures.DYNAMIC_TERNARY_CJS_REQUIREJS, fixtures.DYNAMIC_VARIABLE_CJS_REQUIREJS, fixtures.DYNAMIC_AMD_REQUIREJS_WITH_ERRBACK ], invalid: [ { code: fixtures.CONDITIONAL_AMD_REQUIRE, errors: [ERROR] }, { code: fixtures.CONDITIONAL_CJS_REQUIRE, errors: [ERROR] }, { code: fixtures.CONDITIONAL_TERNARY_CJS_REQUIRE, errors: [ERROR, ERROR] }, { code: fixtures.CONDITIONAL_NESTED_AMD_REQUIRE, errors: [ERROR] }, { code: fixtures.CONDITIONAL_AMD_REQUIREJS, errors: [ERROR] }, { code: fixtures.CONDITIONAL_CJS_REQUIREJS, errors: [ERROR] }, { code: fixtures.CONDITIONAL_TERNARY_CJS_REQUIREJS, errors: [ERROR, ERROR] }, { code: fixtures.CONDITIONAL_NESTED_AMD_REQUIREJS, errors: [ERROR] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-dynamic-require.js000066400000000000000000000047411344425206400254360ustar00rootroot00000000000000/** * @file Tests for `no-dynamic-require` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-dynamic-require"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR = { message: "Dynamic `require` calls are not allowed.", type: "CallExpression" }; testRule("no-dynamic-require", rule, { valid: [ fixtures.AMD_REQUIRE, fixtures.AMD_REQUIRE_RELATIVE, fixtures.AMD_EMPTY_REQUIRE, fixtures.AMD_REQUIRE_WITH_ERRBACK, fixtures.AMD_REQUIREJS, fixtures.AMD_REQUIREJS_RELATIVE, fixtures.AMD_EMPTY_REQUIREJS, fixtures.AMD_REQUIREJS_WITH_ERRBACK, fixtures.NESTED_AMD_REQUIRE, fixtures.NESTED_AMD_REQUIREJS, fixtures.NESTED_AMD_REQUIRE_NO_CALLBACK, fixtures.NESTED_AMD_REQUIREJS_NO_CALLBACK, fixtures.CJS_WITH_RETURN, fixtures.CJS_WITH_EXPORTS, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.NAMED_CJS_DEFINE, fixtures.CONDITIONAL_AMD_REQUIRE, fixtures.CONDITIONAL_CJS_REQUIRE, fixtures.CONDITIONAL_TERNARY_CJS_REQUIRE, fixtures.CONDITIONAL_NESTED_AMD_REQUIRE, fixtures.CONDITIONAL_AMD_REQUIREJS, fixtures.CONDITIONAL_CJS_REQUIREJS, fixtures.CONDITIONAL_TERNARY_CJS_REQUIREJS, fixtures.CONDITIONAL_NESTED_AMD_REQUIREJS ], invalid: [ { code: fixtures.DYNAMIC_MIXED_AMD_REQUIRE, errors: [ERROR] }, { code: fixtures.DYNAMIC_TERNARY_AMD_REQUIRE, errors: [ERROR] }, { code: fixtures.DYNAMIC_VARIABLE_AMD_REQUIRE, errors: [ERROR] }, { code: fixtures.DYNAMIC_TERNARY_CJS_REQUIRE, errors: [ERROR] }, { code: fixtures.DYNAMIC_VARIABLE_CJS_REQUIRE, errors: [ERROR] }, { code: fixtures.DYNAMIC_AMD_REQUIRE_WITH_ERRBACK, errors: [ERROR] }, { code: fixtures.DYNAMIC_MIXED_AMD_REQUIREJS, errors: [ERROR] }, { code: fixtures.DYNAMIC_TERNARY_AMD_REQUIREJS, errors: [ERROR] }, { code: fixtures.DYNAMIC_VARIABLE_AMD_REQUIREJS, errors: [ERROR] }, { code: fixtures.DYNAMIC_TERNARY_CJS_REQUIREJS, errors: [ERROR] }, { code: fixtures.DYNAMIC_VARIABLE_CJS_REQUIREJS, errors: [ERROR] }, { code: fixtures.DYNAMIC_AMD_REQUIREJS_WITH_ERRBACK, errors: [ERROR] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-function-define.js000066400000000000000000000021421344425206400254060ustar00rootroot00000000000000/** * @file Tests for `no-function-define` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-function-define"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR = { message: "Simple function form of `define` is not allowed", type: "CallExpression" }; testRule("no-function-define", rule, { valid: [ fixtures.OBJECT_DEFINE, fixtures.CJS_WITH_RETURN, fixtures.CJS_WITH_EXPORTS, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.AMD_DEFINE, fixtures.AMD_EMPTY_DEFINE, fixtures.NAMED_OBJECT_DEFINE, fixtures.NAMED_AMD_DEFINE, fixtures.NAMED_AMD_EMPTY_DEFINE, fixtures.NAMED_CJS_DEFINE ], invalid: [ { code: fixtures.FUNCTION_DEFINE, errors: [ERROR] }, { code: fixtures.NAMED_FUNCTION_DEFINE, errors: [ERROR] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-invalid-define.js000066400000000000000000000022051344425206400252070ustar00rootroot00000000000000/** * @file Tests for `no-invalid-define` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-invalid-define"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR = { message: "Invalid module definition", type: "CallExpression" }; testRule("no-invalid-define", rule, { valid: [ fixtures.OBJECT_DEFINE, fixtures.FUNCTION_DEFINE, fixtures.CJS_WITH_RETURN, fixtures.CJS_WITH_EXPORTS, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.AMD_DEFINE, fixtures.AMD_EMPTY_DEFINE, fixtures.NAMED_OBJECT_DEFINE, fixtures.NAMED_FUNCTION_DEFINE, fixtures.NAMED_AMD_DEFINE, fixtures.NAMED_AMD_EMPTY_DEFINE, fixtures.NAMED_CJS_DEFINE ], invalid: [ { code: fixtures.EMPTY_DEFINE, errors: [ERROR] }, { code: fixtures.BAD_DEFINE, errors: [ERROR] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-invalid-require.js000066400000000000000000000057401344425206400254400ustar00rootroot00000000000000/** * @file Tests for `no-invalid-require` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-invalid-require"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR = { message: "Invalid arguments provided to `require` call.", type: "CallExpression" }; testRule("no-invalid-require", rule, { valid: [ fixtures.AMD_REQUIRE, fixtures.AMD_REQUIRE_RELATIVE, fixtures.AMD_REQUIRE_WITH_ERRBACK, fixtures.AMD_REQUIRE_CALLEXPRESSION_CALLBACK, fixtures.AMD_REQUIRE_MEMBEREXPRESSION_CALLBACK, fixtures.AMD_REQUIRE_IDENTIFIER_CALLBACK, fixtures.AMD_REQUIREJS, fixtures.AMD_REQUIREJS_RELATIVE, fixtures.AMD_REQUIREJS_WITH_ERRBACK, fixtures.AMD_REQUIREJS_CALLEXPRESSION_CALLBACK, fixtures.AMD_REQUIREJS_MEMBEREXPRESSION_CALLBACK, fixtures.AMD_REQUIREJS_IDENTIFIER_CALLBACK, fixtures.CJS_WITH_EXPORTS, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.CJS_WITH_RETURN, fixtures.CONDITIONAL_AMD_REQUIRE, fixtures.CONDITIONAL_AMD_REQUIREJS, fixtures.CONDITIONAL_CJS_REQUIRE, fixtures.CONDITIONAL_CJS_REQUIREJS, fixtures.CONDITIONAL_NESTED_AMD_REQUIRE, fixtures.CONDITIONAL_NESTED_AMD_REQUIREJS, fixtures.CONDITIONAL_TERNARY_CJS_REQUIRE, fixtures.CONDITIONAL_TERNARY_CJS_REQUIREJS, fixtures.DYNAMIC_AMD_REQUIRE_WITH_ERRBACK, fixtures.DYNAMIC_AMD_REQUIREJS_WITH_ERRBACK, fixtures.DYNAMIC_MIXED_AMD_REQUIRE, fixtures.DYNAMIC_MIXED_AMD_REQUIREJS, fixtures.DYNAMIC_TERNARY_AMD_REQUIRE, fixtures.DYNAMIC_TERNARY_AMD_REQUIREJS, fixtures.DYNAMIC_VARIABLE_AMD_REQUIRE, fixtures.DYNAMIC_VARIABLE_AMD_REQUIREJS, fixtures.DYNAMIC_VARIABLE_CJS_REQUIRE, fixtures.DYNAMIC_VARIABLE_CJS_REQUIREJS, fixtures.NESTED_AMD_REQUIRE, fixtures.NESTED_AMD_REQUIREJS, fixtures.NESTED_AMD_REQUIRE_NO_CALLBACK, fixtures.NESTED_AMD_REQUIREJS_NO_CALLBACK ], invalid: [ { code: fixtures.BAD_REQUIRE_EMPTY, errors: [ERROR] }, { code: fixtures.BAD_REQUIRE_NO_DEPS, errors: [ERROR] }, { code: fixtures.BAD_REQUIRE_OBJECT, errors: [ERROR] }, { code: fixtures.BAD_REQUIRE_TOO_MANY_ARGS, errors: [ERROR] }, { code: fixtures.BAD_REQUIRE_STRING_DEP, errors: [ERROR] }, { code: fixtures.BAD_REQUIREJS_STRING_DEP, errors: [ERROR] }, { code: fixtures.BAD_REQUIRE_INVALID_CALLBACK, errors: [ERROR] }, { code: fixtures.BAD_REQUIRE_INVALID_CALLBACK_ARRAY, errors: [ERROR] }, { code: fixtures.BAD_REQUIRE_INVALID_ERRBACK, errors: [ERROR] }, { code: fixtures.BAD_REQUIRE_INVALID_ERRBACK_ARRAY, errors: [ERROR] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-js-extension.js000066400000000000000000000107701344425206400247650ustar00rootroot00000000000000/** * @file Tests for `no-js-extension` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-js-extension"); // ----------------------------------------------------------------------------- // Fixtures // ----------------------------------------------------------------------------- const NON_REQUIREJS_DEFINE_WITH_JS_EXT = ` module([ 'aaa.js' ], function () { /* ... */ }); `; // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR = { message: "Don't use .js extension in dependency path.", type: "Literal" }; testRule("no-js-extension", rule, { valid: [ fixtures.BAD_REQUIRE_EMPTY, fixtures.AMD_DEFINE, fixtures.AMD_EMPTY_DEFINE, fixtures.AMD_EMPTY_REQUIRE, fixtures.AMD_EMPTY_REQUIREJS, fixtures.AMD_REQUIRE, fixtures.AMD_REQUIRE_RELATIVE, fixtures.AMD_REQUIRE_WITH_ERRBACK, fixtures.AMD_REQUIREJS, fixtures.AMD_REQUIREJS_RELATIVE, fixtures.AMD_REQUIREJS_WITH_ERRBACK, fixtures.CJS_WITH_EXPORTS, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.CJS_WITH_RETURN, fixtures.NAMED_AMD_DEFINE, fixtures.NAMED_AMD_EMPTY_DEFINE, fixtures.NAMED_CJS_DEFINE, fixtures.DYNAMIC_AMD_REQUIRE_WITH_ERRBACK, fixtures.DYNAMIC_AMD_REQUIREJS_WITH_ERRBACK, fixtures.DYNAMIC_MIXED_AMD_REQUIRE, fixtures.DYNAMIC_MIXED_AMD_REQUIREJS, fixtures.DYNAMIC_TERNARY_AMD_REQUIRE, fixtures.DYNAMIC_TERNARY_AMD_REQUIREJS, fixtures.DYNAMIC_TERNARY_CJS_REQUIRE, fixtures.DYNAMIC_TERNARY_CJS_REQUIREJS, fixtures.DYNAMIC_VARIABLE_AMD_REQUIRE, fixtures.DYNAMIC_VARIABLE_AMD_REQUIREJS, fixtures.DYNAMIC_VARIABLE_CJS_REQUIRE, fixtures.DYNAMIC_VARIABLE_CJS_REQUIREJS, fixtures.CONDITIONAL_AMD_REQUIRE, fixtures.CONDITIONAL_AMD_REQUIREJS, fixtures.CONDITIONAL_CJS_REQUIRE, fixtures.CONDITIONAL_CJS_REQUIREJS, fixtures.CONDITIONAL_NESTED_AMD_REQUIRE, fixtures.CONDITIONAL_NESTED_AMD_REQUIREJS, fixtures.CONDITIONAL_TERNARY_CJS_REQUIRE, fixtures.CONDITIONAL_TERNARY_CJS_REQUIREJS, NON_REQUIREJS_DEFINE_WITH_JS_EXT, // plugins check fixtures.AMD_DEFINE_WITH_FOO_PLUGIN_AND_JS_EXT, fixtures.AMD_REQUIRE_WITH_FOO_PLUGIN_AND_JS_EXT, fixtures.AMD_REQUIREJS_WITH_FOO_PLUGIN_AND_JS_EXT, fixtures.CJS_WITH_FOO_PLUGIN_AND_JS_EXT ], invalid: [ { code: fixtures.AMD_REQUIRE_WITH_JS_EXT, errors: [ERROR] }, { code: fixtures.AMD_REQUIREJS_WITH_JS_EXT, errors: [ERROR] }, { code: fixtures.AMD_REQUIRE_RELATIVE_WITH_JS_EXT, errors: [ERROR] }, { code: fixtures.AMD_DEFINE_WITH_JS_EXT, errors: [ERROR] }, { code: fixtures.CJS_WITH_JS_EXT, errors: [ERROR] }, { code: fixtures.NAMED_AMD_DEFINE_WITH_JS_EXT, errors: [ERROR] }, { code: fixtures.NAMED_CJS_DEFINE_WITH_JS_EXT, errors: [ERROR] }, // one plugin check { code: fixtures.AMD_DEFINE_WITH_FOO_PLUGIN_AND_JS_EXT, options: [[ "foo" ]], errors: [ERROR] }, { code: fixtures.AMD_REQUIRE_WITH_FOO_PLUGIN_AND_JS_EXT, options: [[ "foo" ]], errors: [ERROR] }, { code: fixtures.AMD_REQUIREJS_WITH_FOO_PLUGIN_AND_JS_EXT, options: [[ "foo" ]], errors: [ERROR] }, { code: fixtures.CJS_WITH_FOO_PLUGIN_AND_JS_EXT, options: [[ "foo" ]], errors: [ERROR] }, // more plugins check { code: fixtures.AMD_DEFINE_WITH_FOO_PLUGIN_AND_JS_EXT, options: [[ "more", "plugins", "foo" ]], errors: [ERROR] }, { code: fixtures.AMD_REQUIRE_WITH_FOO_PLUGIN_AND_JS_EXT, options: [[ "more", "plugins", "foo" ]], errors: [ERROR] }, { code: fixtures.AMD_REQUIREJS_WITH_FOO_PLUGIN_AND_JS_EXT, options: [[ "more", "plugins", "foo" ]], errors: [ERROR] }, { code: fixtures.CJS_WITH_FOO_PLUGIN_AND_JS_EXT, options: [[ "more", "plugins", "foo" ]], errors: [ERROR] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-multiple-define.js000066400000000000000000000027271344425206400254250ustar00rootroot00000000000000/** * @file Tests for `no-multiple-define` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-multiple-define"); // ----------------------------------------------------------------------------- // Fixtures // ----------------------------------------------------------------------------- const MULTIPLE_DEFINE_ONE_CALL = ` if (typeof define === "function") { define(function () { return { foo: 'bar' }; }); } `; // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- testRule("no-multiple-define", rule, { valid: [ fixtures.OBJECT_DEFINE, fixtures.FUNCTION_DEFINE, fixtures.CJS_WITH_RETURN, fixtures.CJS_WITH_EXPORTS, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.AMD_DEFINE, fixtures.AMD_EMPTY_DEFINE, fixtures.NAMED_AMD_DEFINE, fixtures.NAMED_AMD_EMPTY_DEFINE, MULTIPLE_DEFINE_ONE_CALL ], invalid: [ { code: fixtures.MULTIPLE_DEFINE, errors: [{ message: "Multiple `define` calls in a single file are not permitted", type: "CallExpression", line: 4, column: 1 }] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-named-define.js000066400000000000000000000022471344425206400246530ustar00rootroot00000000000000/** * @file Tests for `no-named-define` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-named-define"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR = { message: "Named module form of `define` is not allowed", type: "CallExpression" }; testRule("no-named-define", rule, { valid: [ fixtures.OBJECT_DEFINE, fixtures.FUNCTION_DEFINE, fixtures.CJS_WITH_RETURN, fixtures.CJS_WITH_EXPORTS, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.AMD_DEFINE, fixtures.AMD_EMPTY_DEFINE ], invalid: [ { code: fixtures.NAMED_OBJECT_DEFINE, errors: [ERROR] }, { code: fixtures.NAMED_FUNCTION_DEFINE, errors: [ERROR] }, { code: fixtures.NAMED_AMD_DEFINE, errors: [ERROR] }, { code: fixtures.NAMED_AMD_EMPTY_DEFINE, errors: [ERROR] }, { code: fixtures.NAMED_CJS_DEFINE, errors: [ERROR] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-object-define.js000066400000000000000000000021441344425206400250310ustar00rootroot00000000000000/** * @file Tests for `no-object-define` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-object-define"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ERROR = { message: "Simple Name/Value Pairs form of `define` is not allowed", type: "CallExpression" }; testRule("no-object-define", rule, { valid: [ fixtures.FUNCTION_DEFINE, fixtures.CJS_WITH_RETURN, fixtures.CJS_WITH_EXPORTS, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.AMD_DEFINE, fixtures.AMD_EMPTY_DEFINE, fixtures.NAMED_FUNCTION_DEFINE, fixtures.NAMED_AMD_DEFINE, fixtures.NAMED_AMD_EMPTY_DEFINE, fixtures.NAMED_CJS_DEFINE ], invalid: [ { code: fixtures.OBJECT_DEFINE, errors: [ERROR] }, { code: fixtures.NAMED_OBJECT_DEFINE, errors: [ERROR] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-require-tourl.js000066400000000000000000000043501344425206400251530ustar00rootroot00000000000000/** * @file Tests for `no-require-tourl` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const util = require("util"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-require-tourl"); // ----------------------------------------------------------------------------- // Fixtures // ----------------------------------------------------------------------------- const REQUIREJS_NAME_TO_URL = ` define(['require'], function (require) { var idUrl = requirejs.nameToUrl('id'); }); `; const REQUIREJS_TO_URL = ` define(['require'], function (require) { var cssUrl = requirejs.toUrl('./style.css'); }); `; const REQUIRE_NAME_TO_URL = ` define(['require'], function (require) { var idUrl = require.nameToUrl('id'); }); `; const REQUIRE_TO_URL = ` define(['require'], function (require) { var cssUrl = require.toUrl('./style.css'); }); `; // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const MESSAGE = "Use of `require.%s` is not allowed."; testRule("no-require-tourl", rule, { valid: [ fixtures.AMD_REQUIRE_RELATIVE, fixtures.CJS_WITH_RETURN, fixtures.CJS_WITH_EXPORTS, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.NAMED_CJS_DEFINE ], invalid: [ { code: REQUIRE_TO_URL, errors: [{ message: util.format(MESSAGE, "toUrl"), type: "CallExpression" }] }, { code: REQUIREJS_TO_URL, errors: [{ message: util.format(MESSAGE, "toUrl"), type: "CallExpression" }] }, { code: REQUIRE_NAME_TO_URL, errors: [{ message: util.format(MESSAGE, "nameToUrl"), type: "CallExpression" }] }, { code: REQUIREJS_NAME_TO_URL, errors: [{ message: util.format(MESSAGE, "nameToUrl"), type: "CallExpression" }] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/no-restricted-amd-modules.js000066400000000000000000000115071344425206400267130ustar00rootroot00000000000000/** * @file Tests for `no-restricted-amd-modules` rule * @author Stefan Buck */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/no-restricted-amd-modules"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const errorMsg = expected => ({ message: `'${expected}' module is restricted from being used.`, type: "Literal" }); testRule("no-restricted-amd-modules", rule, { valid: [ { code: fixtures.AMD_DEFINE, options: ["foo"] }, { code: fixtures.FUNCTION_DEFINE, options: ["foo", "bar"] }, { code: fixtures.AMD_DEFINE, options: ["foo", "bar"] }, fixtures.AMD_DEFINE, { code: fixtures.AMD_DEFINE_WITH_FOO_PLUGIN_AND_JS_EXT, options: ["foo"] }, { code: fixtures.AMD_DEFINE_WITH_JS_EXT, options: ["foo"] }, { code: fixtures.AMD_EMPTY_DEFINE, options: ["foo"] }, { code: fixtures.AMD_DEFINE, options: ["path/to"] }, { code: fixtures.AMD_DEFINE, options: [{ paths: ["path", "to", "a"] }] }, { code: fixtures.AMD_DEFINE, options: [{ patterns: ["path/to/c*"] }] }, { code: fixtures.AMD_DEFINE, options: [{ paths: ["path/to"], patterns: ["path/to/c*"] }] }, { code: fixtures.AMD_DEFINE_WITH_JS_EXT, options: [ { paths: ["path/to"], patterns: ["path/to/*", "!path/to/a.js"] } ] } ], invalid: [ { code: fixtures.AMD_DEFINE, options: ["path/to/a"], errors: [errorMsg("path/to/a")] }, { code: fixtures.AMD_DEFINE, options: ["path/to/b"], errors: [errorMsg("path/to/b")] }, { code: fixtures.AMD_DEFINE_WITH_JS_EXT, options: [{ paths: ["path/to/a.js"] }], errors: [errorMsg("path/to/a.js")] }, { code: fixtures.AMD_DEFINE_WITH_FOO_PLUGIN_AND_JS_EXT, options: [{ paths: ["foo!aaa/bbb/ccc.js"] }], errors: [errorMsg("foo!aaa/bbb/ccc.js")] }, { code: fixtures.AMD_DEFINE_WITH_FOO_PLUGIN_AND_JS_EXT, options: [{ patterns: ["*!aaa/bbb/ccc.js"] }], errors: [ { message: "'foo!aaa/bbb/ccc.js' module is restricted from being used by a pattern.", type: "CallExpression" } ] }, { code: fixtures.AMD_DEFINE, options: [{ patterns: ["path/to/*"] }], errors: [ { message: "'path/to/a' module is restricted from being used by a pattern.", type: "CallExpression" } ] }, { code: fixtures.AMD_DEFINE, options: [{ paths: ["path/to/*"], patterns: ["path/to"] }], errors: [ { message: "'path/to/a' module is restricted from being used by a pattern.", type: "CallExpression" } ] }, { code: fixtures.AMD_DEFINE, options: [ { patterns: ["path/to/*", "!path/to/c"], paths: ["path/to"] } ], errors: [ { message: "'path/to/a' module is restricted from being used by a pattern.", type: "CallExpression" } ] }, { code: fixtures.AMD_DEFINE, options: [ { name: "path/to/a", message: "Please use 'path/to/c' module instead." } ], errors: [ { message: "'path/to/a' module is restricted from being used. Please use 'path/to/c' module instead.", type: "Literal" } ] }, { code: fixtures.AMD_DEFINE, options: [ "path/to", { name: "path/to/a", message: "Please use 'path/to/c' module instead." }, "path/to/d" ], errors: [ { message: "'path/to/a' module is restricted from being used. Please use 'path/to/c' module instead.", type: "Literal" } ] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/one-dependency-per-line.js000066400000000000000000000303441344425206400263320ustar00rootroot00000000000000/** * @file Tests for `one-dependency-per-line` rule * @author Casey Visco */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/one-dependency-per-line"); // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const ALWAYS_PATHS_ERROR = { message: "Only one dependency path is permitted per line.", type: "ArrayExpression" }; const ALWAYS_NAMES_ERROR = { message: "Only one dependency name is permitted per line.", type: "FunctionExpression" }; const NEVER_PATHS_ERROR = { message: "Dependency paths must appear on one line.", type: "ArrayExpression" }; const NEVER_NAMES_ERROR = { message: "Dependency names must appear on one line.", type: "FunctionExpression" }; testRule("one-dependency-per-line", rule, { valid: [ // Should ignore irrelevant or malformed definitions fixtures.FUNCTION_DEFINE, fixtures.EMPTY_DEFINE, fixtures.OBJECT_DEFINE, fixtures.CJS_WITH_RETURN, fixtures.BAD_DEFINE, fixtures.BAD_REQUIRE_EMPTY, fixtures.BAD_REQUIRE_INVALID_CALLBACK, fixtures.BAD_REQUIRE_NO_DEPS, fixtures.BAD_REQUIRE_OBJECT, fixtures.BAD_REQUIRE_STRING_DEP, fixtures.BAD_REQUIREJS_STRING_DEP, { code: fixtures.DEFINE_WITH_ARROW_FUNCTION, parserOptions: { ecmaVersion: 6 } }, // zero deps should never trigger warning, regardless of options { code: fixtures.AMD_DEPS_NONE, options: [{}] }, { code: fixtures.AMD_DEPS_NONE, options: [{ "paths": "never" }] }, { code: fixtures.AMD_DEPS_NONE, options: [{ "names": "never" }] }, // Default options: "always" for both { code: fixtures.AMD_DEPS_MULTI_LINE_ONE, options: [{}] }, { code: fixtures.AMD_DEPS_MULTI_LINE_TWO, options: [{}] }, { code: fixtures.AMD_DEPS_MULTI_LINE_THREE, options: [{}] }, { code: fixtures.AMD_DEPS_MULTI_LINE_FOUR, options: [{}] }, // "never" for both { code: fixtures.AMD_DEPS_SINGLE_LINE_ONE, options: [{ "paths": "never", "names": "never" }] }, { code: fixtures.AMD_DEPS_SINGLE_LINE_TWO, options: [{ "paths": "never", "names": "never" }] }, { code: fixtures.AMD_DEPS_SINGLE_LINE_THREE, options: [{ "paths": "never", "names": "never" }] }, { code: fixtures.AMD_DEPS_SINGLE_LINE_FOUR, options: [{ "paths": "never", "names": "never" }] }, // "never" for names { code: fixtures.AMD_DEPS_MULTI_LINE_PATHS_ONE, options: [{ "names": "never" }] }, { code: fixtures.AMD_DEPS_MULTI_LINE_PATHS_TWO, options: [{ "names": "never" }] }, { code: fixtures.AMD_DEPS_MULTI_LINE_PATHS_THREE, options: [{ "names": "never" }] }, { code: fixtures.AMD_DEPS_MULTI_LINE_PATHS_FOUR, options: [{ "names": "never" }] }, // "never" for paths { code: fixtures.AMD_DEPS_MULTI_LINE_NAMES_ONE, options: [{ "paths": "never" }] }, { code: fixtures.AMD_DEPS_MULTI_LINE_NAMES_TWO, options: [{ "paths": "never" }] }, { code: fixtures.AMD_DEPS_MULTI_LINE_NAMES_THREE, options: [{ "paths": "never" }] }, { code: fixtures.AMD_DEPS_MULTI_LINE_NAMES_FOUR, options: [{ "paths": "never" }] }, // Minimum values should not warn on fewer dependencies { code: fixtures.AMD_DEPS_SINGLE_LINE_ONE, options: [{ "paths": 2, "names": 2 }] }, { code: fixtures.AMD_DEPS_SINGLE_LINE_TWO, options: [{ "paths": 2, "names": 2 }] }, { code: fixtures.AMD_DEPS_SINGLE_LINE_ONE, options: [{ "paths": 2, "names": 2 }] }, { code: fixtures.AMD_DEPS_SINGLE_LINE_TWO, options: [{ "paths": 2, "names": 2 }] }, { code: fixtures.AMD_DEPS_MULTI_LINE_PATHS_ONE, options: [{ "paths": "always", "names": 2 }] }, { code: fixtures.AMD_DEPS_MULTI_LINE_PATHS_TWO, options: [{ "paths": "always", "names": 2 }] }, { code: fixtures.AMD_DEPS_MULTI_LINE_NAMES_ONE, options: [{ "paths": 2, "names": "always" }] }, { code: fixtures.AMD_DEPS_MULTI_LINE_NAMES_TWO, options: [{ "paths": 2, "names": "always" }] } ], invalid: [ // Default options: "always" for both { code: fixtures.AMD_DEPS_SINGLE_LINE_TWO, options: [{}], errors: [ ALWAYS_PATHS_ERROR, ALWAYS_NAMES_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_TWO }, { code: fixtures.AMD_DEPS_SINGLE_LINE_THREE, options: [{}], errors: [ ALWAYS_PATHS_ERROR, ALWAYS_NAMES_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_THREE }, { code: fixtures.AMD_DEPS_SINGLE_LINE_FOUR, options: [{}], errors: [ ALWAYS_PATHS_ERROR, ALWAYS_NAMES_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_FOUR }, { code: fixtures.AMD_DEPS_MULTI_LINE_NAMES_TWO, options: [{}], errors: [ ALWAYS_PATHS_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_TWO }, { code: fixtures.AMD_DEPS_MULTI_LINE_NAMES_THREE, options: [{}], errors: [ ALWAYS_PATHS_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_THREE }, { code: fixtures.AMD_DEPS_MULTI_LINE_NAMES_FOUR, options: [{}], errors: [ ALWAYS_PATHS_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_FOUR }, { code: fixtures.AMD_DEPS_MULTI_LINE_PATHS_TWO, options: [{}], errors: [ ALWAYS_NAMES_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_TWO }, { code: fixtures.AMD_DEPS_MULTI_LINE_PATHS_THREE, options: [{}], errors: [ ALWAYS_NAMES_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_THREE }, { code: fixtures.AMD_DEPS_MULTI_LINE_PATHS_FOUR, options: [{}], errors: [ ALWAYS_NAMES_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_FOUR }, { code: fixtures.AMD_DEPS_SINGLE_LINE_NO_INDENT_TWO, options: [{}], errors: [ ALWAYS_PATHS_ERROR, ALWAYS_NAMES_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_NO_INDENT_TWO }, { code: fixtures.AMD_DEPS_SINGLE_LINE_NO_INDENT_THREE, options: [{}], errors: [ ALWAYS_PATHS_ERROR, ALWAYS_NAMES_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_NO_INDENT_THREE }, { code: fixtures.AMD_DEPS_SINGLE_LINE_NO_INDENT_FOUR, options: [{}], errors: [ ALWAYS_PATHS_ERROR, ALWAYS_NAMES_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_NO_INDENT_FOUR }, // "always" for paths only { code: fixtures.AMD_DEPS_SINGLE_LINE_TWO, options: [{"names": "never"}], errors: [ ALWAYS_PATHS_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_PATHS_TWO }, { code: fixtures.AMD_DEPS_SINGLE_LINE_THREE, options: [{"names": "never"}], errors: [ ALWAYS_PATHS_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_PATHS_THREE }, { code: fixtures.AMD_DEPS_SINGLE_LINE_FOUR, options: [{"names": "never"}], errors: [ ALWAYS_PATHS_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_PATHS_FOUR }, // "always" for names only { code: fixtures.AMD_DEPS_SINGLE_LINE_TWO, options: [{"paths": "never"}], errors: [ ALWAYS_NAMES_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_NAMES_TWO }, { code: fixtures.AMD_DEPS_SINGLE_LINE_THREE, options: [{"paths": "never"}], errors: [ ALWAYS_NAMES_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_NAMES_THREE }, { code: fixtures.AMD_DEPS_SINGLE_LINE_FOUR, options: [{"paths": "never"}], errors: [ ALWAYS_NAMES_ERROR ], output: fixtures.AMD_DEPS_MULTI_LINE_NAMES_FOUR }, // "never" for both { code: fixtures.AMD_DEPS_MULTI_LINE_TWO, options: [{ "paths": "never", "names": "never" }], errors: [ NEVER_PATHS_ERROR, NEVER_NAMES_ERROR ] }, { code: fixtures.AMD_DEPS_MULTI_LINE_THREE, options: [{ "paths": "never", "names": "never" }], errors: [ NEVER_PATHS_ERROR, NEVER_NAMES_ERROR ] }, { code: fixtures.AMD_DEPS_MULTI_LINE_FOUR, options: [{ "paths": "never", "names": "never" }], errors: [ NEVER_PATHS_ERROR, NEVER_NAMES_ERROR ] }, { code: fixtures.AMD_DEPS_MULTI_LINE_PATHS_TWO, options: [{ "paths": "never", "names": "never" }], errors: [ NEVER_PATHS_ERROR ] }, { code: fixtures.AMD_DEPS_MULTI_LINE_PATHS_THREE, options: [{ "paths": "never", "names": "never" }], errors: [ NEVER_PATHS_ERROR ] }, { code: fixtures.AMD_DEPS_MULTI_LINE_PATHS_FOUR, options: [{ "paths": "never", "names": "never" }], errors: [ NEVER_PATHS_ERROR ] }, { code: fixtures.AMD_DEPS_MULTI_LINE_NAMES_TWO, options: [{ "paths": "never", "names": "never" }], errors: [ NEVER_NAMES_ERROR ] }, { code: fixtures.AMD_DEPS_MULTI_LINE_NAMES_THREE, options: [{ "paths": "never", "names": "never" }], errors: [ NEVER_NAMES_ERROR ] }, { code: fixtures.AMD_DEPS_MULTI_LINE_NAMES_FOUR, options: [{ "paths": "never", "names": "never" }], errors: [ NEVER_NAMES_ERROR ] }, // Minimum values should warn when threshold exceeded { code: fixtures.AMD_DEPS_SINGLE_LINE_THREE, options: [{ "paths": 2, "names": 2 }], errors: [ ALWAYS_PATHS_ERROR, ALWAYS_NAMES_ERROR ] }, { code: fixtures.AMD_DEPS_SINGLE_LINE_FOUR, options: [{ "paths": 2, "names": 2 }], errors: [ ALWAYS_PATHS_ERROR, ALWAYS_NAMES_ERROR ] }, { code: fixtures.AMD_DEPS_SINGLE_LINE_THREE, options: [{ "paths": 2, "names": 2 }], errors: [ ALWAYS_PATHS_ERROR, ALWAYS_NAMES_ERROR ] }, { code: fixtures.AMD_DEPS_SINGLE_LINE_FOUR, options: [{ "paths": 2, "names": 2 }], errors: [ ALWAYS_PATHS_ERROR, ALWAYS_NAMES_ERROR ] }, { code: fixtures.AMD_DEPS_MULTI_LINE_PATHS_THREE, options: [{ "paths": "always", "names": 2 }], errors: [ ALWAYS_NAMES_ERROR ] }, { code: fixtures.AMD_DEPS_MULTI_LINE_PATHS_FOUR, options: [{ "paths": "always", "names": 2 }], errors: [ ALWAYS_NAMES_ERROR ] }, { code: fixtures.AMD_DEPS_MULTI_LINE_NAMES_THREE, options: [{ "paths": 2, "names": "always" }], errors: [ ALWAYS_PATHS_ERROR ] }, { code: fixtures.AMD_DEPS_MULTI_LINE_NAMES_FOUR, options: [{ "paths": 2, "names": "always" }], errors: [ ALWAYS_PATHS_ERROR ] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/rules/sort-amd-paths.js000066400000000000000000000456531344425206400246000ustar00rootroot00000000000000/** * @file Tests for `sort-amd-paths` rule * @author Ondřej Brejla */ "use strict"; const testRule = require("../../rule-tester"); const fixtures = require("../../fixtures"); const rule = require("../../../lib/rules/sort-amd-paths"); // ----------------------------------------------------------------------------- // Fixtures // ----------------------------------------------------------------------------- const BASENAME_CAPITAL = ` define([ 'aaa/bbb/Xxx', 'aaa/bbb/ccc/ddd' ], function (ccc, aaa) { /* ... */ }); `; const NO_PATH = ` define(function () { /* ... */ }); `; const ONE_PATH_IN_ARRAY = ` define([ 'foo/bar/baz' ], function (baz) { /* ... */ }); `; const MORE_PATHS_IN_ARRAY = ` define([ 'base.dt/js/DesignerUtils', 'components.dt/js/deleters/DeletersRegistry', 'core/js/api/Listenable', 'core/js/api/utils/KeyConstants', 'pages.dt/js/api/Pages', 'pages.dt/js/api/ViewGeneratorModes' ], function (aaa, ccc, ddd, bbb, yyy) { /* ... */ }); `; const FULLPATH_INVALID = ` define([ 'aaa/bbb/xxx', 'aaa/bbb/ccc/ddd' ], function (ccc, aaa) { /* ... */ }); `; const DIRNAME_WRONG_ORDER = ` define([ 'aaa/bbb/ccc/ddd/aaa', 'aaa/bbb/ccc/xxx' ], function (ccc, aaa) { /* ... */ }); `; const IGNORED_PATHS = ` define([ 'aaa/bbb/xxx', 'aaa/bbb/yyy', 'aaa/bbb/zzz', // following lines should be ignored 'aaa/bbb/aaa', 'aaa/bbb/bbb' ], function (xxx, yyy, zzz) { /* ... */ }); `; const SLASH_PUNC_VALID = ` define([ 'foo/bar/baz/Bat', 'foo-bar/baz/Bat', 'foo.bar/baz/Bat' ], function (bat1, bat2, bat3) { /* ... */ }); `; const PLUGIN_PRESERVE = ` define([ 'aaa/aaa/aaa', 'bbb!fff/fff/fff', 'ccc/ccc/ccc', 'ggg/ggg/ggg', 'hhh!ddd/ddd/ddd' ], function (aaa, fff, ccc, ggg, ddd) { /* ... */ }); `; const FULLPATH_VALID = ` define([ 'aaa/bbb/ccc/ddd', 'aaa/bbb/xxx' ], function (ccc, aaa) { /* ... */ }); `; const BASENAME_VALID_ORDER = ` define([ 'xxx/aaa', 'aaa/xxx' ], function (ccc, aaa) { /* ... */ }); `; const BASENAME_PLUGIN_PRESERVE_IGNORE = ` define([ 'awhat/ever1/aaa', 'cwhat/ever3/ccc', 'hhh!dwhat/ever5/ddd', 'bbb!fwhat/ever2/fff', 'gwhat/ever4/ggg' ], function (aaa, ccc, ddd, fff, ggg) { /* ... */ }); `; const PLUGIN_IGNORE = ` define([ 'aaa/aaa/aaa', 'ccc/ccc/ccc', 'bbb!fff/fff/fff1', 'bbb!fff/fff/fff2', 'ggg/ggg/ggg' ], function (aaa, ccc, fff1, fff2, ggg) { /* ... */ }); `; const PLUGIN_FIRST = ` define([ 'bbb!fff/fff/fff1', 'bbb!fff/fff/fff2', 'aaa/aaa/aaa', 'ccc/ccc/ccc', 'ggg/ggg/ggg' ], function (fff1, fff2, aaa, ccc, ggg) { /* ... */ }); `; const BASENAME_PLUGIN_FIRST = ` define([ 'hhh!dwhat/ever5/ddd', 'bbb!fwhat/ever2/fff', 'awhat/ever1/aaa', 'cwhat/ever3/ccc', 'gwhat/ever4/ggg' ], function (ddd, fff, aaa, ccc, ggg) { /* ... */ }); `; const PLUGIN_LAST = ` define([ 'aaa/aaa/aaa', 'ccc/ccc/ccc', 'ggg/ggg/ggg', 'bbb!fff/fff/fff1', 'bbb!fff/fff/fff2' ], function (aaa, ccc, ggg, fff1, fff2) { /* ... */ }); `; const BASENAME_PLUGIN_LAST = ` define([ 'awhat/ever1/aaa', 'cwhat/ever3/ccc', 'gwhat/ever4/ggg', 'hhh!dwhat/ever5/ddd', 'bbb!fwhat/ever2/fff' ], function (aaa, ccc, ggg, ddd, fff) { /* ... */ }); `; const INVALID_ORDER = ` define([ 'aaa/bbb/ccc', 'aaa/bbb/Aaa' ], function (ccc, aaa) { /* ... */ }); `; const SLASH_PUNC_INVALID = ` define([ 'foo.bar/baz/Bat', 'foo/bar/baz/Bat', 'foo-bar/baz/Bat' ], function (bat1, bat2, bat3) { /* ... */ }); `; const FIRST_LONGER_INVALID = ` define([ 'foo/bar/baz/Batttt', 'foo/bar/baz/Bat' ], function (bat1, bat2) { /* ... */ }); `; const BASENAME_INVALID_ORDER = ` define([ 'aaa/xxx', 'xxx/aaa' ], function (ccc, aaa) { /* ... */ }); `; const BASENAME_IDENTICAL = ` define([ 'aaa/xxx', 'bbb/xxx', 'ccc/xxx' ], function (ccc, aaa) { /* ... */ }); `; // ----------------------------------------------------------------------------- // Tests // ----------------------------------------------------------------------------- const errorMsg = (expected) => ({ message: `Required paths are not in alphabetical order (expected '${expected}').`, type: "Literal" }); testRule("sort-amd-paths", rule, { valid: [ fixtures.AMD_EMPTY_DEFINE, NO_PATH, ONE_PATH_IN_ARRAY, MORE_PATHS_IN_ARRAY, BASENAME_CAPITAL, FULLPATH_INVALID, IGNORED_PATHS, SLASH_PUNC_VALID, PLUGIN_PRESERVE, { code: fixtures.AMD_EMPTY_DEFINE, options: [{ compare: "dirname-basename" }] }, { code: NO_PATH, options: [{ compare: "dirname-basename" }] }, { code: ONE_PATH_IN_ARRAY, options: [{ compare: "dirname-basename" }] }, { code: MORE_PATHS_IN_ARRAY, options: [{ compare: "dirname-basename" }] }, { code: BASENAME_CAPITAL, options: [{ compare: "dirname-basename" }] }, { code: FULLPATH_INVALID, options: [{ compare: "dirname-basename" }] }, { code: PLUGIN_PRESERVE, options: [{ compare: "dirname-basename" }] }, { code: fixtures.AMD_EMPTY_DEFINE, options: [{ compare: "dirname-basename", ignoreCase: true }] }, { code: NO_PATH, options: [{ compare: "dirname-basename", ignoreCase: true }] }, { code: ONE_PATH_IN_ARRAY, options: [{ compare: "dirname-basename", ignoreCase: true }] }, { code: MORE_PATHS_IN_ARRAY, options: [{ compare: "dirname-basename", ignoreCase: true }] }, { code: BASENAME_CAPITAL, options: [{ compare: "dirname-basename", ignoreCase: true }] }, { code: FULLPATH_INVALID, options: [{ compare: "dirname-basename", ignoreCase: true }] }, { code: PLUGIN_PRESERVE, options: [{ compare: "dirname-basename", ignoreCase: true }] }, { code: fixtures.AMD_EMPTY_DEFINE, options: [{ compare: "dirname-basename", ignoreCase: false }] }, { code: NO_PATH, options: [{ compare: "dirname-basename", ignoreCase: false }] }, { code: ONE_PATH_IN_ARRAY, options: [{ compare: "dirname-basename", ignoreCase: false }] }, { code: BASENAME_CAPITAL, options: [{ compare: "dirname-basename", ignoreCase: false }] }, { code: FULLPATH_INVALID, options: [{ compare: "dirname-basename", ignoreCase: false }] }, { code: FULLPATH_VALID, options: [{ compare: "fullpath" }] }, { code: FULLPATH_VALID, options: [{ compare: "fullpath", ignoreCase: true }] }, { code: BASENAME_CAPITAL, options: [{ compare: "fullpath", ignoreCase: false }] }, { code: FULLPATH_VALID, options: [{ compare: "fullpath", ignoreCase: false }] }, { code: BASENAME_VALID_ORDER, options: [{ compare: "basename" }] }, { code: BASENAME_IDENTICAL, options: [{ compare: "basename" }] }, { code: BASENAME_VALID_ORDER, options: [{ compare: "basename", ignoreCase: true }] }, { code: BASENAME_VALID_ORDER, options: [{ compare: "basename", ignoreCase: false }] }, { code: BASENAME_CAPITAL, options: [{ compare: "basename", ignoreCase: false }] }, { code: PLUGIN_PRESERVE, options: [{ compare: "dirname-basename", sortPlugins: "preserve" }] }, { code: PLUGIN_PRESERVE, options: [{ compare: "fullpath", sortPlugins: "preserve" }] }, { code: BASENAME_PLUGIN_PRESERVE_IGNORE, options: [{ compare: "basename", sortPlugins: "preserve" }] }, { code: PLUGIN_IGNORE, options: [{ compare: "dirname-basename", sortPlugins: "ignore" }] }, { code: PLUGIN_IGNORE, options: [{ compare: "fullpath", sortPlugins: "ignore" }] }, { code: BASENAME_PLUGIN_PRESERVE_IGNORE, options: [{ compare: "basename", sortPlugins: "ignore" }] }, { code: PLUGIN_FIRST, options: [{ compare: "dirname-basename", sortPlugins: "first" }] }, { code: PLUGIN_FIRST, options: [{ compare: "fullpath", sortPlugins: "first" }] }, { code: BASENAME_PLUGIN_FIRST, options: [{ compare: "basename", sortPlugins: "first" }] }, { code: PLUGIN_LAST, options: [{ compare: "dirname-basename", sortPlugins: "last" }] }, { code: PLUGIN_LAST, options: [{ compare: "fullpath", sortPlugins: "last" }] }, { code: BASENAME_PLUGIN_LAST, options: [{ compare: "basename", sortPlugins: "last" }] }, fixtures.AMD_REQUIRE, fixtures.AMD_REQUIREJS, fixtures.CJS_WITH_RETURN, fixtures.CJS_WITH_EXPORTS, fixtures.CJS_WITH_MODULE_EXPORTS, fixtures.CJS_WITH_FUNC_EXPR, fixtures.CJS_WITH_INVALID_EXPORTS, fixtures.DYNAMIC_AMD_REQUIRE_WITH_ERRBACK, fixtures.DYNAMIC_AMD_REQUIREJS_WITH_ERRBACK ], invalid: [ { code: INVALID_ORDER, errors: [errorMsg("aaa/bbb/Aaa")] }, { code: SLASH_PUNC_INVALID, errors: [errorMsg("foo/bar/baz/Bat")] }, { code: FIRST_LONGER_INVALID, errors: [errorMsg("foo/bar/baz/Bat")] }, { code: PLUGIN_IGNORE, errors: [errorMsg("bbb!fff/fff/fff1")] }, { code: PLUGIN_FIRST, errors: [errorMsg("aaa/aaa/aaa")] }, { code: PLUGIN_LAST, errors: [errorMsg("bbb!fff/fff/fff1")] }, { code: INVALID_ORDER, options: [{ compare: "dirname-basename" }], errors: [errorMsg("aaa/bbb/Aaa")] }, { code: DIRNAME_WRONG_ORDER, options: [{ compare: "dirname-basename" }], errors: [errorMsg("aaa/bbb/ccc/xxx")] }, { code: INVALID_ORDER, options: [{ compare: "dirname-basename", ignoreCase: true }], errors: [errorMsg("aaa/bbb/Aaa")] }, { code: INVALID_ORDER, options: [{ compare: "dirname-basename", ignoreCase: false }], errors: [errorMsg("aaa/bbb/Aaa")] }, { code: FULLPATH_INVALID, options: [{ compare: "fullpath" }], errors: [errorMsg("aaa/bbb/ccc/ddd")] }, { code: BASENAME_CAPITAL, options: [{ compare: "fullpath" }], errors: [errorMsg("aaa/bbb/ccc/ddd")] }, { code: FULLPATH_INVALID, options: [{ compare: "fullpath", ignoreCase: true }], errors: [errorMsg("aaa/bbb/ccc/ddd")] }, { code: BASENAME_CAPITAL, options: [{ compare: "fullpath", ignoreCase: true }], errors: [errorMsg("aaa/bbb/ccc/ddd")] }, { code: FULLPATH_INVALID, options: [{ compare: "fullpath", ignoreCase: false }], errors: [errorMsg("aaa/bbb/ccc/ddd")] }, { code: INVALID_ORDER, options: [{ compare: "fullpath", ignoreCase: false }], errors: [errorMsg("aaa/bbb/Aaa")] }, { code: BASENAME_INVALID_ORDER, errors: [errorMsg("xxx/aaa")], options: [{ compare: "basename" }] }, { code: BASENAME_INVALID_ORDER, errors: [errorMsg("xxx/aaa")], options: [{ compare: "basename", ignoreCase: true }] }, { code: BASENAME_INVALID_ORDER, errors: [errorMsg("xxx/aaa")], options: [{ compare: "basename", ignoreCase: false }] }, { code: INVALID_ORDER, options: [{ compare: "basename", ignoreCase: false }], errors: [errorMsg("aaa/bbb/Aaa")] }, { code: PLUGIN_IGNORE, options: [{ compare: "dirname-basename", sortPlugins: "preserve" }], errors: [errorMsg("bbb!fff/fff/fff1")] }, { code: PLUGIN_FIRST, options: [{ compare: "dirname-basename", sortPlugins: "preserve" }], errors: [errorMsg("aaa/aaa/aaa")] }, { code: PLUGIN_LAST, options: [{ compare: "dirname-basename", sortPlugins: "preserve" }], errors: [errorMsg("bbb!fff/fff/fff1")] }, { code: PLUGIN_IGNORE, options: [{ compare: "fullpath", sortPlugins: "preserve" }], errors: [errorMsg("bbb!fff/fff/fff1")] }, { code: PLUGIN_FIRST, options: [{ compare: "fullpath", sortPlugins: "preserve" }], errors: [errorMsg("aaa/aaa/aaa")] }, { code: PLUGIN_LAST, options: [{ compare: "fullpath", sortPlugins: "preserve" }], errors: [errorMsg("bbb!fff/fff/fff1")] }, { code: BASENAME_PLUGIN_FIRST, options: [{ compare: "basename", sortPlugins: "preserve" }], errors: [errorMsg("awhat/ever1/aaa")] }, { code: BASENAME_PLUGIN_LAST, options: [{ compare: "basename", sortPlugins: "preserve" }], errors: [errorMsg("hhh!dwhat/ever5/ddd")] }, { code: PLUGIN_PRESERVE, options: [{ compare: "dirname-basename", sortPlugins: "ignore" }], errors: [errorMsg("ccc/ccc/ccc")] }, { code: PLUGIN_FIRST, options: [{ compare: "dirname-basename", sortPlugins: "ignore" }], errors: [errorMsg("aaa/aaa/aaa")] }, { code: PLUGIN_LAST, options: [{ compare: "dirname-basename", sortPlugins: "ignore" }], errors: [errorMsg("bbb!fff/fff/fff1")] }, { code: PLUGIN_PRESERVE, options: [{ compare: "fullpath", sortPlugins: "ignore" }], errors: [errorMsg("ccc/ccc/ccc")] }, { code: PLUGIN_FIRST, options: [{ compare: "fullpath", sortPlugins: "ignore" }], errors: [errorMsg("aaa/aaa/aaa")] }, { code: PLUGIN_LAST, options: [{ compare: "fullpath", sortPlugins: "ignore" }], errors: [errorMsg("bbb!fff/fff/fff1")] }, { code: BASENAME_PLUGIN_FIRST, options: [{ compare: "basename", sortPlugins: "ignore" }], errors: [errorMsg("awhat/ever1/aaa")] }, { code: BASENAME_PLUGIN_LAST, options: [{ compare: "basename", sortPlugins: "ignore" }], errors: [errorMsg("hhh!dwhat/ever5/ddd")] }, { code: PLUGIN_PRESERVE, options: [{ compare: "dirname-basename", sortPlugins: "first" }], errors: [errorMsg("bbb!fff/fff/fff")] }, { code: PLUGIN_IGNORE, options: [{ compare: "dirname-basename", sortPlugins: "first" }], errors: [errorMsg("bbb!fff/fff/fff1")] }, { code: PLUGIN_LAST, options: [{ compare: "dirname-basename", sortPlugins: "first" }], errors: [errorMsg("bbb!fff/fff/fff1")] }, { code: PLUGIN_PRESERVE, options: [{ compare: "fullpath", sortPlugins: "first" }], errors: [errorMsg("bbb!fff/fff/fff")] }, { code: PLUGIN_IGNORE, options: [{ compare: "fullpath", sortPlugins: "first" }], errors: [errorMsg("bbb!fff/fff/fff1")] }, { code: PLUGIN_LAST, options: [{ compare: "fullpath", sortPlugins: "first" }], errors: [errorMsg("bbb!fff/fff/fff1")] }, { code: BASENAME_PLUGIN_PRESERVE_IGNORE, options: [{ compare: "basename", sortPlugins: "first" }], errors: [errorMsg("hhh!dwhat/ever5/ddd")] }, { code: BASENAME_PLUGIN_LAST, options: [{ compare: "basename", sortPlugins: "first" }], errors: [errorMsg("hhh!dwhat/ever5/ddd")] }, { code: PLUGIN_PRESERVE, options: [{ compare: "dirname-basename", sortPlugins: "last" }], errors: [errorMsg("ccc/ccc/ccc")] }, { code: PLUGIN_IGNORE, options: [{ compare: "dirname-basename", sortPlugins: "last" }], errors: [errorMsg("ggg/ggg/ggg")] }, { code: PLUGIN_FIRST, options: [{ compare: "dirname-basename", sortPlugins: "last" }], errors: [errorMsg("aaa/aaa/aaa")] }, { code: PLUGIN_PRESERVE, options: [{ compare: "fullpath", sortPlugins: "last" }], errors: [errorMsg("ccc/ccc/ccc")] }, { code: PLUGIN_IGNORE, options: [{ compare: "fullpath", sortPlugins: "last" }], errors: [errorMsg("ggg/ggg/ggg")] }, { code: PLUGIN_FIRST, options: [{ compare: "fullpath", sortPlugins: "last" }], errors: [errorMsg("aaa/aaa/aaa")] }, { code: BASENAME_PLUGIN_PRESERVE_IGNORE, options: [{ compare: "basename", sortPlugins: "last" }], errors: [errorMsg("gwhat/ever4/ggg")] }, { code: BASENAME_PLUGIN_FIRST, options: [{ compare: "basename", sortPlugins: "last" }], errors: [errorMsg("awhat/ever1/aaa")] } ] }); eslint-plugin-requirejs-4.0.0/tests/lib/utils/000077500000000000000000000000001344425206400213705ustar00rootroot00000000000000eslint-plugin-requirejs-4.0.0/tests/lib/utils/ast.js000066400000000000000000000341661344425206400225270ustar00rootroot00000000000000/** * @file Tests for AST helper functions * @author Casey Visco */ "use strict"; const assert = require("assert"); const ast = require("../../../lib/utils/ast"); describe("ast.isIdentifier", function () { it("should return `false` if no argument is supplied", function () { const actual = ast.isIdentifier(); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node does not contain a `type` attribute", function () { const actual = ast.isIdentifier({}); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node contains a `type` other than `Identifier`", function () { const actual = ast.isIdentifier({ type: "Literal" }); const expected = false; assert.equal(actual, expected); }); it("should return `true` if supplied node is an Identifier", function () { const actual = ast.isIdentifier({ type: "Identifier" }); const expected = true; assert.equal(actual, expected); }); }); describe("ast.isLiteral", function () { it("should return `false` if no argument is supplied", function () { const actual = ast.isLiteral(); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node does not contain a `type` attribute", function () { const actual = ast.isLiteral({}); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node contains a `type` other than `Literal`", function () { const actual = ast.isLiteral({ type: "Identifier" }); const expected = false; assert.equal(actual, expected); }); it("should return `true` if supplied node is a `Literal`", function () { const actual = ast.isLiteral({ type: "Literal" }); const expected = true; assert.equal(actual, expected); }); }); describe("ast.isStringLiteral", function () { it("should return `false` if no argument is supplied", function () { const actual = ast.isStringLiteral(); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node does not contain a `type` attribute", function () { const actual = ast.isStringLiteral({}); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node does not contain a `value` attribute", function () { const actual = ast.isStringLiteral({ type: "Literal" }); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node contains a `type` other than `Literal`", function () { const actual = ast.isStringLiteral({ type: "Identifier" }); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node contains a `value` type other than `string`", function () { const actual = ast.isStringLiteral({ type: "Identifier", value: 5 }); const expected = false; assert.equal(actual, expected); }); it("should return `true` if supplied node is a `Literal` with a `string` value", function () { const actual = ast.isStringLiteral({ type: "Literal", value: "foobar" }); const expected = true; assert.equal(actual, expected); }); }); describe("ast.isArrayExpr", function () { it("should return `false` if no argument is supplied", function () { const actual = ast.isArrayExpr(); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node does not contain a `type` attribute", function () { const actual = ast.isArrayExpr({}); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node contains a `type` other than `ArrayExpression`", function () { const actual = ast.isArrayExpr({ type: "foobar" }); const expected = false; assert.equal(actual, expected); }); it("should return `true` if supplied node is an `ArrayExpression`", function () { const actual = ast.isArrayExpr({ type: "ArrayExpression" }); const expected = true; assert.equal(actual, expected); }); }); describe("ast.isObjectExpr", function () { it("should return `false` if no argument is supplied", function () { const actual = ast.isObjectExpr(); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node does not contain a `type` attribute", function () { const actual = ast.isObjectExpr({}); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node contains a `type` other than `ObjectExpression`", function () { const actual = ast.isObjectExpr({ type: "foobar" }); const expected = false; assert.equal(actual, expected); }); it("should return `true` if supplied node is an `ObjectExpression`", function () { const actual = ast.isObjectExpr({ type: "ObjectExpression" }); const expected = true; assert.equal(actual, expected); }); }); describe("ast.isFunctionExpr", function () { it("should return `false` if no argument is supplied", function () { const actual = ast.isFunctionExpr(); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node does not contain a `type` attribute", function () { const actual = ast.isFunctionExpr({}); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node contains a `type` other than `FunctionExpression` or `ArrowFunctionExpression`", function () { const actual = ast.isFunctionExpr({ type: "foobar" }); const expected = false; assert.equal(actual, expected); }); it("should return `true` if supplied node is a `FunctionExpression`", function () { const actual = ast.isFunctionExpr({ type: "FunctionExpression" }); const expected = true; assert.equal(actual, expected); }); it("should return `true` if supplied node is an `ArrowFunctionExpression`", function () { const actual = ast.isFunctionExpr({ type: "ArrowFunctionExpression" }); const expected = true; assert.equal(actual, expected); }); }); describe("ast.isMemberExpr", function () { it("should return `false` if no argument is supplied", function () { const actual = ast.isMemberExpr(); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node does not contain a `type` attribute", function () { const actual = ast.isMemberExpr({}); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node contains a `type` other than `MemberExpression`", function () { const actual = ast.isMemberExpr({ type: "foobar" }); const expected = false; assert.equal(actual, expected); }); it("should return `true` if supplied node is an `MemberExpression`", function () { const actual = ast.isMemberExpr({ type: "MemberExpression" }); const expected = true; assert.equal(actual, expected); }); }); describe("ast.isExprStatement", function () { it("should return `false` if no argument is supplied", function () { const actual = ast.isExprStatement(); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node does not contain a `type` attribute", function () { const actual = ast.isExprStatement({}); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node contains a `type` other than `ExpressionStatement`", function () { const actual = ast.isExprStatement({ type: "foobar" }); const expected = false; assert.equal(actual, expected); }); it("should return `true` if supplied node is an `ExpressionStatement`", function () { const actual = ast.isExprStatement({ type: "ExpressionStatement" }); const expected = true; assert.equal(actual, expected); }); }); describe("ast.isStringLiteralArray", function () { it("should return `false` if no argument is supplied", function () { const actual = ast.isStringLiteralArray(); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node does not contain a `type` attribute", function () { const actual = ast.isStringLiteral({}); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node `type` is not an `ArrayExpression`", function () { const actual = ast.isStringLiteralArray({ type: "FunctionExpression" }); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node does not contain an `elements` attribute", function () { const actual = ast.isStringLiteralArray({ type: "ArrayExpression" }); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node `elements` contains non-string values", function () { const actual = ast.isStringLiteralArray({ type: "ArrayExpression", elements: [ { type: "Literal", value: "a" }, { type: "Literal", value: null }, { type: "Literal", value: 5 } ] }); const expected = false; assert.equal(actual, expected); }); it("should return `true` if node `elements` contains only string values", function () { const actual = ast.isStringLiteralArray({ type: "ArrayExpression", elements: [ { type: "Literal", value: "a" }, { type: "Literal", value: "b" }, { type: "Literal", value: "c" } ] }); const expected = true; assert.equal(actual, expected); }); it("should return `true` if node `elements` is empty", function () { const actual = ast.isStringLiteralArray({ type: "ArrayExpression", elements: [] }); const expected = true; assert.equal(actual, expected); }); }); describe("ast.hasParams", function () { it("should return `false` if no argument is supplied", function () { const actual = ast.hasParams(); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node does not contain a `params` attribute", function () { const actual = ast.hasParams({}); const expected = false; assert.equal(actual, expected); }); it("should return `false` if `params` is empty", function () { const actual = ast.hasParams({ params: [] }); const expected = false; assert.equal(actual, expected); }); it("should return `true` if supplied node has at least one param", function () { const actual = ast.hasParams({ params: [{ type: "Identifier", name: "boop" }] }); const expected = true; assert.equal(actual, expected); }); }); describe("ast.hasCallback", function () { it("should return `false` if no argument is supplied", function () { const actual = ast.hasCallback(); const expected = false; assert.equal(actual, expected); }); it("should return `false` if node does not contain a `arguments` attribute", function () { const actual = ast.hasCallback({}); const expected = false; assert.equal(actual, expected); }); it("should return `false` if `arguments` is empty", function () { const actual = ast.hasCallback({ arguments: [] }); const expected = false; assert.equal(actual, expected); }); it("should return `false` if `arguments` does not contain a FunctionExpression", function () { const actual = ast.hasCallback({ arguments: [{ type: "Identifier", name: "foobar" }] }); const expected = false; assert.equal(actual, expected); }); it("should return `true` if supplied node has at least one FunctionExpression argument", function () { const actual = ast.hasCallback({ arguments: [{ type: "FunctionExpression" }] }); const expected = true; assert.equal(actual, expected); }); }); describe("ast.ancestor", function () { const a = { type: "Program" }; const b = { type: "FunctionDeclaration", parent: a }; const c = { type: "BlockStatement", parent: b }; const d = { type: "ReturnStatement", parent: c }; it("should return `true` if an ancestor satisfies the predicate", function () { const actual = ast.ancestor((node) => node.type === "FunctionDeclaration", d); const expected = true; assert.equal(actual, expected); }); it("should return `false` if no ancestor satisfies the predicate", function () { const actual = ast.ancestor((node) => node.type === "VariableDeclaration", d); const expected = false; assert.equal(actual, expected); }); }); describe("ast.nearest", function () { const a = { type: "Program" }; const b = { type: "FunctionDeclaration", parent: a }; const c = { type: "BlockStatement", parent: b }; const d = { type: "ReturnStatement", parent: c }; it("should return found node if an ancestor satisfies the predicate", function () { const actual = ast.nearest((node) => node.type === "FunctionDeclaration", d); const expected = b; assert.equal(actual, expected); }); it("should return `undefined` if no ancestor satisfies the predicate", function () { const actual = ast.nearest((node) => node.type === "VariableDeclaration", d); const expected = undefined; assert.equal(actual, expected); }); }); eslint-plugin-requirejs-4.0.0/tests/rule-tester.js000066400000000000000000000003121344425206400222670ustar00rootroot00000000000000"use strict"; const RuleTester = require("eslint").RuleTester; module.exports = function (ruleName, rule, test) { const ruleTester = new RuleTester(); ruleTester.run(ruleName, rule, test); };