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

neutrino-preset-mozilla-frontend-infra

v4.1.0

Published

`neutrino-preset-mozilla-frontend-infra` is a Neutrino preset that supports building React web applications, React components, or Node.js applications and linting them with Airbnb's ESLint config, following the Airbnb styleguide with Mozilla additions. Th

Downloads

39

Readme

Mozilla Frontend Infra Neutrino Preset

neutrino-preset-mozilla-frontend-infra is a Neutrino preset that supports building React web applications, React components, or Node.js applications and linting them with Airbnb's ESLint config, following the Airbnb styleguide with Mozilla additions. This preset is used for supporting Mozilla's Frontend Infra team.

NPM version NPM downloads

Features

This preset exposes a few base presets for working with projects:

  • neutrino-preset-mozilla-frontend-infra/react:
    • Extends from @neutrinojs/react
    • Ability to automatically change asset versions using an optional ID.
    • Supports React Hot Loader v4
    • Skips source-maps when building PRs in CI
    • Can lint staged files using git hooks defined in package.json
  • neutrino-preset-mozilla-frontend-infra/node:
    • Extends from @neutrinojs/node
    • Skips source-maps when building PRs in CI
    • Can lint staged files using git hooks defined in package.json
  • neutrino-preset-mozilla-frontend-infra/react-components:
    • Extends from @neutrinojs/react-components
    • Generates two builds: one for our browser-support matrix to use within our own web apps; one for use in ES5 builds, such as community project based on Create React App.
    • Skips source-maps when building PRs in CI
    • Can lint staged files using git hooks defined in package.json

Each of these base presets also come with one of the following variants our own linting customizations. They also bake in Prettier for unifying code style.

  • neutrino-preset-mozilla-frontend-infra/react-lint:
    • Extends from @neutrinojs/airbnb
    • For linting React and React Component-based projects
    • Highly visible during development, fails compilation when building for production
  • neutrino-preset-mozilla-frontend-infra/node-lint:
    • Extends from @neutrinojs/airbnb-base
    • For linting Node.js-based projects
    • Highly visible during development, fails compilation when building for production

You do not need to add this linting preset separately unless you are not using one of the above configurations.

If you wish to add React Styleguidist for previewing components in isolation from an application, there is additional middleware for that, to be used with the react and react-components presets:

  • neutrino-preset-mozilla-frontend-infra/styleguide:
    • Extends from neutrino-middleware-styleguidist
    • Automatically generated from any components in src/components/**/*.jsx
    • Must be placed in .neutrinorc.js before the react or react-components presets.
    • Exposes access to neutrino styleguide:start and neutrino styleguide:build commands

Requirements

  • Node.js v6.10+
  • Yarn or npm client
  • Neutrino v8

Installation

neutrino-preset-mozilla-frontend-infra can be installed via the Yarn or npm clients. Inside your project, make sure neutrino and neutrino-preset-mozilla-frontend-infra are development dependencies. Yarn is highly preferred for Mozilla Frontend Infra projects.

Yarn

❯ yarn add --dev neutrino neutrino-preset-mozilla-frontend-infra

npm

❯ npm install --save-dev neutrino neutrino-preset-mozilla-frontend-infra

Project Layout

neutrino-preset-mozilla-frontend-infra follows the standard project layout specified by Neutrino. This means that by default all project source code should live in a directory named src in the root of the project. This includes JavaScript files, CSS stylesheets, images, and any other assets that would be available to import your compiled project.

Project Docs

Precommit staging command

Using the react, react-components, or node presets expose access to the neutrino stage command. By default this command will run neutrino lint against git staged files for commit, matching any .js and .jsx files. Installing neutrino-preset-mozilla-frontend-infra installs git hooks enabling you to set this up to run automatically if you define a hook in your package.json scripts:

{
  "scripts": {
    "precommit": "neutrino stage"
  }
}

Now running git commit will run neutrino lint against these staged files, and prevent the commit if lint fails.

Example: running git commit with files staged with linting errors:

❯ git commit -m "Commiting linting errors"

husky > npm run -s precommit (node v9.9.0)

 ❯ Running tasks for *.{js,jsx}
   ✖ neutrino lint
     → 1 error potentially fixable with the `--fix` option.
✖ neutrino lint found some errors. Please fix them and try committing again.

            error: Insert `;` (prettier/prettier) at src/components/Authorize/index.jsx:163:32:
  161 |             reject(new Error('No authorization result'));
  162 |           } else {
> 163 |             resolve(authResult)
      |                                ^
  164 |           }
  165 |         }
  166 |       );


1 error found.
1 error potentially fixable with the `--fix` option.

husky > pre-commit hook failed (add --no-verify to bypass)

If you wish to override the options for staging, pass an options object to the staging property of your middleware. You must use the advanced config format specified by lint-staged. If no options are passed for staging.linters, the default linter of '*.{js,jsx}': ['neutrino lint'] will be used.

Example: only run linting against JS files:

module.exports = {
  use: [
    ['neutrino-preset-mozilla-frontend-infra/react', {
      staging: {
        linters: {
          '*.js': ['neutrino lint'],
        },
      },
    }],
  ],
};