fix(SW-3691): Setup one prettier config for whole repo * Setup prettierrc in root and remove other configs Approved-by: Joakim Jäderberg Approved-by: Linus Flood
99 lines
2.7 KiB
JavaScript
99 lines
2.7 KiB
JavaScript
import { defineConfig, globalIgnores } from "eslint/config"
|
|
import globals from "globals"
|
|
import tsParser from "@typescript-eslint/parser"
|
|
import reactRefresh from "eslint-plugin-react-refresh"
|
|
import react from "eslint-plugin-react"
|
|
import { FlatCompat } from "@eslint/eslintrc"
|
|
import js from "@eslint/js"
|
|
import importPlugin from "eslint-plugin-import"
|
|
import formatjs from "eslint-plugin-formatjs"
|
|
|
|
import { fileURLToPath } from "node:url"
|
|
import path from "node:path"
|
|
|
|
const compat = new FlatCompat({
|
|
recommendedConfig: js.configs.recommended,
|
|
allConfig: js.configs.all,
|
|
})
|
|
|
|
const packageDir = path.dirname(fileURLToPath(import.meta.url))
|
|
|
|
export default defineConfig([
|
|
{
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.browser,
|
|
},
|
|
parser: tsParser,
|
|
},
|
|
extends: compat.extends(
|
|
"eslint:recommended",
|
|
"plugin:@typescript-eslint/recommended",
|
|
"plugin:react-hooks/recommended",
|
|
"plugin:storybook/recommended"
|
|
),
|
|
plugins: {
|
|
"react-refresh": reactRefresh,
|
|
import: importPlugin,
|
|
formatjs,
|
|
react,
|
|
},
|
|
settings: {
|
|
// Ensure the plugin can resolve workspace packages and TS path aliases
|
|
"import/resolver": {
|
|
typescript: {
|
|
project: [path.join(packageDir, "tsconfig.json")],
|
|
alwaysTryTypes: true,
|
|
},
|
|
node: {
|
|
extensions: [".js", ".jsx", ".ts", ".tsx"],
|
|
},
|
|
},
|
|
},
|
|
rules: {
|
|
"import/no-relative-packages": "error",
|
|
"import/no-extraneous-dependencies": [
|
|
"error",
|
|
{
|
|
includeInternal: true,
|
|
includeTypes: true,
|
|
packageDir: [packageDir],
|
|
},
|
|
],
|
|
"react-refresh/only-export-components": [
|
|
"warn",
|
|
{
|
|
allowConstantExport: true,
|
|
},
|
|
],
|
|
"react/jsx-curly-brace-presence": [
|
|
"error",
|
|
{
|
|
props: "never",
|
|
children: "never",
|
|
propElementValues: "always",
|
|
},
|
|
],
|
|
|
|
"formatjs/enforce-default-message": ["error", "literal"],
|
|
"formatjs/enforce-placeholders": ["error"],
|
|
"formatjs/enforce-plural-rules": ["error"],
|
|
"formatjs/no-literal-string-in-jsx": ["error"],
|
|
"formatjs/no-multiple-whitespaces": ["error"],
|
|
"formatjs/no-multiple-plurals": ["error"],
|
|
"formatjs/no-invalid-icu": ["error"],
|
|
"formatjs/enforce-id": ["error"],
|
|
"formatjs/no-complex-selectors": ["error"],
|
|
"formatjs/no-useless-message": ["error"],
|
|
"formatjs/prefer-pound-in-plural": ["error"],
|
|
},
|
|
},
|
|
{
|
|
files: ["**/*.stories.tsx"],
|
|
rules: {
|
|
"formatjs/no-literal-string-in-jsx": "off",
|
|
},
|
|
},
|
|
globalIgnores(["**/dist", "**/.eslintrc.cjs", "**/storybook-static"]),
|
|
])
|