Skip to content

Commit

Permalink
feat(linting): add enforced types and jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
MatsJohansen87 committed Feb 7, 2024
1 parent aded5b1 commit 6256410
Show file tree
Hide file tree
Showing 28 changed files with 645 additions and 529 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module.exports = {
plugins: ['@typescript-eslint/eslint-plugin', 'eslint-plugin-tsdoc', 'jsdoc'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'plugin:svelte/prettier',
'eslint-config-prettier',
'prettier',
"plugin:jsdoc/recommended-typescript-error",
],
parser: '@typescript-eslint/parser',
parserOptions: {
Expand All @@ -24,7 +26,13 @@ module.exports = {
'svelte/typescript': import('typescript'),
},
rules: {
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/explicit-function-return-type': ['error', { allowExpressions: true }],
'svelte/no-at-html-tags': 'off',
'jsdoc/check-syntax': 2,
"jsdoc/check-param-names": 2,


},
ignorePatterns: ['**/dist/**'],
};
140 changes: 140 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsdoc": "^48.0.6",
"eslint-plugin-svelte": "^2.35.1",
"eslint-plugin-tsdoc": "^0.2.17",
"husky": "^9.0.9",
"lint-staged": "^15.2.1",
"prettier": "^3.2.4",
Expand Down
10 changes: 5 additions & 5 deletions packages/demo/src/AppFragmentDevelopment.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -135,25 +135,25 @@
let dataPasser: HTMLElement;
const getQuery = () => {
const getQuery = (): void => {
console.log(dataPasser, dataPasser.getQueryAPI());
queryStore = dataPasser.getQueryAPI();
};
const getResponse = () => {
const getResponse = (): void => {
console.log(dataPasser, dataPasser.getResponseAPI());
};
const getAST = () => {
const getAST = (): void => {
console.log(dataPasser, dataPasser.getAstAPI());
};
const removeItem = (queryObject) => {
const removeItem = (queryObject): void => {
dataPasser.removeItemFromQuyeryAPI({ queryObject });
getQuery();
};
const removeValue = (queryItem: QueryItem, value: QueryValue) => {
const removeValue = (queryItem: QueryItem, value: QueryValue): void => {
console.log(queryItem, value);
dataPasser.removeValueFromQueryAPI({ queryItem, value });
getQuery();
Expand Down
11 changes: 8 additions & 3 deletions packages/lib/src/classes/blaze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ export class Blaze {
private auth: string = "",
) {}

async send(cql: string, controller?: AbortController) {
/**
* sends the query to beam and updates the store with the results
* @param cql the query as cql string
* @param controller the abort controller to cancel the request
*/
async send(cql: string, controller?: AbortController): Promise<void> {
try {
responseStore.update((store) => {
store.set(this.name, { status: "claimed", data: null });
Expand All @@ -30,7 +35,7 @@ export class Blaze {
"Content-Type": "application/json",
},
body: JSON.stringify(buildLibrary(cql)),
signal: controller.signal,
signal: controller?.signal,
},
);
if (!libraryResponse.ok) {
Expand Down Expand Up @@ -91,7 +96,7 @@ export class Blaze {
}
}

async handleError(message: string, response: Response) {
async handleError(message: string, response: Response): Promise<void> {
const errorMessage = await response.text();
console.debug(
`${message}. Received error ${response.status} with message ${errorMessage}`,
Expand Down
13 changes: 9 additions & 4 deletions packages/lib/src/classes/spot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ type BeamResult = {
};

export class Spot {
private storeCache: ResponseStore;
private currentTask: string;
private storeCache!: ResponseStore;
private currentTask!: string;

constructor(
private url: URL,
Expand All @@ -29,7 +29,12 @@ export class Spot {
);
}

async send(query: string, controller?: AbortController) {
/**
* sends the query to beam and updates the store with the results
* @param query the query as base64 encoded string
* @param controller the abort controller to cancel the request
*/
async send(query: string, controller?: AbortController): Promise<void> {
try {
const beamTaskResponse = await fetch(
`${this.url}tasks?sites=${this.sites.toString()}`,
Expand All @@ -56,7 +61,7 @@ export class Spot {
`${this.url}tasks/${this.currentTask}?wait_count=${responseCount + 1}`,
{
credentials: import.meta.env.PROD ? "include" : "omit",
signal: controller.signal,
signal: controller?.signal,
},
);

Expand Down
11 changes: 5 additions & 6 deletions packages/lib/src/components/Options.wc.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
customElement={{
tag: "lens-options",
props: {
options: {type: 'Object'},
options: { type: "Object" },
catalogueData: { type: "Object" },
},
}}
Expand All @@ -12,15 +12,14 @@
/**
* this component takes the catalogue and all options set from the project and passes them to the appropriate store
* TODO: refactor all mappings and configurations to be passed in here
*/
import {lensOptions} from "../stores/options";
*/
import { lensOptions } from "../stores/options";
import { catalogue } from "../stores/catalogue";
import type { Criteria } from "../types/treeData";
export let options: object = {};
export let catalogueData: Criteria[] = [];
$: $lensOptions = options;
$: $catalogue = catalogueData;
</script>
</script>
Loading

0 comments on commit 6256410

Please sign in to comment.