Skip to content

Commit 25afe6d

Browse files
committed
fix: fix linting errors
1 parent eb4a0d5 commit 25afe6d

20 files changed

+346
-318
lines changed

.eslintrc.cjs

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ module.exports = {
66
'plugin:@typescript-eslint/recommended',
77
'plugin:react-hooks/recommended',
88
],
9-
ignorePatterns: ['dist', '.eslintrc.cjs'],
9+
ignorePatterns: ['dist', 'examples', 'tmp', 'old', '.eslintrc.cjs', 'vite.config.ts'],
1010
parser: '@typescript-eslint/parser',
1111
plugins: ['react-refresh'],
1212
rules: {
13+
'semi': [2, 'always'],
1314
'react-refresh/only-export-components': [
1415
'warn',
1516
{ allowConstantExport: true },
1617
],
18+
'no-trailing-spaces': ['error', { "skipBlankLines": true, "ignoreComments": true }],
1719
},
1820
}

demo/Demo.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import gosling from 'gosling.js';
33
import { AltGoslingComponent } from '../src/AltGoslingComponent';
44

5-
import { bar } from './examples/bar-static';
5+
import { bar } from './examples/bar';
66

77

88
function Demo() {
@@ -11,7 +11,7 @@ function Demo() {
1111
<>
1212
<AltGoslingComponent spec={goslingSpec}/>
1313
</>
14-
)
14+
);
1515
}
1616

17-
export default Demo
17+
export default Demo;

demo/DemoFull.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ function Demo() {
4545
return (
4646
<>
4747
<p>hello</p>
48-
<AltGoslingComponent spec={goslingSpec} test={true}/>
48+
<AltGoslingComponent spec={goslingSpec}/>
4949
</>
50-
)
50+
);
5151
}
5252

5353
function Demo2() {
@@ -82,12 +82,12 @@ function Demo2() {
8282
});
8383
}
8484

85-
return(
85+
return(
8686
<>
8787
<GoslingComponent ref={gosRef} {...props}/>
8888
</>
89-
)
90-
}
89+
);
90+
};
9191

9292

9393

@@ -96,10 +96,10 @@ function Demo2() {
9696
<p>hello</p>
9797
<AltGoslingComponent spec={goslingSpec} test={true}/>
9898
</>
99-
)
99+
);
100100
}
101101

102-
export default Demo
102+
export default Demo;
103103

104104

105105

demo/main.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from 'react'
2-
import ReactDOM from 'react-dom/client'
3-
import Demo from './Demo'
1+
import React from 'react';
2+
import ReactDOM from 'react-dom/client';
3+
import Demo from './Demo';
44

55
ReactDOM.createRoot(document.getElementById('root')!).render(
66
<Demo />
7-
)
7+
);

index.tsx

-10
This file was deleted.

src/AltGoslingComponent.tsx

+26-23
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11

2-
import { StrictMode, useEffect, useRef, useState } from 'react';
2+
import { useEffect, useRef, useState } from 'react';
33
import gosling, { GoslingComponent, GoslingSpec, HiGlassSpec } from 'gosling.js';
4-
import type { Datum } from 'gosling.js/dist/src/gosling-schema';
5-
import type { AltGoslingSpec, PreviewAlt, AltTrack, AltDataStatistics } from './schema/alt-gosling-schema';
4+
import type { Datum, AltGoslingSpec, PreviewAlt, AltTrack, AltDataStatistics } from '@alt-gosling/schema/alt-gosling-schema';
5+
6+
import { getAlt, updateAlt } from './alt-gosling-model';
7+
import { renderAltTree, renderDataPanel } from './render';
68

79
// import Grid from '@mui/material/Grid';
810
// import TextField from '@mui/material/TextField';
911

10-
import { getAlt, updateAlt } from './alt-gosling-model';
11-
import { renderAltTree, renderDataPanel } from './render';
12+
1213

1314
// import Button from '@mui/material/Button';
1415

