Skip to content

Commit

Permalink
Fix the prettier configuration (#920)
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm authored Nov 16, 2023
1 parent 9d993e7 commit 9ed7e51
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 52 deletions.
17 changes: 11 additions & 6 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ module.exports = {
},
settings: {
"import/resolver": {
"typescript": {
"project": "packages/*/tsconfig.json",
}
}
typescript: {
project: "packages/*/tsconfig.json",
},
},
},
extends: [
"plugin:@typescript-eslint/recommended",
Expand All @@ -51,7 +51,8 @@ module.exports = {
rules: {
"@typescript-eslint/strict-boolean-expressions": "error",
"@typescript-eslint/no-unnecessary-condition": "error",
"@typescript-eslint/array-type": "off", // we use complex typings, where Array is actually more readable than T[]
// we use complex typings, where Array is actually more readable than T[]
"@typescript-eslint/array-type": "off",
"@typescript-eslint/switch-exhaustiveness-check": "error",
"@typescript-eslint/prefer-nullish-coalescing": "error",
"@typescript-eslint/no-unnecessary-boolean-literal-compare":
Expand All @@ -60,7 +61,11 @@ module.exports = {
"@typescript-eslint/no-base-to-string": "error",
"import/no-cycle": "error",
"import/no-duplicates": "error",
"import/consistent-type-specifier-style": ["error", "prefer-top-level"], // TS 4.5 adds type modifiers on import names, but we want to support lower versions
// TS 4.5 adds type modifiers on import names, but we want to support lower versions
"import/consistent-type-specifier-style": [
"error",
"prefer-top-level",
],
},
};
}),
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
node_modules
/packages/connect/src/protocol-grpc/gen/*.ts
/packages/*/bin
/packages/*/dist
/packages/*/src/gen
/.tmp
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ lint: node_modules $(BUILD)/connect $(BUILD)/connect-express $(BUILD)/connect-fa

