Skip to content

kobakazu0429/eslint-config

Repository files navigation

@kobakazu0429/eslint-config

Usage

  1. install eslint and eslint-config
yarn add -D eslint @kobakazu0429/eslint-config-base
yarn add -D eslint @kobakazu0429/eslint-config-typescript
yarn add -D eslint @kobakazu0429/eslint-config-typescript-react
yarn add -D eslint @kobakazu0429/eslint-config-typescript-svelte
  1. create and edit .eslintrc.js.
$ touch .eslintrc.js
wget https://raw.githubusercontent.com/kobakazu0429/eslint-config/master/template.js -O .eslintrc.js
module.exports = {
  extends: "@kobakazu0429/eslint-config-base",
  // extends: "@kobakazu0429/eslint-config-typescript",
  // extends: "@kobakazu0429/eslint-config-typescript-react",
  // extends: "@kobakazu0429/eslint-config-typescript-svelte",
};
  1. add lint command to scripts filed into package.json.
{
  "lint": "npm run lint:eslint && npm run lint:prettier",
  "lint:eslint": "eslint \"./{src,test}/**/*.{js,ts,tsx,svelte}\" --fix",
  "lint:prettier": "prettier \"./{src,test}/**/*.{js,ts,tsx,svelte}\" --write"
}

if using webpack

$ yarn add -D eslint-plugin-import eslint-import-resolver-webpack
module.exports = {
  settings: {
    "import/resolver": {
      webpack: {
        config: "config/webpack.config.common.js",
      },
    },
  },
};

FYI: eslint-plugin-import で TypeScript の import 問題を解決する - Qiita

if using svelte

module.exports = {
  parserOptions: {
    project: "./tsconfig.json",
    tsconfigRootDir: __dirname,
  },
};