npm.io
2.0.0 • Published 15h ago

eslint-config-mytools

Licence
MIT
Version
2.0.0
Deps
1
Size
7 kB
Vulns
0
Weekly
0
Stars
4

Introduction

NPM license NPM version NPM downloads NPM downloads NPM downloads NPM downloads NPM downloads

eslint-config-mytools helps you configure eslint and prettier in your project according to your team's needs.

Installation

pnpm add -D eslint eslint-config-mytools

If you also need prettier, you need to install it:

pnpm add -D prettier prettier-plugin-astro

If your project is using Astro, you will also need to install the prettier library for Astro:

pnpm add -D prettier

Configure eslint for Javascript projects

You have to create an eslint.config.mjs file in your project and import the js config:

import { defineConfig } from 'eslint/config'
import { base } from 'eslint-config-mytools'

export default defineConfig([
  ...base,
])

Configure eslint for Typescript projects

You have to create an eslint.config.mjs file in your project and import the js config:

import { defineConfig } from 'eslint/config'
import { base, typescript } from 'eslint-config-mytools'

export default defineConfig([
  ...base,
  ...typescript,
])

Configure eslint for React projects with Typescript or Javascript

You have to create an eslint.config.mjs file in your project and import the js config:

import { defineConfig } from 'eslint/config'
import { base, typescript, react } from 'eslint-config-mytools'

export default defineConfig([
  ...base,
  ...typescript,
  ...react,
])

Configure eslint for Astro projects

You have to create an eslint.config.mjs file in your project and import the js config:

import { defineConfig } from 'eslint/config'
import { astro, base, typescript } from 'eslint-config-mytools'

export default defineConfig([
  ...base,
  ...typescript,
  ...astro,
])

If you have React, add the config as well:

import { defineConfig } from 'eslint/config'
import { astro, base, typescript, react } from 'eslint-config-mytools'

export default defineConfig([
  ...base,
  ...typescript,
  ...astro,
  ...react,
])

Configure Prettier for any project

You have to create an eslint.config.mjs file in your project and import the js config:

import { defineConfig } from 'eslint/config'
import { prettier } from 'eslint-config-mytools'

export default defineConfig([
  ...prettier,
])

If you want .astro, .json, and .md files to work with prettier, a prettier.config.mjs file is required:

/**
 * @see https://prettier.io/docs/configuration
 * @type {import("prettier").Config}
 */
export default {
  plugins: ['prettier-plugin-astro'],
  singleQuote: true,
  printWidth: 120,
  semi: false,
  trailingComma: 'all',
}

And add the following script to your package.json file:

{
  "format": "prettier --write **/*{.astro,.json,.md}"
}

The prettier configuration imported into eslint will only affect files: **/*.{js,mjs,cjs,jsx,ts,jsx,tsx}

Keywords