Skip to content

Commit 2982d4b

Browse files
authored
Switch to airbnb eslint (#466)
Signed-off-by: Ayoub LABIDI <[email protected]>
1 parent 9cafed5 commit 2982d4b

File tree

194 files changed

+2920
-2783
lines changed

Some content is hidden

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

194 files changed

+2920
-2783
lines changed

.eslintrc.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
{
22
"root": true,
33
"extends": [
4-
"react-app",
5-
"plugin:prettier/recommended"
4+
"airbnb",
5+
"airbnb-typescript",
6+
"airbnb/hooks",
7+
"plugin:prettier/recommended",
8+
"plugin:react/jsx-runtime"
69
],
10+
"parserOptions": {
11+
"project": "./tsconfig.json"
12+
},
713
"ignorePatterns": [
814
// node_modules is implicitly always ignored
9-
"dist"
15+
"dist",
16+
"vite.config.mts",
17+
"jest.config.ts",
18+
"jest.setup.ts"
1019
],
1120
"rules": {
1221
"prettier/prettier": "warn",
13-
"curly": "error"
22+
"curly": "error",
23+
"no-console": "off",
24+
"react/jsx-props-no-spreading": "off",
25+
"react/require-default-props": "off",
26+
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }]
1427
}
1528
}

babel.config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{
22
"presets": [
3+
"airbnb",
34
"@babel/preset-env",
45
["@babel/preset-react", { "runtime": "automatic" }],
56
"@babel/preset-typescript",
67
"babel-preset-vite"
8+
],
9+
"plugins": [
10+
"@babel/plugin-transform-runtime"
711
]
812
}

demo/data/EquipmentSearchBar.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const EQUIPMENTS = [
148148
},
149149
];
150150

