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

@rocketmakers/eslint

v2.1.0

Published

Package to return eslint config based on a set of internally defined standards

Downloads

2,931

Readme

Rocketmakers eslint

Package to return eslint config based on a set of internally defined standards.

Installation

Run the following to install the package as a dev dependency:

npm i --save-dev @rocketmakers/eslint

Once you have installed @rocketmakers/eslint you do not need to install any other linting package such as eslint, eslint-config-* or eslint-plugin-* as these will be installed as transitive dependencies and you will still be able to run npx eslint ... successfully.

Config setup

Create a .eslintrc.js file in the directory you intend to run eslint from. Import createEslintConfig in order to generate your base project config. In depth descriptions of this function and its mandatory/optional params can be found in our full docs.

An example .eslintrc.js can be found below - the second block should only be used if you need specific extra files covered:

// .eslintrc.js
const { createEslintConfig } = require('@rocketmakers/eslint');

const config = createEslintConfig(
  {
    project: ['tsconfig.json'],
    ignorePatterns: ['**/node_modules/**/*.*', 'lib/*', '*.js'],
  },
  {
    'import/no-extraneous-dependencies': [
      'error',
      {
        devDependencies: ['.eslintrc.js', 'prettier.config.js'],
      },
    ],
  }
);

module.exports = config;

Lerna monorepo setup

When working inside a monorepo many package imports can be linted as extraneous dependencies, when they are actually installed at the project root. In order to resolve these linting errors you must provide a list of core modules to specify which dependencies you know are accessible from the root repository node_modules. An example is given below:

// .eslintrc.js

const config = createEslintConfig(
  {
    ...,
    // When installed at the root, this would be classed as an extraneous dev dep due to lerna monorepo setup
    coreModules: ['@rocketmakers/log'],
  }
);

JSX linting

To properly lint JSX components, the package needs to underrstand which of your custom components link back to 'standard' ones and what type of component they are.

// .eslintrc.js

const config = createEslintConfig(
  {
    ...,
    // Accessibility - maps custom component directly to html component
    jsxAllyComponents: {
      MyButton: 'button'
    },
    jsxFormComponents: [
      // Simple form wrapper that uses 'action' to hold the target url
      'MyForm',
      // More complicated form wrapper with own target attribute
      { name: 'MyComplexForm', formAttribute: 'endpoint' },
    ],
    jsxLinkComponent: [
      // Simple link wrapper that uses 'href' to hold the target url
      'MyLink',
      // More complicated link wrapper with own target attribute
      { name: 'Link', linkAttribute: 'to' }
    ]
  }
);

Linting

Run the following scripts to lint your code:

# return errors
npx eslint .

# fix auto-fixable linting errors
npx eslint . --fix

Ignore files

Using the above setup, .eslintignore files are respected when linting. You do not need to include an .eslintignore file as you can pass an ignorePatterns property as part of the createEslintConfig() params.

Config checking

If you want to check your ESLint config in its complete output state to see what plugins, rules etc are enabled, run:

npx eslint --print-config file.js > eslintconfig.json

This will produce a complete json object for the configuration post-compilation. Be aware that this is a very large file.