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

@toyokumo/eslint-config

v2.1.2

Published

eslint rule set for Toyokumo.

Downloads

853

Readme

eslint-config

npm version Test

A ESLint rule set for Toyokumo.

Purpose

  • Standardization of coding style.
  • Installation and setting support for ESLint.

Use prettier for code format

  • All rules provided by toyokumo/eslint-config assume the use of prettier.
  • Use prettier-config-plugin to avoid lint errors where it overlaps with prettier format rules.
    • If we find a red squiggly line, we will want to fix it, but we don't have to manually fix what we can fix by formatting
  • For the lint + format method, refer to the method of this repository.
  • This policy might be changed.

Usage

npm i --save-dev @toyokumo/eslint-config eslint @toyokumo/prettier-config prettier npm-run-all
# or
yarn add --dev @toyokumo/eslint-config eslint @toyokumo/prettier-config prettier npm-run-all

Setup npm scripts

We must use prettier for code format when using @toyokumo/eslint-config.

We are taking this strategy for code format - eslint --fix -> prettier --write

An Example of npm scripts to achieve this strategy.

{
  "scripts": {
    "format": "run-s \"format:eslint -- {1}\" \"format:prettier -- {1}\" --",
    "format:eslint": "eslint --fix",
    "format:prettier": "prettier --write",
    "format-all": "npm run format \"./**/*.{js,ts,tsx}\"",
    "format-all:eslint": "eslint --fix \"./**/*.{js,ts,tsx}\"",
    "format-all:prettier": "prettier --write \"./**/*.{js,ts,tsx}\""
  }
}

Configuration object

const toyokumoEslint = require('@toyokumo/eslint-config');
/* 
Imported toyokumoEslint is a object of ESLint configurations.

{
  // config is a config helper function inspired by typescript-eslint.
  // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/typescript-eslint/src/config-helper.ts
  config,
  // configs is a object of ESLint configurations.
  configs: {
    base, // Linter.FlatConfig[]
    js, // Linter.FlatConfig[]
    ts, // Linter.FlatConfig[]
    tsx, // Linter.FlatConfig[]
    react, // Linter.FlatConfig[]
    next, // Linter.FlatConfig[]
    tailwindcss, // Linter.FlatConfig[]
    jest, // Linter.FlatConfig[]
    prettier, // Linter.FlatConfig[]
  },
}

 */

Setup eslint.config.js

We just set the ideal rule set, so we can overwrite or ignore the rule depending on the project situation.

// Most simple example
const toyokumoEslint = require('@toyokumo/eslint-config');

module.exports = [
  ...toyokumoEslint.configs.base,
  ...toyokumoEslint.configs.js,
  ...toyokumoEslint.configs.ts,
  ...toyokumoEslint.configs.tsx,
  ...toyokumoEslint.configs.react,
  ...toyokumoEslint.configs.next,
  ...toyokumoEslint.configs.tailwindcss,
  ...toyokumoEslint.configs.prettier,
  {
    rules: {
      // Overwrite my rule
    }
  },
];

// Multi modules
module.exports = [
  ...toyokumoEslint.configs.base,
  ...toyokumoEslint.configs.tsx, // *.tsx only.
  ...toyokumoEslint.config({
    files: ['packages/next/**/*.ts', 'packages/next/**/*.tsx'],
    extends: [
      ...toyokumoEslint.configs.ts,
      ...toyokumoEslint.configs.react,
      ...toyokumoEslint.configs.next,
      ...toyokumoEslint.configs.tailwindcss,
      {
        languageOptions: {
          parserOptions: {
            project: 'packages/next/tsconfig.json',
          },
        },
        settings: {
          'import/resolver': {
            typescript: {
              project: 'packages/next/tsconfig.json',
            },
          },
          tailwindcss: {
            config: 'packages/next/tailwind.config.ts',
          },
        },
      }
    ],
    rules: {
      '@next/next/no-html-link-for-pages': ['error', 'packages/next/app'],
      // Overwrite my rule
    }
  }),
  ...toyokumoEslint.config({
    files: ['packages/ui-component/**/*.ts', 'packages/ui-component/**/*.tsx'],
    extends: [
      ...toyokumoEslint.configs.ts,
      ...toyokumoEslint.configs.react,
      ...toyokumoEslint.configs.tailwindcss,
      {
        languageOptions: {
          parserOptions: {
            project: 'packages/ui-component/tsconfig.json',
          },
        },
        settings: {
          'import/resolver': {
            typescript: {
              project: 'packages/ui-component/tsconfig.json',
            },
          },
          tailwindcss: {
            config: 'packages/ui-component/tailwind.config.ts',
          },
        },
      }
    ],
    rules: {
      // Overwrite my rule
    }
  }),
  ...toyokumoEslint.configs.prettier,
];