Skip to content

Commit

Permalink
add jest configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
achou11 committed Feb 3, 2025
1 parent ad35fdc commit 5ad46a7
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 40 deletions.
88 changes: 48 additions & 40 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import js from '@eslint/js';
import pluginQuery from '@tanstack/eslint-plugin-query';
// @ts-expect-error Requires updating tsconfig (see https://github.com/typescript-eslint/typescript-eslint/issues/7284)
import * as tsParser from '@typescript-eslint/parser';
import jest from 'eslint-plugin-jest';
import reactNative from 'eslint-plugin-react-native';
import globals from 'globals';
import tseslint from 'typescript-eslint';
Expand Down Expand Up @@ -53,51 +54,58 @@ const backendConfig = tseslint.config({
},
});

const frontendConfig = tseslint.config({
name: 'frontend',
files: ['src/frontend/**/*.{js,jsx,ts,tsx}'],
extends: [
tseslint.configs.recommended,
pluginQuery.configs['flat/recommended'],
react.configs['recommended-typescript'],
react.configs['disable-dom'],
// https://github.com/facebook/react-native/issues/42996#issuecomment-2275994981
{
name: 'eslint-plugin-react-native',
plugins: {
'react-native': fixupPluginRules({
// @ts-expect-error
rules: reactNative.rules,
}),
},
rules: {
...reactNative.configs.all.rules,
'react-native/sort-styles': 'off',
'react-native/no-inline-styles': 'off',
'react-native/no-color-literals': 'warn',
},
},
],
rules: {
// Allow unused vars if prefixed with `_` (https://typescript-eslint.io/rules/no-unused-vars/)
'@typescript-eslint/no-unused-vars': [
'error',
const frontendConfig = tseslint.config(
{
name: 'frontend',
files: ['src/frontend/**/*.{js,jsx,ts,tsx}'],
extends: [
tseslint.configs.recommended,
pluginQuery.configs['flat/recommended'],
react.configs['recommended-typescript'],
react.configs['disable-dom'],
// https://github.com/facebook/react-native/issues/42996#issuecomment-2275994981
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
name: 'eslint-plugin-react-native',
plugins: {
'react-native': fixupPluginRules({
// @ts-expect-error
rules: reactNative.rules,
}),
},
rules: {
...reactNative.configs.all.rules,
'react-native/sort-styles': 'off',
'react-native/no-inline-styles': 'off',
'react-native/no-color-literals': 'warn',
},
},
],
'@typescript-eslint/no-require-imports': 'warn',
rules: {
// Allow unused vars if prefixed with `_` (https://typescript-eslint.io/rules/no-unused-vars/)
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/no-require-imports': 'warn',
},
languageOptions: {
parser: tsParser,
},
},
languageOptions: {
parser: tsParser,
{
...jest.configs['flat/recommended'],
name: 'eslint-plugin-jest',
files: ['src/frontend/**/*.test.{js,jsx,ts,tsx}'],
},
});
);

export default tseslint.config(
js.configs.recommended,
Expand Down
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
"date-fns": "3.6.0",
"dotenv-cli": "7.4.2",
"eslint": "9.19.0",
"eslint-plugin-jest": "28.11.0",
"eslint-plugin-react-native": "5.0.0",
"execa": "8.0.1",
"glob": "10.3.15",
Expand Down

0 comments on commit 5ad46a7

Please sign in to comment.