Skip to content

Commit 68f2a80

Browse files
Add lint & format, and fix corresponding errors (#40)
1 parent 40600ac commit 68f2a80

File tree

13 files changed

+557
-60
lines changed

13 files changed

+557
-60
lines changed

.github/workflows/semgrep.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
semgrep:
8-
name: Run Semgrep
8+
name: Run Semgrep
99
runs-on: ubuntu-latest
1010
timeout-minutes: 30
1111
container:

.oxfmtrc.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"arrowParens": "avoid",
4+
"singleQuote": true,
5+
"trailingComma": "all",
6+
"printWidth": 80,
7+
"sortPackageJson": false,
8+
"sortImports": {
9+
"ignoreCase": false,
10+
"newlinesBetween": true,
11+
"groups": [
12+
["side_effect"],
13+
["builtin"],
14+
["external"],
15+
["parent"],
16+
["sibling"],
17+
["index"]
18+
]
19+
}
20+
}

.oxlintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": ["eslint", "import", "oxc", "react", "typescript"]
3+
}

.yarnrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
nodeLinker: node-modules
22

3-
npmMinimalAgeGate: 7d
3+
npmMinimalAgeGate: 7d

README.md

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ To test your plugin in Sigma Plugin Dev Playground, you must:
3232
To test a development version of a registered plugin, you must:
3333

3434
- Have either:
35-
3635
- An Admin account type
3736
- A custom account type that supports plugin developer feature permissions
3837

