🚨(frontend) add lib eslint-config-impress

Create the eslint-config-impress package to share
eslint configuration with all impress projects.
This commit is contained in:
Anthony LC
2024-04-02 12:09:10 +02:00
parent c3e354d727
commit c64b66c797
10 changed files with 11635 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
module.exports = {
semi: true,
trailingComma: 'all',
singleQuote: true,
printWidth: 80,
tabWidth: 2,
};

31
src/frontend/package.json Normal file
View File

@@ -0,0 +1,31 @@
{
"name": "impress",
"version": "0.1.0",
"private": true,
"workspaces": {
"packages": [
"apps/*",
"packages/*"
]
},
"scripts": {
"APP_IMPRESS": "yarn workspace app-impress",
"APP_E2E": "yarn workspace app-e2e",
"I18N": "yarn workspace packages-i18n",
"app:dev": "yarn APP_IMPRESS run dev",
"app:start": "yarn APP_IMPRESS run start",
"app:build": "yarn APP_IMPRESS run build",
"app:test": "yarn APP_IMPRESS run test",
"ci:build": "yarn APP_IMPRESS run build:ci",
"e2e:test": "yarn APP_E2E run test",
"lint": "yarn APP_IMPRESS run lint && yarn APP_E2E run lint && yarn workspace eslint-config-impress run lint && yarn I18N run lint",
"i18n:extract": "yarn I18N run extract-translation",
"i18n:deploy": "yarn I18N run format-deploy",
"i18n:test": "yarn I18N run test"
},
"resolutions": {
"@types/node": "20.12.2",
"@types/react-dom": "18.2.23",
"typescript": "5.4.3"
}
}

View File

@@ -0,0 +1,21 @@
const common = require('./common');
module.exports = {
root: true,
settings: {
react: {
version: 'detect',
},
},
extends: [
'plugin:prettier/recommended',
'plugin:import/recommended',
'plugin:react/recommended',
],
rules: common.globalRules,
parserOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
},
ignorePatterns: ['node_modules'],
};

View File

@@ -0,0 +1,71 @@
const eslintTS = [
{
files: ['*.ts', '*.tsx'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'sort-imports': [
'error',
{
ignoreDeclarationSort: true,
},
],
},
},
{
files: ['*.d.ts'],
rules: {
'no-unused-vars': 'off',
},
},
];
const globalRules = {
'block-scoped-var': 'error',
curly: ['error', 'all'],
'import/no-duplicates': ['error', { considerQueryString: false }],
'import/order': [
'error',
{
alphabetize: {
order: 'asc',
},
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
pathGroups: [
{
pattern: '@/**',
group: 'internal',
},
],
pathGroupsExcludedImportTypes: ['builtin'],
'newlines-between': 'always',
warnOnUnassignedImports: true,
},
],
'no-alert': 'error',
'no-unused-vars': [
'error',
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
],
'react/jsx-curly-brace-presence': [
'error',
{ props: 'never', children: 'never', propElementValues: 'always' },
],
'sort-imports': [
'error',
{
ignoreDeclarationSort: true,
},
],
};
module.exports = { eslintTS, globalRules };

View File

@@ -0,0 +1,51 @@
const common = require('./common');
module.exports = {
extends: ['plugin:prettier/recommended', 'plugin:react/recommended'],
rules: common.globalRules,
settings: {
react: {
version: 'detect',
},
},
overrides: [
...common.eslintTS,
{
files: ['*.spec.*', '*.test.*', '**/__mock__/**/*'],
plugins: ['jest'],
extends: ['plugin:jest/recommended', 'plugin:testing-library/react'],
rules: {
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'testing-library/no-await-sync-events': [
'error',
{ eventModules: ['fire-event'] },
],
'testing-library/await-async-events': [
'error',
{
eventModule: 'userEvent',
},
],
'testing-library/no-manual-cleanup': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
],
'react/display-name': 0,
'jest/expect-expect': 'error',
'@typescript-eslint/unbound-method': 'off',
'jest/unbound-method': 'error',
'react/react-in-jsx-scope': 'off',
},
},
],
ignorePatterns: ['node_modules'],
};

View File

@@ -0,0 +1,40 @@
const common = require('./common');
module.exports = {
extends: [
'next',
'plugin:prettier/recommended',
'plugin:@tanstack/eslint-plugin-query/recommended',
'plugin:jsx-a11y/recommended',
],
parserOptions: {
babelOptions: {
presets: [require.resolve('next/babel')],
},
},
settings: {
'jsx-a11y': {
polymorphicPropName: 'as',
components: {
Input: 'input',
Button: 'button',
Box: 'div',
Text: 'span',
Select: 'select',
},
},
},
rules: {
...common.globalRules,
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
},
overrides: [
...common.eslintTS,
{
files: ['*.spec.*', '*.test.*', '**/__mock__/**/*'],
extends: ['impress/jest'],
},
],
ignorePatterns: ['node_modules'],
};

View File

@@ -0,0 +1,23 @@
{
"name": "eslint-config-impress",
"version": "0.1.0",
"license": "MIT",
"scripts": {
"lint": "eslint --ext .js ."
},
"dependencies": {
"@next/eslint-plugin-next": "14.1.4",
"@tanstack/eslint-plugin-query": "5.28.6",
"@typescript-eslint/eslint-plugin": "7.5.0",
"eslint": "8.57.0",
"eslint-config-next": "14.1.4",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jest": "27.9.0",
"eslint-plugin-jsx-a11y": "6.8.0",
"eslint-plugin-playwright": "1.5.4",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-react": "7.34.1",
"eslint-plugin-testing-library": "6.2.0"
}
}

View File

@@ -0,0 +1,34 @@
const common = require('./common');
module.exports = {
extends: ['next', 'plugin:prettier/recommended'],
settings: {
react: {
version: 'detect',
},
},
parserOptions: {
babelOptions: {
presets: [require.resolve('next/babel')],
},
},
rules: { ...common.globalRules, '@next/next/no-html-link-for-pages': 'off' },
overrides: [
...common.eslintTS,
{
files: ['**/*.ts'],
rules: {
'@typescript-eslint/no-unsafe-member-access': 'off',
},
},
{
files: ['*.spec.*', '*.test.*', '**/__mock__/**/*'],
extends: ['plugin:playwright/recommended'],
plugins: ['playwright'],
rules: {
'@typescript-eslint/no-unsafe-member-access': 'off',
},
},
],
ignorePatterns: ['node_modules'],
};

File diff suppressed because it is too large Load Diff

9201
src/frontend/yarn.lock Normal file

File diff suppressed because it is too large Load Diff