Skip to content

Commit a7b02df

Browse files
authored
Merge pull request #60 from microsoft/eslint-jsxa11y
Eslint
2 parents 2b9937e + f0ebe17 commit a7b02df

14 files changed

+129
-28
lines changed

eslint.config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import globals from "globals";
22
import pluginJs from "@eslint/js";
33
import tseslint from "typescript-eslint";
44
import pluginReact from "eslint-plugin-react";
5-
5+
import jsxA11y from "eslint-plugin-jsx-a11y";
66

77
/** @type {import('eslint').Linter.Config[]} */
88
export default [
@@ -18,6 +18,9 @@ export default [
1818
...tseslint.configs.recommended,
1919
pluginReact.configs.flat.recommended,
2020
{
21+
plugins: {
22+
'jsx-a11y': jsxA11y,
23+
},
2124
rules: {
2225
"@typescript-eslint/ban-ts-comment": "off",
2326
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
@@ -27,11 +30,9 @@ export default [
2730
"@typescript-eslint/no-unused-vars": "off",
2831
"no-empty-pattern": "off",
2932
"no-empty": "off",
30-
"no-var": "off",
3133
"no-unsafe-optional-chaining": "off",
3234
"no-useless-escape": "off",
3335
"prefer-const": "off",
34-
"react/jsx-key": "off",
3536
"react/no-unescaped-entities": "off",
3637
}
3738
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"@typescript-eslint/parser": "^8.16.0",
7777
"@vitejs/plugin-react-swc": "^3.7.0",
7878
"eslint": "^9.15.0",
79+
"eslint-plugin-jsx-a11y": "^6.10.2",
7980
"eslint-plugin-react": "^7.37.2",
8081
"globals": "^15.12.0",
8182
"sass": "^1.77.6",

src/app/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ export const ExportStateButton: React.FC<{}> = ({}) => {
124124
return <Tooltip title="save session locally">
125125
<Button variant="text" onClick={()=>{
126126
function download(content: string, fileName: string, contentType: string) {
127-
var a = document.createElement("a");
128-
var file = new Blob([content], {type: contentType});
127+
let a = document.createElement("a");
128+
let file = new Blob([content], {type: contentType});
129129
a.href = URL.createObjectURL(file);
130130
a.download = fileName;
131131
a.click();

src/data/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export function tupleEqual(a: any[], b: any[]) {
139139
if (a === b) return true;
140140
if (a == null || b == null) return false;
141141
if (a.length !== b.length) return false;
142-
for (var i = 0; i < a.length; ++i) {
142+
for (let i = 0; i < a.length; ++i) {
143143
if (a[i] !== b[i]) return false;
144144
}
145145
return true;

src/views/ConceptCard.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ export const DerivedConceptForm: FC<ConceptFormProps> = function DerivedConceptF
622622
console.log(conceptShelfItems.find(f => f.id == conceptID)?.source)
623623
let chipColor = conceptShelfItems.find(f => f.id == conceptID)?.source == "original" ? theme.palette.primary.light : theme.palette.custom.main;
624624
return <Chip
625+
key={conceptID}
625626
variant="outlined" size="small"
626627
// color={}
627628
sx={{

src/views/ConceptShelf.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ export const ConceptShelf: FC<ConceptShelfProps> = function ConceptShelf() {
142142
<OperatorCard operator="bin" />
143143
</Box>
144144
{groupNames.map(gp => [
145-
<Box sx={{display: "block", width: "100%"}}>
145+
<Box
146+
key={`concept-group-${gp}`}
147+
sx={{display: "block", width: "100%"}}>
146148
<Divider orientation="horizontal" textAlign="left"><Typography component="h2" sx={{fontSize: "10px"}} color="text.secondary">
147149
{gp}
148150
</Typography></Divider>

src/views/DataThread.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,9 @@ let SingleThreadView: FC<{
217217

218218
return [
219219
regularTableBox,
220-
<Box sx={{display: 'flex', flexDirection: 'row'}}>
220+
<Box
221+
key={`table-${tableId}`}
222+
sx={{display: 'flex', flexDirection: 'row'}}>
221223
<div style={{minWidth: '1px', padding: '0px', width: '17px', flex: 'none', display: 'flex'
222224
//borderLeft: '1px dashed darkgray',
223225
}}>
@@ -381,11 +383,11 @@ export const DataThread: FC<{}> = function ({ }) {
381383
assembledChart = (({ data, ...o }) => o)(assembledChart);
382384

383385
let getRandom = (seed: number) => {
384-
var x = Math.sin(seed++) * 10000;
386+
let x = Math.sin(seed++) * 10000;
385387
return x - Math.floor(x);
386388
}
387389
let getRandomSubarray = (arr: any[], size: number) => {
388-
var shuffled = arr.slice(0), i = arr.length, temp, index;
390+
let shuffled = arr.slice(0), i = arr.length, temp, index;
389391
while (i--) {
390392
index = Math.floor((i + 1) * getRandom(233 * i + 888));
391393
temp = shuffled[index];
@@ -456,7 +458,9 @@ export const DataThread: FC<{}> = function ({ }) {
456458
{leafTables.map((lt, i) => {
457459
let usedTableIds = leafTables.slice(0, i)
458460
.map(x => [x.id, ...getTriggers(x, tables).map(y => y.tableId) || []]).flat();
459-
return <SingleThreadView scrollRef={scrollRef} threadIdx={i} leafTable={lt} chartElements={chartElements} usedTableIds={usedTableIds} />
461+
return <SingleThreadView
462+
key={`thread-${lt.id}`}
463+
scrollRef={scrollRef} threadIdx={i} leafTable={lt} chartElements={chartElements} usedTableIds={usedTableIds} />
460464
})}
461465
</Box>
462466

src/views/EncodingShelfCard.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ export const TriggerCard: FC<{className?: string, trigger: Trigger, hideFields?:
9999
.map(([channel, encoding], index) => {
100100
let field = fieldItems.find(f => f.id == encoding.fieldID) as FieldItem;
101101
return [index > 0 ? '⨉' : '',
102-
<Chip sx={{color:'inherit', maxWidth: '110px', marginLeft: "2px", height: 18, fontSize: 12, borderRadius: '4px',
102+
<Chip
103+
key={`trigger-${channel}-${field.id}`}
104+
sx={{color:'inherit', maxWidth: '110px', marginLeft: "2px", height: 18, fontSize: 12, borderRadius: '4px',
103105
border: '1px solid rgb(250 235 215)', background: 'rgb(250 235 215 / 70%)',
104106
'& .MuiChip-label': { paddingLeft: '6px', paddingRight: '6px' }}}
105107
label={`${field.name}`} />]
@@ -157,7 +159,9 @@ export const MiniTriggerCard: FC<{className?: string, trigger: Trigger, hideFiel
157159
.map(([channel, encoding], index) => {
158160
let field = fieldItems.find(f => f.id == encoding.fieldID) as FieldItem;
159161
return [index > 0 ? '⨉' : '',
160-
<Chip sx={{color:'inherit', maxWidth: '110px', marginLeft: "2px", height: 16, fontSize: 'inherit', borderRadius: '4px',
162+
<Chip
163+
key={`trigger-${channel}-${field.id}`}
164+
sx={{color:'inherit', maxWidth: '110px', marginLeft: "2px", height: 16, fontSize: 'inherit', borderRadius: '4px',
161165
border: '1px solid rgb(250 235 215)', background: 'rgb(250 235 215 / 70%)',
162166
'& .MuiChip-label': { paddingLeft: '6px', paddingRight: '6px' }}}
163167
label={`${field.name}`} />]

src/views/EncodingShelfThread.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ export let ChartElementFC: FC<{chart: Chart, tableRows: any[], boxWidth?: number
9090
assembledChart = (({ data, ...o }) => o)(assembledChart);
9191

9292
let getRandom = (seed: number) => {
93-
var x = Math.sin(seed++) * 10000;
93+
let x = Math.sin(seed++) * 10000;
9494
return x - Math.floor(x);
9595
}
9696
let getRandomSubarray = (arr: any[], size: number) => {
97-
var shuffled = arr.slice(0), i = arr.length, temp, index;
97+
let shuffled = arr.slice(0), i = arr.length, temp, index;
9898
while (i--) {
9999
index = Math.floor((i + 1) * getRandom(233 * i + 888));
100100
temp = shuffled[index];
@@ -404,7 +404,9 @@ export const EncodingShelfThread: FC<EncodingShelfThreadProps> = function ({ cha
404404
}
405405

406406
//let triggers = currentTable.derive.triggers;
407-
let tableList = activeTableThread.map((tableId) => <div className="table-list-item">
407+
let tableList = activeTableThread.map((tableId) => <div
408+
key={tableId}
409+
className="table-list-item">
408410
<Button variant="text" sx={{textTransform: 'none', padding: 0, minWidth: 0}} onClick={() => { dispatch(dfActions.setFocusedTable(tableId)) }}>
409411
<Stack direction="row" sx={{fontSize: '12px'}} alignItems="center" gap={"2px"}>
410412
<TableRowsIcon fontSize="inherit" />
@@ -416,7 +418,9 @@ export const EncodingShelfThread: FC<EncodingShelfThreadProps> = function ({ cha
416418
</div>);
417419

418420
let tableCards = activeTableThread.map((tableId) =>
419-
<Card variant='outlined' sx={{padding: '2px 0 2px 0'}}>
421+
<Card
422+
key={tableId}
423+
variant='outlined' sx={{padding: '2px 0 2px 0'}}>
420424
<Button variant="text" sx={{textTransform: 'none', padding: 0, marginLeft: 1, minWidth: 0}} onClick={() => { dispatch(dfActions.setFocusedTable(tableId)) }}>
421425
<Stack direction="row" sx={{fontSize: '12px'}} alignItems="center" gap={"2px"}>
422426
<TableRowsIcon fontSize="inherit" />
@@ -439,7 +443,9 @@ export const EncodingShelfThread: FC<EncodingShelfThreadProps> = function ({ cha
439443
let currentActiveFields = new Set(extractActiveFields(trigger))
440444
let fieldsIdentical = _.isEqual(previousActiveFields, currentActiveFields)
441445

442-
return <Box sx={{padding: 0, display: 'flex'}}>
446+
return <Box
447+
key={trigger.tableId}
448+
sx={{padding: 0, display: 'flex'}}>
443449
{/* <SouthIcon sx={{fontSize: "inherit", margin: 'auto 4px'}} /> */}
444450
<Box sx={{minWidth: '1px', padding: '0px', width: '17px', flex: 'none', display: 'flex', flexDirection: 'column'
445451
//borderLeft: '1px dashed darkgray',
@@ -501,7 +507,9 @@ export const EncodingShelfThread: FC<EncodingShelfThreadProps> = function ({ cha
501507
let postInstructEndPoint = activeTableThread.findIndex(s => s == activeThreadChart.tableRef);
502508
postInstruction = <Collapse orientation="vertical" in={true} sx={{width: "100%"}}>
503509
<Box sx={{padding: '4px 0px', display: 'flex', flexDirection: "column" }}>
504-
{interleaveArrays([<Box sx={{width: '17px', height: '12px'}}>
510+
{interleaveArrays([<Box
511+
key="post-instruction"
512+
sx={{width: '17px', height: '12px'}}>
505513
<Box sx={{padding:0, width: '1px', margin:'auto', height: '100%',
506514
backgroundImage: 'linear-gradient(180deg, darkgray, darkgray 75%, transparent 75%, transparent 100%)',
507515
backgroundSize: '1px 6px, 3px 100%'}}></Box>
@@ -531,7 +539,9 @@ export const EncodingShelfThread: FC<EncodingShelfThreadProps> = function ({ cha
531539
</Typography>
532540
</Box> */}
533541
{[
534-
<Box sx={{display: 'flex'}}>
542+
<Box
543+
key="encoding-shelf"
544+
sx={{display: 'flex'}}>
535545
{previousInstructions}
536546
</Box>,
537547
// <Box sx={{padding: '4px 0px', background: 'aliceblue', margin: 'auto', width: '200px', height: '6px', paddingBottom: 0.5}}></Box>

src/views/InfoPanel.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export const InfoPanelFC: FC<{ $tableRef: React.RefObject<AgGridReact | Selectab
7373
return {
7474
id: `simple-tab-${index}`,
7575
'aria-controls': `simple-tabpanel-${index}`,
76-
key: `simple-tab-${index}`
7776
};
7877
}
7978

@@ -89,7 +88,9 @@ export const InfoPanelFC: FC<{ $tableRef: React.RefObject<AgGridReact | Selectab
8988
<IconButton color="primary" sx={{ borderRadius: 0 }} onClick={() => { setHidePanel(!hidePanel) }}>{hidePanel ? <UnfoldMoreIcon /> : <UnfoldLessIcon />}</IconButton>
9089
<Tabs value={Math.abs(tabValue)} >
9190
{tabEntries.map((entry, index) => (
92-
<Tab className={entry.highlight && index != tabValue ? "background-highlight" : ''}
91+
<Tab
92+
key={`simple-tab-${index}`}
93+
className={entry.highlight && index != tabValue ? "background-highlight" : ''}
9394
onClick={(event) => { handleTabSwitch(event, index) }} label={entry.label} {...a11yProps(index)}
9495
sx={{ "&.MuiTab-root": { "textTransform": "none" } }} />))}
9596
</Tabs>

0 commit comments

Comments
 (0)