151-
export const searchEquipments = (searchTerm, equipmentLabelling) => {
151+
const searchEquipments = (searchTerm, equipmentLabelling) => {
152152
if (searchTerm) {
153153
return getEquipmentsInfosForSearchBar(
154154
equipmentLabelling
@@ -160,7 +160,8 @@ export const searchEquipments = (searchTerm, equipmentLabelling) => {
160160
),
161161
equipmentLabelling ? (e) => e.name || e.id : (e) => e.id
162162
);
163-
} else {
164-
return [];
165163
}
164+
return [];
166165
};
166+
167+
export default searchEquipments;

demo/data/ReportViewer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
/* eslint-disable no-template-curly-in-string */
88

9-
export const LOGS_JSON = {
9+
const LOGS_JSON = {
1010
taskKey: 'Test',
1111
defaultName: 'Test',
1212
taskValues: {},
@@ -230,3 +230,5 @@ export const LOGS_JSON = {
230230
],
231231
reports: [],
232232
};
233+
234+
export default LOGS_JSON;

demo/data/TreeViewFinder.jsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
Whatshot as WhatshotIcon,
1616
} from '@mui/icons-material';
1717

18-
var PokemonTree = [
18+
// eslint-disable-next-line import/no-mutable-exports
19+
let PokemonTree = [
1920
{
2021
id: 'D1',
2122
name: 'Team',
@@ -116,7 +117,8 @@ var PokemonTree = [
116117
},
117118
];
118119

119-
var PokemonList = [
120+
// eslint-disable-next-line import/no-mutable-exports
121+
let PokemonList = [
120122
{
121123
id: '1',
122124
name: 'Pikachu',
@@ -137,14 +139,14 @@ var PokemonList = [
137139
{ id: '6', name: 'Machoc', type: 'Combat', power: '64' },
138140
];
139141

140-
var IDCounter = 100; // Start at 100 to avoid conflicts for demo
142+
let IDCounter = 100; // Start at 100 to avoid conflicts for demo
141143
function fetchInfinitePokemonList() {
142-
IDCounter++;
144+
IDCounter += 1;
143145
PokemonList = [
144146
...PokemonList,
145147
{
146148
id: IDCounter.toString(),
147-
name: 'Métamorph_' + new Date().getTime(),
149+
name: `Métamorph_${new Date().getTime()}`,
148150
type: 'Normal',
149151
power: '1',
150152
icon: <FiberNewIcon />,
@@ -154,20 +156,20 @@ function fetchInfinitePokemonList() {
154156
}
155157

156158
function fetchInfinitePokemonTree(nodeId) {
157-
IDCounter++;
159+
IDCounter += 1;
158160

159-
let PokemonTreeCopy = [...PokemonTree];
161+
const PokemonTreeCopy = [...PokemonTree];
160162
const dirFound = PokemonTreeCopy.find((element) => element.id === nodeId);
161163

162164
if (dirFound) {
163165
dirFound.children.push({
164166
id: IDCounter.toString(),
165-
name: 'Métamorph_' + new Date().getTime(),
167+
name: `Métamorph_${new Date().getTime()}`,
166168
type: 'Normal',
167169
power: '1',
168170
icon: <FiberNewIcon />,
169171
});
170-
dirFound.childrenCount++;
172+
dirFound.childrenCount += 1;
171173
}
172174

173175
PokemonTree = PokemonTreeCopy;

demo/src/FlatParametersTab.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { useCallback, useState } from 'react';
99
import RightResizableBox from './right-resizable-box';
10-
import FlatParameters from '../../src/components/FlatParameters/FlatParameters';
10+
import { FlatParameters } from '../../src/components/FlatParameters/FlatParameters';
1111

1212
const EXAMPLE_PARAMETERS = [
1313
{
@@ -198,7 +198,7 @@ const EXAMPLE_PARAMETERS = [
198198
},
199199
];
200200

201-
export const FlatParametersTab = () => {
201+
function FlatParametersTab() {
202202
const [currentParameters, setCurrentParameters] = useState({});
203203
const onChange = useCallback((paramName, value, isEdit) => {
204204
if (!isEdit) {
@@ -217,7 +217,7 @@ export const FlatParametersTab = () => {
217217
paramsAsArray={EXAMPLE_PARAMETERS}
218218
initValues={currentParameters}
219219
onChange={onChange}
220-
variant={'standard'}
220+
variant="standard"
221221
showSeparator
222222
selectionWithDialog={(param) =>
223223
param?.possibleValues?.length > 10
@@ -226,4 +226,6 @@ export const FlatParametersTab = () => {
226226
</RightResizableBox>
227227
</div>
228228
);
229-
};
229+
}
230+
231+
export default FlatParametersTab;

demo/src/InputsTab.jsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as yup from 'yup';
99
import { yupResolver } from '@hookform/resolvers/yup';
1010
import { useForm } from 'react-hook-form';
1111
import { Box, Grid } from '@mui/material';
12+
import { useState } from 'react';
1213
import AutocompleteInput from '../../src/components/inputs/react-hook-form/autocomplete-inputs/autocomplete-input';
1314
import TextInput from '../../src/components/inputs/react-hook-form/text-input';
1415
import RadioInput from '../../src/components/inputs/react-hook-form/radio-input';
@@ -22,7 +23,6 @@ import SubmitButton from '../../src/components/inputs/react-hook-form/utils/subm
2223
import ExpandingTextField from '../../src/components/inputs/react-hook-form/ExpandingTextField';
2324
import CustomFormProvider from '../../src/components/inputs/react-hook-form/provider/custom-form-provider';
2425
import SelectClearable from '../../src/components/inputs/select-clearable';
25-
import { useState } from 'react';
2626

2727
const AUTOCOMPLETE_INPUT = 'autocomplete';
2828
const TEXT_INPUT = 'text';
@@ -84,7 +84,7 @@ const areIdsEqual = (val1, val2) => {
8484
const logWhenValuesChange = false;
8585
const logWhenValidate = true;
8686

87-
export function InputsTab() {
87+
function InputsTab() {
8888
const formMethods = useForm({
8989
defaultValues: emptyFormData,
9090
resolver: yupResolver(formSchema),
@@ -124,26 +124,26 @@ export function InputsTab() {
124124
<AutocompleteInput
125125
name={AUTOCOMPLETE_INPUT}
126126
options={basicOptions}
127-
label={'inputs/autocomplete'}
127+
label="inputs/autocomplete"
128128
isOptionEqualToValue={areIdsEqual}
129129
/>
130130
</Grid>
131131
<Grid item xs={gridSize}>
132-
<TextInput name={TEXT_INPUT} label={'inputs/text'} />
132+
<TextInput name={TEXT_INPUT} label="inputs/text" />
133133
</Grid>
134134
<Grid item xs={gridSize}>
135135
<ExpandingTextField
136136
name={DESCRIPTION_INPUT}
137-
label={'inputs/description'}
137+
label="inputs/description"
138138
maxCharactersNumber={300}
139139
minRows={2}
140140
rows={4}
141-
></ExpandingTextField>
141+
/>
142142
</Grid>
143143
<Grid item xs={gridSize}>
144144
<SliderInput
145145
name={SLIDER_INPUT}
146-
label={'inputs/slider'}
146+
label="inputs/slider"
147147
min={0.0}
148148
max={100.0}
149149
step={0.1}
@@ -152,44 +152,44 @@ export function InputsTab() {
152152
<Grid item xs={gridSize}>
153153
<SelectInput
154154
name={SELECT_INPUT}
155-
label={'inputs/select'}
155+
label="inputs/select"
156156
options={options}
157157
/>
158158
</Grid>
159159
<Grid item xs={gridSize}>
160160
<SelectClearable
161161
value={selectValue}
162162
onChange={setSelectValue}
163-
label={'inputs/select'}
163+
label="inputs/select"
164164
options={options}
165165
/>
166166
</Grid>
167167
<Grid item xs={gridSize}>
168168
<RadioInput
169169
name={RADIO_INPUT}
170-
label={'inputs/radio'}
170+
label="inputs/radio"
171171
options={options}
172172
/>
173173
</Grid>
174174
<Grid item xs={gridSize}>
175175
<IntegerInput
176176
name={INTEGER_INPUT}
177-
label={'inputs/integer'}
177+
label="inputs/integer"
178178
/>
179179
</Grid>
180180
<Grid item xs={gridSize}>
181-
<FloatInput name={FLOAT_INPUT} label={'inputs/float'} />
181+
<FloatInput name={FLOAT_INPUT} label="inputs/float" />
182182
</Grid>
183183
<Grid item xs={gridSize}>
184184
<CheckboxInput
185185
name={CHECKBOX_INPUT}
186-
label={'inputs/checkbox'}
186+
label="inputs/checkbox"
187187
/>
188188
</Grid>
189189
<Grid item xs={gridSize}>
190190
<SwitchInput
191191
name={SWITCH_INPUT}
192-
label={'inputs/switch'}
192+
label="inputs/switch"
193193
/>
194194
</Grid>
195195
</Grid>
@@ -206,3 +206,5 @@ export function InputsTab() {
206206
</CustomFormProvider>
207207
);
208208
}
209+
210+
export default InputsTab;

0 commit comments

Comments
 (0)