@@ -94,7 +95,7 @@ export const AltGoslingComponent = (props: AltGoslingCompProps) => {
9495

9596
function updateDataPanelDisplay(altTrack: AltTrack, altDataStatistics: AltDataStatistics) {
9697
// console.log('updating data panel...')
97-
setAmountOfDataFetched(amountOfDataFetched + 1)
98+
setAmountOfDataFetched(amountOfDataFetched + 1);
9899
// check if id is the same
99100
// check if range is the same
100101

@@ -105,7 +106,7 @@ export const AltGoslingComponent = (props: AltGoslingCompProps) => {
105106

106107
useEffect(() => {
107108
// console.log('now its updated', selectedAltPanel)
108-
}, [selectedAltPanel])
109+
}, [selectedAltPanel]);
109110

110111
// The state of useState is updated asynchronously
111112
// Therefore, we update the panel based on SelectedAltPanel
@@ -136,25 +137,25 @@ export const AltGoslingComponent = (props: AltGoslingCompProps) => {
136137

137138
// get latest AltGoslingSpec
138139

139-
const updatedAlt = updateAlt(AltPanels.current[selectedAltPanel].data, data.id, data.data)
140+
const updatedAlt = updateAlt(AltPanels.current[selectedAltPanel].data, data.id, data.data);
140141
updateAltPanelDisplay(updatedAlt);
141-
updateDataPanelDisplay(updatedAlt.tracks[0], updatedAlt.tracks[0].data.details.dataStatistics)
142+
updateDataPanelDisplay(updatedAlt.tracks[0], updatedAlt.tracks[0].data.details.dataStatistics);
142143

143144
});
144145
}
145146

146147
return () => {
147148
gosRef.current?.api.unsubscribe('rawData');
148-
}
149+
};
149150
}, [gosRef.current]);
150151

151152

152153

153154
const AltPanelComponent = () => {
154155
// console.log('altcomp rerender')
155156
return (
156-
<div className="editor-alt-text-panel">
157-
{selectedAltPanel >= 0 &&
157+
<div className="editor-alt-text-panel">
158+
{selectedAltPanel >= 0 &&
158159
// AltPanels.current.length > selectedAltPanel &&
159160
AltPanels.current[selectedAltPanel] &&
160161
Object.keys(AltPanels.current[selectedAltPanel].data).length > 0 ? (
@@ -168,14 +169,14 @@ export const AltGoslingComponent = (props: AltGoslingCompProps) => {
168169
</>
169170
) : null}
170171
</div>
171-
)
172-
}
172+
);
173+
};
173174

174175
const DataPanelComponent = () => {
175176
// console.log('datapanel rerender')
176177
return (
177-
<div className="editor-data-panel">
178-
{/* {selectedDataPanel >= 0 &&
178+
<div className="editor-data-panel">
179+
{/* {selectedDataPanel >= 0 &&
179180
// AltPanels.current.length > selectedAltPanel &&
180181
DataPanels.current[selectedDataPanel] ? ( */}
181182
<>
@@ -188,13 +189,15 @@ export const AltGoslingComponent = (props: AltGoslingCompProps) => {
188189
</>
189190
{/* ) : null} */}
190191
</div>
191-
)
192-
}
192+
);
193+
};
193194

194195

195196
return(
196197
<>
197-
<GoslingComponent ref={gosRef} {...props} compiled={(gs: GoslingSpec, hs: HiGlassSpec, additionalData: any) => {setSpecProcessed(additionalData['_processedSpec'] as AltGoslingSpec)}}/>
198+
<GoslingComponent ref={gosRef} {...props} compiled={(gs: GoslingSpec, hs: HiGlassSpec, additionalData: any) => {
199+
setSpecProcessed(additionalData['_processedSpec'] as AltGoslingSpec);
200+
}}/>
198201

199202
<AltPanelComponent/>
200203

@@ -204,8 +207,8 @@ export const AltGoslingComponent = (props: AltGoslingCompProps) => {
204207
<Button variant="contained" onClick={doSomething}>Reset example</Button>
205208
</div> */}
206209
</>
207-
)
208-
}
210+
);
211+
};
209212

210213
export default AltGoslingComponent;
211214

@@ -336,7 +339,7 @@ export default AltGoslingComponent;
336339

337340

338341
// // i want the ref to point to goslingcomponent
339-
// //
342+
// //
340343

341344
// // export const AltGoslingComponent = forwardRef<GoslingRef>((props, gosRef) => {
342345

@@ -378,7 +381,7 @@ export default AltGoslingComponent;
378381
// // useEffect(() => {
379382
// // gosApi.subscribe('rawData', (_: string, data: {id: string, data: Datum[]}) => {
380383
// // console.log('Updated data was seen for', data.id);
381-
// // });
384+
// // });
382385
// // // return () => {
383386
// // // gosApi.unsubscribe('rawData');
384387
// // // }

0 commit comments

Comments
 (0)