oursky / eslint-oursky

Apache License 2.0
3 stars 3 forks source link
lint

Installation

This plugin supports eslint 9 only.

npm install --save --save-dev eslint@9.x @oursky/eslint-plugin

How to use?

The following examples are the contents of your eslint.config.mjs.

TypeScript project (e.g. Node.js backend, Turbo & Stimulus frontend)

import oursky from "@oursky/eslint-plugin";

const js = "src/**/*.{js,jsx,mjs,mjsx}";
const ts = "src/**/*.{ts,tsx,mts,mtsx}";

export default [
  {
    files: [ts],
    languageOptions: {
      parserOptions: {
        projectService: true,
        tsconfigRootDir: import.meta.dirname,
      },
    },
  },
  {
    files: [js, ts],
    ...oursky.configs.eslint,
  },
  {
    files: [ts],
    ...oursky.configs.typescript,
  },
  {
    files: [ts],
    ...oursky.configs.tsdoc,
  },
  {
    files: [js, ts],
    ...oursky.configs.oursky,
  },
];

React project in TypeScript

import oursky from "@oursky/eslint-plugin";

const js = "src/**/*.{js,jsx,mjs,mjsx}";
const ts = "src/**/*.{ts,tsx,mts,mtsx}";

export default [
  {
    files: [ts],
    languageOptions: {
      parserOptions: {
        projectService: true,
        tsconfigRootDir: import.meta.dirname,
      },
    },
  },
  {
    files: [js, ts],
    ...oursky.configs.eslint,
  },
  {
    files: [ts],
    ...oursky.configs.typescript,
  },
  {
    files: [ts],
    ...oursky.configs.tsdoc,
  },
  {
    files: [js, ts],
    ...oursky.configs.oursky,
  },
  {
    files: [js, ts],
    ...oursky.configs.react,
  },
  {
    files: [js, ts],
    ...oursky.configs["react-hooks"],
  },
];

React Native Project in TypeScript

import oursky from "@oursky/eslint-plugin";

const js = "src/**/*.{js,jsx,mjs,mjsx}";
const ts = "src/**/*.{ts,tsx,mts,mtsx}";

export default [
  {
    files: [ts],
    languageOptions: {
      parserOptions: {
        projectService: true,
        tsconfigRootDir: import.meta.dirname,
      },
    },
  },
  {
    files: [js, ts],
    ...oursky.configs.eslint,
  },
  {
    files: [ts],
    ...oursky.configs.typescript,
  },
  {
    files: [ts],
    ...oursky.configs.tsdoc,
  },
  {
    files: [js, ts],
    ...oursky.configs.oursky,
  },
  {
    files: [js, ts],
    ...oursky.configs.react,
  },
  {
    files: [js, ts],
    ...oursky.configs["react-hooks"],
  },
  {
    files: [js, ts],
    ...oursky.configs["react-native"],
  },
];

What about other use cases?

You are not supposed to have other use cases at Oursky. Open an issue if you want to discuss.

I want to disable / enable a rule in my project. How can I do that?

You use ordinary object rest spread to override.

import oursky from "@oursky/eslint-plugin";

const js = "src/**/*.{js,jsx,mjs,mjsx}";
const ts = "src/**/*.{ts,tsx,mts,mtsx}";

export default [
  {
    files: [ts],
    languageOptions: {
      parserOptions: {
        projectService: true,
        tsconfigRootDir: import.meta.dirname,
      },
    },
  },
  {
    files: [js, ts],
    ...oursky.configs.eslint,
  },
  {
    files: [ts],
    ...oursky.configs.typescript,
    rules: {
      ...oursky.configs.typescript.rules,
      "@typescript-eslint/parameter-properties": "off",
      "@typescript-eslint/no-restricted-types": [
        "error",
        {
          "types": {
            "BrokenType": "BrokenType is broken. Use NonBrokenType instead",
          },
        },
      ]
    },
  },
  {
    files: [ts],
    ...oursky.configs.tsdoc,
  },
  {
    files: [js, ts],
    ...oursky.configs.oursky,
  },
  {
    files: [js, ts],
    ...oursky.configs.react,
  },
  {
    files: [js, ts],
    ...oursky.configs["react-hooks"],
  },
  {
    files: [js, ts],
    ...oursky.configs["react-native"],
  },
];