.PHONY: format
format: node_modules $(BIN)/license-header ## Format all files, adding license headers
npx prettier --write '**/*.{json,js,jsx,ts,tsx,css}' --log-level error
npx prettier --write '**/*.{json,js,jsx,ts,tsx,css,mjs,cjs}' --log-level error
comm -23 \
<(git ls-files --cached --modified --others --no-empty-directory --exclude-standard | sort -u | grep -v $(LICENSE_IGNORE) ) \
<(git ls-files --deleted | sort -u) | \
Expand Down
4 changes: 2 additions & 2 deletions packages/connect-node-test/connect-node-h1-server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
utimesSync,
writeFileSync,
readFileSync,
openSync
openSync,
} from "fs";
import { dirname, join, basename } from "path";
import * as process from "process";
Expand Down Expand Up @@ -58,7 +58,7 @@ switch (command) {
const outHandle = openSync(outFile, "a");
spawn(nodePath, [selfPath, "startinternal"], {
detached: true,
stdio: ["ignore", outHandle, outHandle]
stdio: ["ignore", outHandle, outHandle],
}).unref();
// wait until server has updated lock file
const startTs = Date.now();
Expand Down
41 changes: 27 additions & 14 deletions packages/connect-web-test/karma-fixup.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,36 @@ const path = require("path");
// http://karma-runner.github.io/6.3/dev/plugins.html

function fixupFactory(files) {
files.unshift({
pattern: path.join(__dirname, "/karma-fixup-globalThis.js"),
included: true, served: true, watched: false
}, {
pattern: path.join(__dirname, "/karma-fixup-AbortController.js"),
included: true, served: true, watched: false
}, {
pattern: path.join(__dirname, "/karma-fixup-queueMicrotask.js"),
included: true, served: true, watched: false
}, {
pattern: path.join(__dirname, "/karma-fixup-symbolAsyncIterator.js"),
included: true, served: true, watched: false
});
files.unshift(
{
pattern: path.join(__dirname, "/karma-fixup-globalThis.js"),
included: true,
served: true,
watched: false,
},
{
pattern: path.join(__dirname, "/karma-fixup-AbortController.js"),
included: true,
served: true,
watched: false,
},
{
pattern: path.join(__dirname, "/karma-fixup-queueMicrotask.js"),
included: true,
served: true,
watched: false,
},
{
pattern: path.join(__dirname, "/karma-fixup-symbolAsyncIterator.js"),
included: true,
served: true,
watched: false,
},
);
}

fixupFactory.$inject = ["config.files"];

module.exports = {
"framework:fixup": ["factory", fixupFactory]
"framework:fixup": ["factory", fixupFactory],
};
36 changes: 18 additions & 18 deletions packages/connect-web-test/karma.browserstack.conf.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
if (process.env.BROWSERSTACK_USERNAME === undefined || process.env.BROWSERSTACK_ACCESS_KEY === undefined) {
throw new Error("The environment variables BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY are required to run tests on browserstack.");
if (
process.env.BROWSERSTACK_USERNAME === undefined ||
process.env.BROWSERSTACK_ACCESS_KEY === undefined
) {
throw new Error(
"The environment variables BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY are required to run tests on browserstack.",
);
}

module.exports = function(config) {
module.exports = function (config) {
config.set({
plugins: [
require("./karma-fixup.cjs"),
Expand All @@ -12,15 +17,12 @@ module.exports = function(config) {
require("karma-chrome-launcher"),
],
singleRun: true,
frameworks: [ "jasmine", "fixup" ],
frameworks: ["jasmine", "fixup"],
preprocessors: {
"**/*.ts": "esbuild",
},
reporters: ["progress", "BrowserStack"],
files: [
"src/browserstackonly/*.ts",
"src/gen/**/*.ts",
],
files: ["src/browserstackonly/*.ts", "src/gen/**/*.ts"],
esbuild: {
define: {},
plugins: [],
Expand All @@ -33,7 +35,7 @@ module.exports = function(config) {
browserStack: {
username: process.env.BROWSERSTACK_USERNAME,
accessKey: process.env.BROWSERSTACK_ACCESS_KEY,
apiClientEndpoint: 'https://api.browserstack.com'
apiClientEndpoint: "https://api.browserstack.com",
},
browsers: [
"ChromeHeadless",
Expand All @@ -46,16 +48,15 @@ module.exports = function(config) {
"bstack_windows_ff_67_0",
],
customLaunchers: {

bstack_ios_safari_13: {
// Safari 13 on iOS 13.3 - the oldest iOS version available.
base : "BrowserStack",
base: "BrowserStack",
"browserstack.tunnel": false,
device : "iPhone 11",
device: "iPhone 11",
real_mobile: true,
browser : "safari",
browser: "safari",
os: "ios",
os_version : "13",
os_version: "13",
},

bstack_macos_safari_14_1: {
Expand Down Expand Up @@ -114,7 +115,7 @@ module.exports = function(config) {
browser: "chrome",
browser_version: "60.0",
os: "Windows",
os_version: "10"
os_version: "10",
},

bstack_windows_ff_67_0: {
Expand All @@ -128,9 +129,8 @@ module.exports = function(config) {
browser: "firefox",
browser_version: "67.0",
os: "Windows",
os_version: "10"
os_version: "10",
},

}
},
});
};
8 changes: 3 additions & 5 deletions packages/connect-web-test/karma.conf.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
module.exports = function (config) {
config.set({
frameworks: ["jasmine"],
files: [
"src/**/*.ts",
],
files: ["src/**/*.ts"],
exclude: [],
singleRun: true,
reporters: ["progress"],
browsers: ["ChromeCustom"],
preprocessors: {"/**/*.ts": "esbuild"},
preprocessors: { "/**/*.ts": "esbuild" },
esbuild: {
target: "esnext",
tsconfig: "./tsconfig.json",
Expand All @@ -35,4 +33,4 @@ module.exports = function (config) {
},
},
});
}
};
2 changes: 1 addition & 1 deletion packages/connect-web-test/karma.serve.conf.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ module.exports = function (config) {
browsers: [],
customLaunchers: {},
});
}
};
10 changes: 6 additions & 4 deletions scripts/gen-esm-proxy.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {existsSync, mkdirSync, readFileSync, writeFileSync} from "node:fs";
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
import * as path from "node:path";
import {exit, stderr, stdout, argv} from "node:process";
import { exit, stderr, stdout, argv } from "node:process";

const args = argv.slice(2);

Expand Down Expand Up @@ -66,14 +66,16 @@ if (packageType !== "module") {
for (const subpath of args) {
const cjsPath = path.join(cjsDist, subpath, "index.js");
if (!existsSync(cjsPath)) {
stderr.write(`CommonJS artifact for subpath "${subpath}" not found at expected path ${cjsPath}\n`);
stderr.write(
`CommonJS artifact for subpath "${subpath}" not found at expected path ${cjsPath}\n`,
);
exit(1);
}
const proxyDir = path.join(proxyDist, subpath);
if (!existsSync(proxyDir)) {
mkdirSync(proxyDir, { recursive: true });
}
const cjsImportPath = path.relative(proxyDir, cjsPath)
const cjsImportPath = path.relative(proxyDir, cjsPath);
writeFileSync(
path.join(proxyDir, "index.js"),
`export * from "${cjsImportPath}";\n`,
Expand Down

0 comments on commit 9ed7e51

Please sign in to comment.