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

@wirby/codestyle

v0.3.1

Published

wir.by codestyle tools shared configs

Downloads

5

Readme

@wirby/codestyle

wir.by codestyle tools shared configs

npm code style: prettier Commitizen friendly

Install

npm i -D @wirby/codestyle

Development

make release # to push new version & generate changelog
make prerelease # only push new version to npm, for testing

EditorConfig

Create configuration file .editorconfig at the root of the project. Insert the following content:

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 100
trim_trailing_whitespace = true

[Makefile]
indent_style = tab

ide

If you use Visual Studio Code, install EditorConfig plugin.


Prettier

config

  1. Create configuration file .prettierrc.js at the root of the project. Insert the following content:
const config = require('@wirby/codestyle/prettier');
module.exports = config;
  1. Also create file .prettierignore, add some ignore patterns:
# ide
.idea/
.vscode/

# npm
node_modules/
package.json
package-lock.json
yarn.lock

# misc
coverage
tsconfig.json

# changelog
*.hbs
CHANGELOG.md

npm

  1. Add following lines to yout package.json:
{
  "scripts": {
    "format": "prettier --write ."
  }
}
  1. And then use as npm run format

ide

JetBrains IDE

Install extension (It is already bundled to WebStorm). You can read more information in Prettier site.

Visual Studio Code

Install extension. Detailed documentation can be found at the extension page.


ESLint

  1. Create configuration file .eslintrc.js at the root of the project. Insert the following content:
module.exports = {
  root: true,
  extends: [
    // choose and enable needed configs
    './node_modules/@wirby/codestyle/eslint/prettier', // prettier first!
    './node_modules/@wirby/codestyle/eslint/base',
    './node_modules/@wirby/codestyle/eslint/typescript',
    './node_modules/@wirby/codestyle/eslint/import',
    // './node_modules/@wirby/codestyle/eslint/next',
    // './node_modules/@wirby/codestyle/eslint/react',
    // './node_modules/@wirby/codestyle/eslint/node',
  ],
};
  1. Add following lines to your package.json:
{
  "scripts": {
    "lint": "eslint . --ext .ts,.tsx,.js,.jsx,.json --fix --cache --max-warnings=0"
  }
}
  1. Also create file .eslintignore, add some ignore patterns:
# ide
.idea/
.vscode/

# npm
**/node_modules/*
package.json
  1. Add .eslintcache to .gitignore

Stylelint

TBD


Conventional Commits

npm i -g commitizen git-cz
  1. add .cz.json:
{
  "path": "git-cz"
}
  1. add changelog.config.js and insert following:
const getChangelogConfig = require('@wirby/codestyle/changelog.config');

module.exports = getChangelogConfig({
  scopes: [
    /* additional scopes */
    'auth',
  ],
  types: {
    /* additional types */
    temp: ['🚧', 'temporary changes'],
  },
});
  1. add commitlint.config.js and insert following:
const getCommitlintConfig = require('@wirby/codestyle/commitlint.config');

const czConfig = require('./changelog.config');

module.exports = getCommitlintConfig(czConfig);
  1. add .release-it.js:
module.exports = require('@wirby/codestyle/release-it');
  1. Add following lines to your package.json:
{
  "scripts": {
    "commit": "git-cz",
    "changelog": "auto-changelog -p && git add CHANGELOG.md",
    "release": "release-it"
  }
}
  1. add badges to README.md
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

lint-staged & husky

  1. add lint-staged.config.js and insert following:
module.exports = {
  '*.@(js|jsx|ts|tsx)': ['prettier --write', 'eslint --fix'],
};
  1. add .husky folder to .gitignore

  2. run npx husky install in your project root

You can extend current husky hooks, by adding scripts in you package.json:

  • "husky:commit-msg": "commitlint --edit $HUSKY_GIT_PARAMS"
  • "husky:pre-commit": "lint-staged"
  • "husky:pre-push": "npm run type-check"
  • "husky:prepare-commit-msg": "exec < /dev/tty && git cz --hook || true"

Note: If node_modules are installed and you decide to delete the .husky folder then you need to delete all node_modules and install them again.