@@ -106,7 +105,6 @@ and a React Hooks API.
106105
```
107106

108107
7. Start developing:
109-
110108
- Get started with Sigma’s Plugin APIs.
111109
- Test your plugin directly in a Sigma workbook using the Sigma Plugin Dev
112110
Playground.
@@ -264,14 +262,14 @@ type CustomPluginConfigOptions =
264262
label?: string;
265263
}
266264
| {
267-
type: 'action-effect';
268-
name: string;
269-
label?: string;
270-
}
265+
type: 'action-effect';
266+
name: string;
267+
label?: string;
268+
}
271269
| {
272-
type: 'url-parameter';
273-
name: string;
274-
};
270+
type: 'url-parameter';
271+
name: string;
272+
};
275273
```
276274
277275
</details>
@@ -814,9 +812,12 @@ console.log(urlParam?.value);
814812
client.config.setUrlParameter('myParamId', 'new-value');
815813
816814
// Subscribe to changes
817-
const unsubscribe = client.config.subscribeToUrlParameter('myParamId', (urlParam) => {
818-
console.log('URL parameter updated:', urlParam.value);
819-
});
815+
const unsubscribe = client.config.subscribeToUrlParameter(
816+
'myParamId',
817+
urlParam => {
818+
console.log('URL parameter updated:', urlParam.value);
819+
},
820+
);
820821
```
821822
822823
#### useInteraction()
@@ -904,33 +905,27 @@ Github.
904905
### Available Plugins
905906
906907
- **Recharts Bar Chart** - A basic bar chart built with the Recharts library.
907-
908908
- [Source Code](https://github.com/sigmacomputing/sigma-sample-plugins/tree/main/sample-plugin-bar-chart)
909909
- Production URL: https://sigma-sample-bar-chart-54049.netlify.app/
910910
911911
- **D3 Candlestick** - A candlestick visualization built with D3.
912-
913912
- [Source Code](https://github.com/sigmacomputing/sigma-sample-plugins/tree/main/sample-plugin-bar-chart)
914913
- Production URL: https://sigma-sample-candlestick-chart-1664e5.netlify.app/
915914
916915
- **Narrative Science Quill** - Demonstrates secure text entry.
917-
918916
- [Source Code]()
919917
- Production URL: https://narrativescience-quill-3ee312.netlify.app/
920918
921919
- **D3 Graph** - Demonstrates usage of multiple data sources and in-memory
922920
joins.
923-
924921
- [Source Code](https://github.com/sigmacomputing/sigma-sample-plugins/tree/main/d3-graph)
925922
- Production URL: https://d3-graph-3a0d0f.netlify.app/
926923
927924
- **D3 Sunburst** - A sunburst visualization built with D3.
928-
929925
- [Source Code](https://github.com/sigmacomputing/sigma-sample-plugins/tree/main/d3-sunburst)
930926
- Production URL: https://d3-sunburst-b97c7c.netlify.app/
931927
932928
- **Frappe Heatmap** - A basic Frappe visualization example.
933-
934929
- [Source Code](https://github.com/sigmacomputing/sigma-sample-plugins/tree/main/frappe-heatmap)
935930
- Production URL: https://frappe-heatmap-9a4163.netlify.app/
936931

jest.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import path from 'path';
2+
23
import { Config } from '@jest/types';
34

45
const config: Config.InitialOptions = {

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"scripts": {
3131
"build": "yarn tsc --build tsconfig.build.json",
3232
"build:watch": "yarn build --watch",
33-
"format": "prettier --write 'src/**/*.{ts,tsx}' 'jest.config.ts'",
33+
"format": "yarn oxfmt",
34+
"lint": "yarn oxlint",
3435
"precommit": "lint-staged",
3536
"prepublish": "yarn build",
3637
"test": "jest --ci",
@@ -49,7 +50,9 @@
4950
"jest": "^27.5.1",
5051
"jest-watch-typeahead": "^2.1.1",
5152
"lint-staged": "^13.0.3",
52-
"prettier": "^2.7.1",
53+
"oxfmt": "^0.38.0",
54+
"oxlint": "^1.53.0",
55+
"oxlint-tsgolint": "^0.16.0",
5356
"ts-jest": "^27.1.4",
5457
"typescript": "^4.8.2"
5558
}

src/client/initialize.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ export function initialize<T = {}>(): PluginInstance<T> {
118118
},
119119

120120
config: {
121-
// @ts-ignore
121+
// @ts-ignore TODO: Fix
122122
getKey(key) {
123-
return pluginConfig?.config?.[key]!;
123+
return pluginConfig?.config?.[key];
124124
},
125125
get() {
126126
return pluginConfig.config;
@@ -219,7 +219,7 @@ export function initialize<T = {}>(): PluginInstance<T> {
219219
setUrlParameter(configId: string, value: string) {
220220
validateConfigId(configId, 'url-parameter');
221221
void execPromise('wb:plugin:url-parameter:set', configId, value);
222-
}
222+
},
223223
},
224224
elements: {
225225
getElementColumns(configId) {

src/react/Provider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type { ReactNode } from 'react';
22

3-
import { PluginContext } from './Context';
43
import { PluginInstance } from '../types';
54

5+
import { PluginContext } from './Context';
6+
67
export interface SigmaClientProviderProps<T = any> {
78
client: PluginInstance<T>;
89
children?: ReactNode;

src/react/hooks.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useContext, useEffect, useCallback, useRef, useState } from 'react';
22

3-
import { PluginContext } from './Context';
43
import {
54
PluginInstance,
65
CustomPluginConfigOptions,
@@ -13,6 +12,8 @@ import {
1312
} from '../types';
1413
import { deepEqual } from '../utils/deepEqual';
1514

15+
import { PluginContext } from './Context';
16+
1617
/**
1718
* Gets the entire plugin instance
1819
* @returns {PluginInstance} Context for the current plugin instance
@@ -118,7 +119,7 @@ export function usePaginatedElementData(
118119
if (configId) {
119120
client.elements.fetchMoreElementData(configId);
120121
}
121-
}, [configId]);
122+
}, [configId, client.elements]);
122123

123124
useEffect(() => {
124125
if (configId) {
@@ -149,7 +150,7 @@ export function useConfig(key?: string): any {
149150
setConfig(newConfig);
150151
}
151152
}),
152-
[client],
153+
[client, key, config],
153154
);
154155

155156
return config;
@@ -179,7 +180,7 @@ export function useVariable(
179180

180181
const setVariable = useCallback(
181182
(...values: unknown[]) => client.config.setVariable(id, ...values),
182-
[id],
183+
[id, client.config],
183184
);
184185

185186
return [workbookVariable, setVariable];
@@ -191,7 +192,7 @@ export function useVariable(
191192
* @returns {[(UrlParameter | undefined), Function]} Constantly updating value of the url parameter and setter for the url parameter
192193
*/
193194
export function useUrlParameter(
194-
id: string
195+
id: string,
195196
): [UrlParameter | undefined, (value: string) => void] {
196197
const client = usePlugin();
197198
const [urlParameter, setUrlParameter] = useState<UrlParameter>();
@@ -239,7 +240,7 @@ export function useInteraction(
239240
(value: WorkbookSelection[]) => {
240241
client.config.setInteraction(id, elementId, value);
241242
},
242-
[id],
243+
[id, elementId, client.config],
243244
);
244245

245246
return [workbookInteraction, setInteraction];

0 commit comments

Comments
 (0)