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

@askeladden/eslint-config-askeladden

v1.1.2

Published

A set of eslint-configs for Askeladden projects, forked from @otovo/eslint-config-otovo.

Downloads

121

Readme

Askeladden eslint config

This repo contains sets of opinionated linting rules (eslint-configs) for Askeladden projects.

Installing

npx install-peerdeps --dev @askeladden/eslint-config-askeladden -x -W

Alternatively, you can manually install correct version of each package listed by:

npm info "@askeladden/eslint-config-askeladden@latest" peerDependencies

If you have a monorepo using e.g. Yarn workspaces, it's recommended to install it in the common/root folder.

Quick start

.eslintrc

From the root directory of your (mono-)repo, create a config file .eslintrc.

{
  "parser": "@typescript-eslint/parser",
  "env": { "browser": true, "node": true },
  "extends": ["@askeladden/eslint-config-askeladden"],
  "rules": {}
}

Note: the default export extended here is adapted to a React project with Typescript, formatted with Prettier. It should also work for a non-React code base. If this does not fit your project, see Slow start.

.eslintignore

You also want an ignore-file, ignoring all dist, build and node_modules folders:

**/dist/*
**/build/*
**/node-modules/*
**/__mocks__/*
**/.cache/*
**/public/*
coverage
*.css
*.json
prettier.config.js

prettier.config.js

const commonConfig = require('@askeladden/eslint-config-askeladden/prettier.config');

module.exports = commonConfig;

These files should be placed in the root directory, also for multi-workspace mono repos

package.json – recommended tasks

"lint": "eslint .",
"lint:ignore-warnings": "eslint . --quiet",
"lint:prettier-check": "prettier --check \"**/*.{js,jsx,ts,tsx,json}\"",
"lint:prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,json}\""

We recommend lint:ignore-warnings and lint:prettier-check to be run on CI test tasks, to prevent PRs with errors to be merged to master. These tasks should be placed in the root directory, also for multi-workspace mono repos

wercker.yml

If we are (still) using wercker when you read this, add steps to the test job for all branches that run the following checks:

linting:
  steps:
    - script:
      name: ESLint check
      code: npm run lint:ignore-warnings
    - script:
      name: Prettier check
      code: npm run lint:prettier-check

Commit hooks

We can use husky and lint-staged to identify errors when we commit, stopping us from commiting invalid code. This will also run prettier and fix some of the errors automatically.

# Install dependencies
yarn add -D husky lint-staged

In package.json, define which tasks to be run on commit. We recommend on-commit hooks to fix and validate both eslint and prettier, which is included in the config below:

"husky": {
  "hooks": {
    "pre-commit": "lint-staged"
  }
},
"lint-staged": {
  "*.{js,jsx,ts,tsx,css}": [
    "prettier --write",
    "eslint --quiet --fix"
  ],
  "*.{json, md}": [
    "prettier --write"
  ]
},

Slow start

@askeladden/eslint-config-askeladden consists of several small sets of rules:

  • javascript
  • react
  • typescript
  • prettier

For a given project, you will probably need several of them. For example: If you want to add javascript and react and prettier to your repo, add the following to your .eslintrc config:

{
  "env": {
    "browser": true
  },
  "extends": [
    "@askeladden/eslint-config-askeladden/javascript",
    "@askeladden/eslint-config-askeladden/react",
    "@askeladden/eslint-config-askeladden/prettier"
  ]
}

Recommended sets

Instead of adding rule sets one by one, you can use one of four collections:

  • @askeladden/eslint-config-askeladden/javascript
  • @askeladden/eslint-config-askeladden/react-recommended
  • @askeladden/eslint-config-askeladden/typescript-recommended
  • @askeladden/eslint-config-askeladden/react-typescript-recommended
  • @askeladden/eslint-config-askeladden/react-native-typescript-recommended

@askeladden/eslint-config-askeladden can be used as shorthand for @askeladden/eslint-config-askeladden/react-typescript-recommended.

You use collections in the same way you add rule sets: By adding them to the extends array in .eslintrc:

{
  "env": {
    "browser": true
  },
  "parser": "@typescript-eslint/parser",
  "extends": ["@askeladden/eslint-config-askeladden/react-typescript-recommended"]
}

The following is a overview of the rules each collection includes:

| | default | react-recommended | typescript-recommended | react-typescript-recommended | | ---------- | --------- | ------------------- | ------------------------ | ------------------------------ | | javascript | ✅ | ✅ | ✅ | ✅ | | prettier | ✅ | ✅ | ✅ | ✅ | | react | ✅ | ✅ | | ✅ | | typescript | ✅ | | ✅ | ✅ |

Publishing new versions

Commits are linted with with commitizen and automatically published to npm on push to master, using semantic release.

They are automatically published to NPM on push to master branch via Wercker CI.