Skip to content

Commit

Permalink
fix(deps): 20156 migrate to eslint 9, review config, improve chunking (
Browse files Browse the repository at this point in the history
…#950)

* improved chunking
* eslint 9
  • Loading branch information
vkozio authored Jan 8, 2025
1 parent 476f5d6 commit 2b6b38f
Show file tree
Hide file tree
Showing 16 changed files with 891 additions and 547 deletions.
19 changes: 0 additions & 19 deletions .eslintignore

This file was deleted.

15 changes: 0 additions & 15 deletions .eslintrc.identical.keys.cjs

This file was deleted.

88 changes: 0 additions & 88 deletions .eslintrc.json

This file was deleted.

11 changes: 3 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,21 @@ package-lock.json
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.env.playwright.local
.env.*.local

web_modules

npm-debug.log*
npm-error.log*
yarn-debug.log*
yarn-error.log*
.vscode
env.yml
.pnpm-debug.log
*.log
stats.json
stats.html
template.config.js
.eslintcache
configs/config.local.json
configs/proxy-config.local.js
configs/*.local.*
public/config/appconfig.json
public/config/features.local.json
cosmos/dist/
Expand Down
149 changes: 149 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import _import from 'eslint-plugin-import';
import i18nChecker from 'eslint-plugin-i18n-checker';
import i18nJson from 'eslint-plugin-i18n-json';
import { fixupPluginRules } from '@eslint/compat';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

/** @type {import('eslint').Linter.Config[]} */
export default [
{
ignores: [
'**/postcss.config.ts',
'**/vite.config.ts',
'**/vite.proxy.ts',
'**/cosmos.decorator.tsx',
'**/template.config.js',
'**/.helpers',
'**/scripts',
'**/jest.config.js',
'**/jest.setup.js',
'**/appconfig.js',
'configs/*',
'**/__test__',
'**/*.test.tsx',
'./**/*.fixture.tsx',
'./**/fixture/*.*',
'**/*.fixture.\\{ts,tsx}',
'**/__fixtures__',
'**/__mocks__',
],
},
...compat.extends('plugin:@typescript-eslint/recommended', 'plugin:react/recommended'),
{
plugins: {
'@typescript-eslint': typescriptEslint,
react,
'react-hooks': fixupPluginRules(reactHooks),
import: fixupPluginRules(_import),
'i18n-checker': i18nChecker,
'i18n-json': i18nJson,
},

languageOptions: {
parser: tsParser,
ecmaVersion: 2020,
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.browser,
},
},

settings: {
react: {
version: 'detect',
},

'import/resolver': {
typescript: {
project: 'tsconfig.json',
},
},
},

rules: {
'import/order': [
'warn',
{
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
'type',
],

'newlines-between': 'never',
},
],

'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/ban-ts-comment': 'warn',
'react/react-in-jsx-scope': 'off',

'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrors: 'none',
},
],

'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 'warn',
'@typescript-eslint/explicit-module-boundary-types': 'off',

'react/jsx-filename-extension': [
'warn',
{
extensions: ['.jsx', '.tsx'],
},
],

'react/prop-types': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',

'i18n-checker/key-must-be-literal': [
2,
{
functionNames: ['i18n.t'],
},
],

'i18n-checker/json-key-exists': [
2,
{
functionNames: ['i18n.t'],
localesPath: 'src/core/localization/translations/en',
},
],
},
},
];
25 changes: 25 additions & 0 deletions eslintrc.identical.keys.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import path from 'node:path';
import i18nJsonPlugin from 'eslint-plugin-i18n-json';
// used in "lint:i18n:keys:identity"
export default {
files: ['src/core/localization/translations/**/*.json'],
plugins: {
'i18n-json': i18nJsonPlugin,
},
processor: {
meta: { name: '.json' },
...i18nJsonPlugin.processors['.json'],
},
rules: {
'i18n-json/identical-keys': [
'warn',
{
filePath: path.resolve('./src/core/localization/translations/en/common.json'),
ignoredKeys: [],
reportIgnoredKeys: true,
checkKeyStructure: true,
},
],
'i18n-json/valid-json': 'error',
},
};
Loading

0 comments on commit 2b6b38f

Please sign in to comment.