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

@meltstudio/eslint-config

v2.1.3

Published

Melt Studio's ESLint configurations

Downloads

947

Readme

@meltstudio/eslint-config

Collection of ESLint configurations used in Melt Studio.

Base rules

All the configurations exported in this package include the following rules:

'no-restricted-imports': [
  'error',
  {
    patterns: [
      {
        group: ['src/**/*', '../**/*'],
        message:
          'usage of src/* and ../**/* imports is not allowed, use paths defined in tsconfig',
      },
    ],
  },
],

'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',

Aditionally, for the TypeScript configurations the following rules are included:

// this rule conflicts with typescript
'no-use-before-define': 'off',

// typescript
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-misused-promises': [
  'error',
  { checksVoidReturn: false },
],

Usage

This package exports multiple ESLint configurations.

node-js

Node-JavaScript configuration, it includes the following rule sets:

  • eslint:recommended
  • airbnb-base
  • plugin:import/recommended
  • plugin:prettier/recommended
  • plugin:jest/recommended (only for test files)

and the base rules.

To use it:

  1. Install it:
yarn add --dev @meltstudio/eslint-config \
    eslint-config-airbnb-base \
    eslint-config-prettier \
    eslint-plugin-prettier \
    eslint-plugin-import \
    eslint-plugin-simple-import-sort
  1. Add it in your eslint config:
{
  ...
  "extends": ["@meltstudio/eslint-config/node-js"],
  ...
}

node-ts

Node-TypeScript configuration, it includes the following rule sets:

  • eslint:recommended
  • airbnb-base
  • airbnb-typescript/base
  • plugin:@typescript-eslint/eslint-recommended
  • plugin:@typescript-eslint/recommended
  • plugin:@typescript-eslint/recommended-requiring-type-checking
  • plugin:import/typescript
  • plugin:import/recommended
  • plugin:prettier/recommended

and the base TypeScript rules.

To use it:

  1. Install it:
yarn add --dev @meltstudio/eslint-config \
    eslint-config-airbnb-base \
    eslint-config-airbnb-typescript \
    eslint-config-prettier \
    eslint-plugin-prettier \
    eslint-plugin-import \
    eslint-plugin-simple-import-sort \
    @typescript-eslint/eslint-plugin \
    @typescript-eslint/parser \
    eslint-import-resolver-typescript
  1. Add it in your eslint config:
{
  ...
  "extends": ["@meltstudio/eslint-config/node-ts"],
  ...
}

react-ts

React-TypeScript configuration, it includes the following rule sets:

  • airbnb
  • airbnb/hooks
  • airbnb-typescript
  • plugin:@typescript-eslint/eslint-recommended
  • plugin:@typescript-eslint/recommended
  • plugin:@typescript-eslint/recommended-requiring-type-checking
  • plugin:import/typescript
  • plugin:import/recommended
  • plugin:prettier/recommended
  • plugin:testing-library/react (only for test files)

all the base TypeScript rules, and the following rules:

// react
'react/function-component-definition': [
  2,
  {
    namedComponents: 'arrow-function',
  },
],
'react/prop-types': 'off',
'react/jsx-props-no-spreading': 'off',
'react/require-default-props': 'off',
'react/react-in-jsx-scope': 'off',

'jsx-a11y/label-has-associated-control': [
  'error',
  { controlComponents: ['Field'] },
],

To use it:

  1. Install it:
yarn add --dev @meltstudio/eslint-config \
    eslint-config-airbnb \
    eslint-config-airbnb-typescript \
    eslint-config-prettier \
    eslint-plugin-prettier \
    eslint-plugin-import \
    eslint-plugin-simple-import-sort \
    @typescript-eslint/eslint-plugin \
    @typescript-eslint/parser \
    eslint-import-resolver-typescript \
    eslint-plugin-jsx-a11y \
    eslint-plugin-react \
    eslint-plugin-react-hooks \
    eslint-plugin-testing-library
  1. Add it in your eslint config:
{
  ...
  "extends": ["@meltstudio/eslint-config/react-ts"],
  ...
}

nextjs-ts

Next.js-TypeScript configuration. It includes the same rule sets and rules that come with the react-ts configuration, plus the following rule sets:

  • plugin:@next/next/recommended

and the following rules:

'jsx-a11y/alt-text': [
  'warn',
  {
    elements: ['img'],
    img: ['Image'],
  },
],

To use it:

  1. Install it:
yarn add --dev @meltstudio/eslint-config \
    eslint-config-airbnb \
    eslint-config-airbnb-typescript \
    eslint-config-prettier \
    eslint-plugin-prettier \
    eslint-plugin-import \
    eslint-plugin-simple-import-sort \
    @typescript-eslint/eslint-plugin \
    @typescript-eslint/parser \
    eslint-import-resolver-typescript \
    eslint-plugin-jsx-a11y \
    eslint-plugin-react \
    eslint-plugin-react-hooks \
    eslint-plugin-testing-library \
    eslint-config-next
  1. Add it in your eslint config:
{
  ...
  "extends": ["@meltstudio/eslint-config/nextjs-ts"],
  ...
}

jest-overrides

Base config that provides overrides for jest. It provides the following rule set:

  • plugin:jest/recommended (only for test files)

To use it:

  1. Install it:
yarn add --dev @meltstudio/eslint-config \
    eslint-plugin-jest \
    jest/recommended
  1. Add it in your eslint config:
{
  ...
  "extends": ["@meltstudio/eslint-config/jest-overrides"],
  ...
}

jest-react-overrides

Base config that provides overrides for jest when using react. It provides the following rule set:

  • plugin:jest/recommended (only for test files)

To use it:

  1. Install it:
yarn add --dev @meltstudio/eslint-config \
    eslint-plugin-jest \
    eslint-plugin-jest-dom \
    testing-library/react \
    jest/recommended
  1. Add it in your eslint config:
{
  ...
  "extends": ["@meltstudio/eslint-config/jest-react-overrides"],
  ...
}

Troubleshooting

Working directory

When running ESLint you need to make sure that it's running using the workspace root as its working directory. If you want to run ESLint using a different working directory, you'll need to override the parserOptions for @typescript-eslint/parser, and the settings for eslint-import-resolver-typescript and eslint-config-next.

Monorepos and lint-staged

The recommended way to work with lint-staged in monorepos is adding separate configuration files in each package. This ensures that lint-staged will run ESLint using the package directory as its working directory.