Skip to content

Commit b5b89fa

Browse files
authored
Merge pull request marmelab#10622 from marmelab/eslint-9
Fix npm warnings when creating new app with create-react-admin
2 parents 52eefab + 7c1c00d commit b5b89fa

File tree

100 files changed

+2936
-2759
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+2936
-2759
lines changed

.eslintignore

Lines changed: 0 additions & 7 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 61 deletions
This file was deleted.

.yarn/patches/@storybook-source-loader-npm-8.4.4-55dafc88e2.patch

Lines changed: 0 additions & 28 deletions
This file was deleted.

cypress/.eslintrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
import js from '@eslint/js';
2+
import { defineConfig, globalIgnores } from 'eslint/config';
3+
import tseslint from 'typescript-eslint';
4+
import cypress from 'eslint-plugin-cypress';
5+
import jsxA11y from 'eslint-plugin-jsx-a11y';
6+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
7+
import react from 'eslint-plugin-react';
8+
import reactHooks from 'eslint-plugin-react-hooks';
9+
import globals from 'globals';
10+
11+
export default defineConfig([
12+
globalIgnores([
13+
'**/node_modules',
14+
'**/build',
15+
'**/lib',
16+
'**/esm',
17+
'**/prism.js',
18+
'packages/create-react-admin/templates/**/*',
19+
]),
20+
{
21+
name: 'eslint-js-recommended-rules',
22+
plugins: {
23+
js,
24+
},
25+
extends: ['js/recommended'],
26+
},
27+
tseslint.configs.recommended.map(conf => ({
28+
...conf,
29+
files: ['**/*.ts', '**/*.tsx'],
30+
})),
31+
{
32+
...jsxA11y.flatConfigs.recommended,
33+
ignores: ['**/*.spec.*', '**/*.stories.*'],
34+
},
35+
eslintPluginPrettierRecommended,
36+
{
37+
name: 'react',
38+
...react.configs.flat.recommended,
39+
},
40+
reactHooks.configs['recommended-latest'],
41+
{
42+
name: 'react-admin-rules',
43+
plugins: {
44+
'@typescript-eslint': tseslint.plugin,
45+
},
46+
languageOptions: {
47+
globals: {
48+
...globals.browser,
49+
...globals.node,
50+
},
51+
},
52+
rules: {
53+
'no-use-before-define': 'off',
54+
'no-restricted-imports': [
55+
'error',
56+
{
57+
paths: [
58+
{
59+
name: '@mui/material',
60+
importNames: ['makeStyles', 'createMuiTheme'],
61+
message:
62+
'Please import from @mui/material/styles instead. See https://material-ui.com/guides/minimizing-bundle-size/#option-2 for more information',
63+
},
64+
{
65+
name: '@mui/icons-material',
66+
message:
67+
"Named import from @mui/icons-material should be avoided for performance reasons. Use a default import instead. E.g. `import Dashboard from '@mui/icons-material/Dashboard';` instead of `import { Dashboard } from '@mui/icons-material';`.See https://mui.com/material-ui/guides/minimizing-bundle-size/#development-environment for more information.",
68+
},
69+
{
70+
name: 'lodash',
71+
message:
72+
"Named import from lodash should be avoided for performance reasons. Use a default import instead. E.g. `import merge from 'lodash/merge';` instead of `import { merge } from 'lodash';`.",
73+
},
74+
],
75+
},
76+
],
77+
'@typescript-eslint/no-redeclare': 'off',
78+
'@typescript-eslint/no-unused-vars': [
79+
'warn',
80+
{
81+
argsIgnorePattern: '^_',
82+
varsIgnorePattern: '^_',
83+
caughtErrorsIgnorePattern: '^_',
84+
ignoreRestSiblings: true,
85+
caughtErrors: 'none',
86+
},
87+
],
88+
'@typescript-eslint/no-explicit-any': 'off',
89+
'@typescript-eslint/prefer-as-const': 'off',
90+
'@typescript-eslint/ban-ts-comment': 'off',
91+
'@typescript-eslint/no-unused-expressions': [
92+
'error',
93+
{
94+
allowShortCircuit: true,
95+
allowTernary: true,
96+
allowTaggedTemplates: true,
97+
enforceForJSX: false,
98+
},
99+
],
100+
'@typescript-eslint/no-wrapper-object-types': 'off',
101+
'@typescript-eslint/no-unsafe-function-type': 'off',
102+
'@typescript-eslint/no-unsafe-function-types': 'off',
103+
'@typescript-eslint/no-unnecessary-type-constraint': 'off',
104+
'@typescript-eslint/no-unnecessary-type-constraints': 'off',
105+
'@typescript-eslint/no-empty-object-type': 'off',
106+
'@typescript-eslint/no-empty-object-types': 'off',
107+
'react/prop-types': 'off',
108+
'react/display-name': 'off',
109+
'react/jsx-key': 'off',
110+
'react/no-unescaped-entities': 'off',
111+
'react/no-children-prop': 'off',
112+
'react/no-children-props': 'off',
113+
'react/react-in-jsx-scope': 'off',
114+
eqeqeq: ['warn', 'smart'],
115+
'no-case-declarations': 'off',
116+
'no-prototype-builtins': 'off',
117+
'prefer-spread': 'off',
118+
'jsx-a11y/no-autofocus': 'off',
119+
},
120+
settings: {
121+
react: {
122+
version: 'detect',
123+
},
124+
},
125+
},
126+
{
127+
name: 'test-rules',
128+
files: ['**/*.spec.*'],
129+
languageOptions: {
130+
globals: {
131+
...globals.jest,
132+
},
133+
},
134+
rules: {
135+
'react-hooks/rules-of-hooks': 'off',
136+
},
137+
},
138+
{
139+
name: 'cypress-rules',
140+
files: ['cypress/**/*'],
141+
plugins: {
142+
cypress,
143+
},
144+
languageOptions: {
145+
globals: {
146+
...cypress.environments.globals.globals,
147+
},
148+
},
149+
},
150+
]);

examples/crm/src/companies/CompanyListFilter.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/no-anonymous-default-export */
21
import * as React from 'react';
32
import {
43
FilterList,

examples/crm/src/companies/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/no-anonymous-default-export */
21
import { CompanyList } from './CompanyList';
32
import { CompanyCreate } from './CompanyCreate';
43
import { CompanyShow } from './CompanyShow';

examples/crm/src/contacts/ContactImportDialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ export function ContactImportDialog({
211211
}
212212

213213
function millisecondsToTime(ms: number) {
214-
var seconds = Math.floor((ms / 1000) % 60);
215-
var minutes = Math.floor((ms / (60 * 1000)) % 60);
214+
const seconds = Math.floor((ms / 1000) % 60);
215+
const minutes = Math.floor((ms / (60 * 1000)) % 60);
216216

217217
return `${minutes}m ${seconds}s`;
218218
}

examples/crm/src/contacts/ContactList.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/no-anonymous-default-export */
21
import { Card, Stack } from '@mui/material';
32
import jsonExport from 'jsonexport/dist';
43
import type { Exporter } from 'react-admin';

examples/crm/src/contacts/ContactListContent.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/no-anonymous-default-export */
21
import type { Theme } from '@mui/material';
32
import {
43
Checkbox,

0 commit comments

Comments
 (0)