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

demio-code-rules

v0.3.2

Published

Demio code rules and linters configuration

Downloads

1

Readme

Demio code rules and linters configuration

This repo is the npm package demio-code-rules

Installation

npm i -D demio-code-rules
# or
yarn add -D demio-code-rules

ESLint airbnb

Dependencies

Install these dependencies in the app:

  • eslint
  • babel-eslint
  • eslint-config-airbnb
  • eslint-plugin-import
  • eslint-plugin-react
# From the root directory
npm i -D eslint babel-eslint eslint-config-airbnb eslint-plugin-import eslint-plugin-react
# or
yarn add -D eslint babel-eslint eslint-config-airbnb eslint-plugin-import eslint-plugin-react

NPM Script

Add a script like this to use Demio's config:

"scripts": {
  "eslint": "eslint --config ./node_modules/demio-code-rules/eslint-airbnb/.eslintrc.airbnb.yml --quiet src"
}

Note that src would be the path to the scripts folder in the app.

This script should be run before commits, an easy way to do it is using the pre-commit package.

Run eslint as pre-commit git hook

Install

npm i -D pre-commit
# or
yarn add -D pre-commit

Add the config to the app package.json:

"pre-commit": [
  "eslint"
]

This tells git to run the eslint script before each commit. This way only verified code will be allowed in the repo. Other scripts like test could be easily added here in order. If pre-commit scripts don't pass without errors then the commit is rejected.

To skip this commit verification in special cases run: git commit -n (or --no-verify)

Disable rules

Rules can be disabled in special cases. To disable one line use:

/* eslint-disable-next-line */
if (exitTime === void 0) {
  ...
}

To disable some rules in the whole file use at the begining:

/* eslint prefer-destructuring: 0 */
/* eslint no-undef: 0 */
const util = DEMIO.util
...

Plugins

Import

Allows the detection of unresolved paths. When using webpack aliases the best option is to use a resolver plugin eslint-import-resolver-webpack but I couldn't make it work in Webpack 1 so the simplest workaround to avoid linter errors on aliases like config or libs is using { ignore: ['^libs', '^config'] } in import/no-unresolved. Unfortunally this workaround disable the linter capability to detect unresolved libraries. We plan to upgrade to webpack 4 ASAP and remove this ignore.

About Webpack aliases, they are a handly way to avoid typing long relative paths to find common resources like shared libraries or configs. Here an example:

# in webpack config
resolve: {
  alias: {
    config: path.resolve(__dirname, 'config.js'),
    libs: path.resolve(__dirname, 'app/scripts/libs')
  }
},

Then when importing there is no need to think about the relative path anymore:

# Simple imports
import { emitLocalEvent } from 'libs/localEvents'
import config from 'config'

# instead of
import { emitLocalEvent } from '../../../libs/localEvents'
import config from '../../../config'

Contribution

  1. Update the code and commit
  2. Bump the package version npm version [major|minor|patch]
  3. Push to the repo
  4. Publish into npm
    • Login with you npm user npm login
    • Publish from the root folder npm publish