Add eslint rule no-relative-packages * Add eslint rule no-relative-packages Approved-by: Christian Andolf
90 lines
2.4 KiB
JavaScript
90 lines
2.4 KiB
JavaScript
import { FlatCompat } from "@eslint/eslintrc"
|
|
import js from "@eslint/js"
|
|
import typescriptEslint from "@typescript-eslint/eslint-plugin"
|
|
import tsParser from "@typescript-eslint/parser"
|
|
import { defineConfig } from "eslint/config"
|
|
import simpleImportSort from "eslint-plugin-simple-import-sort"
|
|
import importPlugin from "eslint-plugin-import"
|
|
|
|
const compat = new FlatCompat({
|
|
recommendedConfig: js.configs.recommended,
|
|
allConfig: js.configs.all,
|
|
})
|
|
|
|
export default defineConfig([
|
|
{
|
|
files: ["**/*.ts", "**/*.tsx"],
|
|
extends: compat.extends("plugin:import/typescript"),
|
|
plugins: {
|
|
"simple-import-sort": simpleImportSort,
|
|
"@typescript-eslint": typescriptEslint,
|
|
import: importPlugin,
|
|
},
|
|
|
|
linterOptions: {
|
|
reportUnusedDisableDirectives: true,
|
|
},
|
|
|
|
languageOptions: {
|
|
parser: tsParser,
|
|
},
|
|
|
|
rules: {
|
|
"no-unused-vars": "off",
|
|
"import/no-relative-packages": "error",
|
|
"simple-import-sort/imports": [
|
|
"error",
|
|
{
|
|
groups: [
|
|
["^\\u0000"],
|
|
["^node:"],
|
|
["^@?\\w"],
|
|
["^@scandic-hotels/(?!.*\u0000$).*$"],
|
|
[
|
|
"^@/constants/?(?!.*\u0000$).*$",
|
|
"^@/env/?(?!.*\u0000$).*$",
|
|
"^@/lib/?(?!.*\u0000$).*$",
|
|
"^@/server/?(?!.*\u0000$).*$",
|
|
"^@/stores/?(?!.*\u0000$).*$",
|
|
],
|
|
["^@/(?!(types|.*\u0000$)).*$"],
|
|
[
|
|
"^\\.\\.(?!/?$)",
|
|
"^\\.\\./?$",
|
|
"^\\./(?=.*/)(?!/?$)",
|
|
"^\\.(?!/?$)",
|
|
"^\\./?$",
|
|
],
|
|
["^(?!\\u0000).+\\.s?css$"],
|
|
["^node:.*\\u0000$", "^@?\\w.*\\u0000$"],
|
|
[
|
|
"^@scandichotels/.*\\u0000$",
|
|
"^@/types/.*",
|
|
"^@/.*\\u0000$",
|
|
"^[^.].*\\u0000$",
|
|
"^\\..*\\u0000$",
|
|
],
|
|
],
|
|
},
|
|
],
|
|
|
|
"simple-import-sort/exports": "error",
|
|
|
|
"@typescript-eslint/consistent-type-imports": "error",
|
|
|
|
"@typescript-eslint/no-unused-vars": [
|
|
"error",
|
|
{
|
|
args: "all",
|
|
argsIgnorePattern: "^_",
|
|
caughtErrors: "all",
|
|
caughtErrorsIgnorePattern: "^_",
|
|
destructuredArrayIgnorePattern: "^_",
|
|
varsIgnorePattern: "^_",
|
|
ignoreRestSiblings: true,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
])
|