npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-requirejs

v4.0.1

Published

Enforce code conventions for RequireJS modules with ESLint

Downloads

18,328

Readme

npm Maintenance Status Build Status Coverage Status Package Quality

eslint-plugin-requirejs

Enforce code conventions for RequireJS modules with ESLint.

This plugin is under active development, and is updated frequently. Take a look at the CHANGELOG to see what's recently been added or fixed.

Installation

Install 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 [email protected]

Configuration

Add the plugins section to your config file if not already present and specify eslint-plugin-requirejs as a plugin. The eslint-plugin- prefix may be omitted:

{
  "plugins": [
    "requirejs"
  ]
}

Enable the rules that you would like to use, for example:

{
  "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 | Disallow invalid module definitions | | :star: | | no-invalid-require | Disallow invalid require or requirejs calls | | :star: | | no-multiple-define | Disallow multiple module definitions in one file | | :star: | | no-assign-exports | Disallow assignment to exports when using Simplified CommonJS Wrapper | | :star: | | no-js-extension | Disallow .js extension in dependency paths |

Stylistic Choices

These rules relate to style guidelines, and are therefore quite subjective:

| | | Rule | Description | | :----: | :------: | :--- | :---------- | | | | no-object-define | Disallow Simple Name/Value Pairs form of define | | | | no-function-define | Disallow Simple Function form of define | | | | no-amd-define | Disallow AMD (dependency array) form of define | | | | no-named-define | Disallow named module form of define | | | | no-commonjs-wrapper | Disallow use of Simplified CommonJS Wrapper | | | | no-commonjs-return | Disallow use of return statement in a module definition when using Simplified CommonJS Wrapper | | | | no-commonjs-exports | Disallow use of exports in a module definition when using Simplified CommonJS Wrapper | | | | no-commonjs-module-exports | Disallow use of module.exports in a module definition when using Simplified CommonJS Wrapper | | | | no-dynamic-require | Disallow use of dynamically generated paths in a require call | | | | no-conditional-require | Disallow use of conditional require calls | | | | no-assign-require | Disallow assignment to require or window.require | | | | no-require-tourl | Disallow use of require.toUrl and require.nameToUrl | | | | enforce-define | Require that all files be wrapped in a define call | | | :wrench: | one-dependency-per-line | Enforce line-break rules for AMD dependencies | | | | amd-function-arity | Ensure AMD callbacks have correct number of parameters | | | | sort-amd-paths | Ensure that required paths are in alphabetical order | | | | no-restricted-amd-modules | 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, or suggest a new rule by filing an issue.

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
  • Submitting pull requests - pick one of the open issues to work on and submit a pull request

License

eslint-plugin-requirejs is licensed under the MIT License.