Fix/linting * fix import issues and add lint check no-extraneous-dependencies * fix use type HotelType instead of string Approved-by: Anton Gunnarsson
89 lines
2.5 KiB
JavaScript
89 lines
2.5 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 { 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,
|
|
},
|
|
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,
|
|
},
|
|
],
|
|
|
|
'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/no-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']),
|
|
])
|