@robinbobin/ts-eslint-prettier

3.0.0 • Public • Published

Installation

Install the following packages:

pnpm i --save-dev @robinbobin/ts-eslint-prettier eslint prettier typescript

For React (Native) projects:

pnpm i --save-dev @types/react eslint-plugin-react-hooks react

Config files

tsconfig.json

Assuming you have the src folder at the top of your project:

{
  "compilerOptions": {
    "declaration": true,
    "outDir": "js"
  },
  "extends": "@robinbobin/ts-eslint-prettier/tsconfig.base",
  "include": ["./*.mjs", "./src/**/*.ts"]
}

For React (Native) projects:

{
  "compilerOptions": {
    "declaration": true,
    "outDir": "js"
  },
  "extends": "@robinbobin/ts-eslint-prettier/tsconfig.base",
  "include": ["./*.mjs", "./src/**/*.ts", "./src/**/*.tsx"]
}

eslint.config.mjs

import eslintConfig from '@robinbobin/ts-eslint-prettier/eslint.config.mjs'

export default [
  ...eslintConfig,
]

If you're getting

The inferred type of 'array' cannot be named without a reference to '.pnpm/@typescript-eslint+utils...'

:

import eslintConfig from '@robinbobin/ts-eslint-prettier/eslint.config.mjs'

/** @type unknown[] */
const array = [...eslintConfig]

export default array

For React (Native) projects:

import config from '@robinbobin/ts-eslint-prettier/eslint.config.mjs'
import configPluginReactHooks from '@robinbobin/ts-eslint-prettier/eslint.config.plugin.react.hooks.mjs'

export default [
  ...config,
  ...configPluginReactHooks,
  {
    rules: {
      'react-hooks/exhaustive-deps': 'error'
    }
  }
]

prettier.config.mjs

export { default } from '@robinbobin/ts-eslint-prettier/prettier.config.mjs'

.prettierignore

/js
/pnpm-lock.yaml

.gitignore

/js
node_modules

package.json

Add the the following to package.json:

"files": [
  "/js",
  "/src"
]

Scripts

prepack.sh

#!/bin/bash
rm -rf js &&
pnpm tsc &&
pnpm eslint &&
pnpm prettier . --check
chmod u+x prepack.sh

package.json:

"scripts": {
  "prepack": "./prepack.sh"
}

Readme

Keywords

Package Sidebar

Install

npm i @robinbobin/ts-eslint-prettier

Weekly Downloads

8

Version

3.0.0

License

none

Unpacked Size

20.2 kB

Total Files

56

Last publish

Collaborators

  • robinbobin