Skip to content

Commit

Permalink
Tweak linter configuration and apply changes to source files (#372)
Browse files Browse the repository at this point in the history
* Update linter settings and apply changes to source

* Update package-lock.json hash in flake.nix
  • Loading branch information
georgestagg authored Mar 5, 2024
1 parent bd6ae01 commit 06fbb3c
Show file tree
Hide file tree
Showing 41 changed files with 1,346 additions and 2,330 deletions.
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# cd src; prefetch-npm-deps package-lock.json
srcNpmDeps = pkgs.fetchNpmDeps {
src = "${self}/src";
hash = "sha256-EoNkNZRRgFnrIDYP2syveGaOfRrwsc+WLPRTGMBq7ro=";
hash = "sha256-3lhRylOg3XGk+06gyYeABmapvJWeFHxOlN2qpC2I7pg=";
};

inherit system;
Expand Down
69 changes: 34 additions & 35 deletions src/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,47 @@ module.exports = {
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:jsdoc/recommended',
'google',
'./node_modules/gts',
'plugin:jest/recommended',
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:jsdoc/recommended",
"plugin:jest/recommended",
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
tsconfigRootDir: __dirname,
project: ["./tsconfig.json"],
},
ignorePatterns: ['.eslintrc.js', 'pre.js', 'esbuild.js', 'jest.config.js'],
plugins: ['@typescript-eslint', 'jest', 'jsdoc', 'react'],
ignorePatterns: [
".eslintrc.js",
"pre.js",
"esbuild.js",
"jest.config.js",
"tests/webr.config.js",
"tests/packages.config.js"
],
plugins: ["@typescript-eslint", "jest", "jsdoc", "react"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-implied-eval": "off",
"@typescript-eslint/semi": ["error", "always"],
"new-cap": ["error", { "capIsNewExceptions": ["UTF8ToString"] }],
"require-jsdoc": "off", // Built-in jsdoc support is deprecated, use jsdoc plugin instead
"valid-jsdoc": "off",
"jsdoc/require-jsdoc": "off",
"jsdoc/newline-after-description": "off",
"jsdoc/no-multi-asterisks": ["error" | "warn", { "allowWhitespace": true }],
'prettier/prettier': 0
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-implied-eval": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/semi": ["error", "always"],
"new-cap": ["error", { capIsNewExceptions: ["UTF8ToString"] }],
"require-jsdoc": "off", // Built-in jsdoc support is deprecated, use jsdoc plugin instead
"valid-jsdoc": "off",
"jsdoc/require-jsdoc": "off",
},
settings: {
jsdoc: {
ignorePrivate: true,
ignoreInternal: true,
tagNamePreference: {
"typeParam": "typeParam",
}
}
}
typeParam: "typeParam",
},
},
},
};
33 changes: 17 additions & 16 deletions src/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function build(input: string, output: string, platform: esbuild.Platform, minify
return esbuild.context({
assetNames: 'assets/[name]-[hash]',
bundle: true,
entryPoints: [ input ],
entryPoints: [input],
external: ['worker_threads', 'path', 'fs'],
loader: {
'.jpg': 'file',
Expand Down Expand Up @@ -62,24 +62,20 @@ const allOutputs = outputs.browser.concat(pkg ? outputs.npm : []);

allOutputs.forEach((build) => {
build
.then((context) => {
context.rebuild();
return context;
})
.then((context) => {
if (serve) context.watch();
.then(async (context) => {
await context.rebuild();
if (serve) await context.watch();
})
.catch((reason) => {
console.error(reason);
throw new Error('A problem occured building webR distribution with esbuild');
throw new Error('A problem occurred building webR distribution with esbuild');
});
}
);
});

if (serve) {
outputs.browser[0]
.then((context) => {
context.serve({ servedir: '../dist', port: 8001 }).then(() => {
.then(async (context) => {
await context.serve({ servedir: '../dist', port: 8001 }).then(() => {
http
.createServer((req, res) => {
const { url, method, headers } = req;
Expand All @@ -105,12 +101,17 @@ if (serve) {
})
.catch((reason) => {
console.error(reason);
throw new Error('A problem occured service webR distribution with esbuild');
throw new Error('A problem occurred serving webR distribution with esbuild');
});
} else {
allOutputs.forEach(build => {
build.then((context) => {
context.dispose();
});
build
.then(async (context) => {
await context.dispose();
})
.catch((reason) => {
console.error(reason);
throw new Error('A problem occurred running esbuild');
});
});
}
Loading

0 comments on commit 06fbb3c

Please sign in to comment.