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

@deftomat/opinionated

v1.1.3

Published

Opinionated tooling for JavaScript & TypeScript projects.

Downloads

286

Readme

Why?

Because orchestrating all the tools, linters, formatters, etc. in each project can took a long time and their configuration will differ more and more as you will copy it between multiple projects.

Opinionated provides everything in one place and upgrading your tool chain is as easy as upgrading the dependency version.

Installation

$ yarn add @deftomat/opinionated --dev

or

$ npm install @deftomat/opinionated --include=dev

Usage

Tool provides the following commands:

> Pre-commit

$ opinionated pre-commit

Pre-commit command will try to run simple, auto-fixable operations on staged files. Operations includes common ESLint rules, Prettier, etc.

Command is designed to be opaque and hassle free, so theoretically, pre-commit check should pass for 99% of commits without any error or warning.

> Checkup

$ opinionated checkup

Checkup command allows you to keep your project in top shape.

Command includes:

  • Engine check - Ensures that you are using the right NodeJS version.
  • Integrity - (yarn only) Ensures that dependencies are installed properly.
  • Dependency duplicates check - (yarn only) Ensures no unnecessary dependency duplicates. Especially useful for monorepos.
  • Linter - Strict ESLint rules.
  • TypeScript check - Detects type errors and unused code.
  • Formatting - Runs Prettier.

Command is aware of yarn workspaces and is able to run checks on whole monorepo or just in one package. To run checks in all packages, just run it in project's root. To run checks in one package, you need to run it in package's directory.

💡 We recommend to run this command before pull requests and deployments.

> Ensure configs

$ opinionated ensure-configs

Command will add the following configs if necessary:

  • EditorConfig - Makes sure that every developer use the same indentation, charset, EOF, etc.
  • Prettier - Makes sure that every supported editor use the same auto-formatting rules.

💡 This command is usually not necessary as every other command runs it by default.

Integration into project

To integrate the tool into your project, we recommend the following packages.json:

{
  ...
  "scripts": {
    "checkup": "opinionated checkup",
    "prepare": "husky install"
  },
  "devDependencies": {
    "@deftomat/opinionated": "^1.0.0",
    "husky": "^8.0.0"
  }
  ...
}

This configuration allows you to automatically run pre-commit check before each commit (via Husky git hook) and provides yarn checkup to easily run checkup command.

Custom ESLint rules

If you need to alter the predefined ESLint rules, just follow the ESLint configuration guide.

Any rule specified in your configuration file will be merged over build-in configuration. This allows you to add/edit/remove any rule you want.

Ignoring files and directories

As tool is using ESLint and Prettier, you can follow their guidelines to ignore any file or directory.

However, when tool detects, that there are no .ignore file for these tools, then it tries to use .opinionatedignore file which will be applied to both ESLint and Prettier. If there is no .opinionatedignore, then .gitignore will be used.

Resolution order for ESLint:

  • .eslintignore
  • eslintIgnore property in package.json
  • .opinionatedignore
  • .gitignore

Resolution order for Prettier:

  • .prettierignore
  • .opinionatedignore
  • .gitignore