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

@practio/eslint-config-practio

v10.1.0

Published

Global eslint config for all Practio repos

Downloads

14

Readme

eslint-config-practio

Global eslint config for all Practio repos

Usage

In order to use this config in your project do the following:

Install this module:

$ npm i -D @practio/eslint-config-practio

After that create a file called .eslintrc.json in the root of the project with the following content:

{
  "extends": ["@practio/practio"]
}

Adding automatic formatting

First start by ensuring you have completed the steps in the Usage section of this readme before you continue.

Then install the modules needed for the formatting script and commit hook:

$ npm i -D husky lint-staged

Then add the following scripts to the package.json file of your project (notice that the format script is also calling a prettier:write script, see the prettier-config repo on how to add it):

{
  "scripts": {
    // ...
    "eslint:fix": "eslint --fix . || echo Unfixable errors were ignored and should be caught by the tests",
    "format": "npm run eslint:fix && npm run prettier:write"
  }
}

Install lint-staged as a dev dependency and add the following entry to the root of the package.json file:

{
  "lint-staged": {
    "*.@(js|jsx|ts|mjs)": ["eslint --fix"]
  }
}

Next install husky as a dev dependency and add a pre-commit hook by using the npx husky add command (see their docs). In the pre-commit file inside the .husky folder add the following line npx --no lint-staged.

You have now added a format script that can be executed in order to format the whole repository (for repositories that are merged with ready builds on Circle-CI, the merge script of ci-merge tries to run the script format if one is defined in package.json).

You have also added a commit hook that ensures that all files that you make changes to will be linted and auto fixed when they are staged with git.

If you need the formatting to ignore some specific folders (for example coverage, build or dist folders) then add a .prettierignore and a .eslintignore file to the root of the repository and add the globs that needs to be ignored to both files (it uses gitignore syntax).

That's it. Next time you make changes to your code, it will be formatted automatically as well.

Enable linting highliting in your editor

Most editors have extensions for eslint that allows for highlighting of linting errors while you code. It is recommnded that you install such an extention in your editor. Normally, those extensions should automatically register and use the .eslintrc.json file you added in the Usage section. You can also enable the extension "Auto fix on save" option to have most linting errors fixed automatically.

Adding mocha test for the linting

All project's should normally also include an automatted test that ensures the the linting rules are respected. To do this for Mocha tests then start by installing the following module:

$ npm i -D mocha-eslint

Then add the test file called eslint.test.js to the folder containing your mocha tests. The content of the file should be:

require('mocha-eslint')(['.']);

That's it. Now the linting will also be checked as part of your tests.