Skip to content

Commit c37c4f2

Browse files
committed
Set default Prettier config
1 parent b7550c2 commit c37c4f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+11712
-11610
lines changed

Diff for: .prettierrc

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"singleQuote": true,
3-
"semi": false,
4-
"trailingComma": "none"
5-
}
1+
{}

Diff for: babel.config.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const config = {
22
presets: [
3-
['@babel/preset-env', { targets: { node: 'current' } }],
4-
'@babel/preset-typescript'
5-
]
6-
}
7-
export default config
3+
["@babel/preset-env", { targets: { node: "current" } }],
4+
"@babel/preset-typescript",
5+
],
6+
};
7+
export default config;

Diff for: babel.config.lib.js

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
const config = {
2-
presets: ['@babel/preset-typescript'],
2+
presets: ["@babel/preset-typescript"],
33

44
env: {
55
cjs: {
66
presets: [
77
[
8-
'@babel/preset-env',
9-
{ targets: { node: 'current' }, modules: 'commonjs', loose: true }
10-
]
8+
"@babel/preset-env",
9+
{ targets: { node: "current" }, modules: "commonjs", loose: true },
10+
],
1111
],
1212

1313
plugins: [
1414
[
15-
'@babel/plugin-transform-modules-commonjs',
16-
{ strict: true, noInterop: true }
15+
"@babel/plugin-transform-modules-commonjs",
16+
{ strict: true, noInterop: true },
1717
],
18-
['babel-plugin-add-import-extension', { extension: 'js' }]
19-
]
18+
["babel-plugin-add-import-extension", { extension: "js" }],
19+
],
2020
},
2121

2222
esm: {
2323
presets: [
24-
['@babel/preset-env', { targets: { node: 'current' }, modules: false }]
24+
["@babel/preset-env", { targets: { node: "current" }, modules: false }],
2525
],
2626

27-
plugins: [['babel-plugin-add-import-extension', { extension: 'mjs' }]]
28-
}
27+
plugins: [["babel-plugin-add-import-extension", { extension: "mjs" }]],
28+
},
2929
},
3030

3131
ignore: [
32-
'src/**/*.d.ts',
33-
'src/**/tests.ts',
34-
'src/tests/**/*',
35-
'src/**/tysts.ts',
36-
'src/tysts/**/*'
37-
]
38-
}
39-
export default config
32+
"src/**/*.d.ts",
33+
"src/**/tests.ts",
34+
"src/tests/**/*",
35+
"src/**/tysts.ts",
36+
"src/tysts/**/*",
37+
],
38+
};
39+
export default config;

Diff for: jest.config.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/** @type {import('@jest/types').Config.InitialOptions} */
22
module.exports = {
3-
roots: ['<rootDir>/src/'],
4-
testRegex: ['tests\\.ts$', 'tests/.+\\.ts$'],
5-
setupFilesAfterEnv: ['<rootDir>/tests/setupAdmin.ts'],
3+
roots: ["<rootDir>/src/"],
4+
testRegex: ["tests\\.ts$", "tests/.+\\.ts$"],
5+
setupFilesAfterEnv: ["<rootDir>/tests/setupAdmin.ts"],
66
transform: {
7-
'\\.(mjs|js|ts)$': 'babel-jest'
8-
}
9-
}
7+
"\\.(mjs|js|ts)$": "babel-jest",
8+
},
9+
};

Diff for: karma.conf.js

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
1-
const webpack = require('webpack')
1+
const webpack = require("webpack");
22

3-
process.env.CHROME_BIN = require('puppeteer').executablePath()
3+
process.env.CHROME_BIN = require("puppeteer").executablePath();
44

55
module.exports = (config) => {
66
config.set({
7-
files: ['tests/karmaTests.ts'],
7+
files: ["tests/karmaTests.ts"],
88

99
preprocessors: {
10-
'tests/karmaTests.ts': ['webpack', 'sourcemap']
10+
"tests/karmaTests.ts": ["webpack", "sourcemap"],
1111
},
1212

13-
frameworks: ['jasmine'],
13+
frameworks: ["jasmine"],
1414

15-
browsers: ['ChromeHeadless'],
15+
browsers: ["ChromeHeadless"],
1616

1717
concurrency: 1,
1818

1919
client: {
2020
jasmine: {
21-
timeoutInterval: 25000
22-
}
21+
timeoutInterval: 25000,
22+
},
2323
},
2424

2525
browserNoActivityTimeout: 40000,
2626

2727
webpack: {
28-
devtool: 'inline-source-map',
28+
devtool: "inline-source-map",
2929

3030
resolve: {
31-
extensions: ['.json', '.js', '.mjs', '.ts']
31+
extensions: [".json", ".js", ".mjs", ".ts"],
3232
},
3333

3434
plugins: [
3535
new webpack.DefinePlugin({
36-
'process.env.FIRESTORE_EMULATOR_HOST': JSON.stringify(
36+
"process.env.FIRESTORE_EMULATOR_HOST": JSON.stringify(
3737
process.env.FIRESTORE_EMULATOR_HOST
3838
),
39-
'process.env.FIREBASE_PROJECT_ID': JSON.stringify(
39+
"process.env.FIREBASE_PROJECT_ID": JSON.stringify(
4040
process.env.FIREBASE_PROJECT_ID
4141
),
42-
'process.env.FIREBASE_API_KEY': JSON.stringify(
42+
"process.env.FIREBASE_API_KEY": JSON.stringify(
4343
process.env.FIREBASE_API_KEY
4444
),
45-
'process.env.FIREBASE_USERNAME': JSON.stringify(
45+
"process.env.FIREBASE_USERNAME": JSON.stringify(
4646
process.env.FIREBASE_USERNAME
4747
),
48-
'process.env.FIREBASE_PASSWORD': JSON.stringify(
48+
"process.env.FIREBASE_PASSWORD": JSON.stringify(
4949
process.env.FIREBASE_PASSWORD
50-
)
50+
),
5151
}),
5252

53-
new webpack.IgnorePlugin({ resourceRegExp: /firebase-admin/ })
53+
new webpack.IgnorePlugin({ resourceRegExp: /firebase-admin/ }),
5454
],
5555

5656
module: {
5757
rules: [
5858
{
5959
test: /\.(mjs|js|ts)$/,
60-
loader: 'babel-loader',
61-
exclude: /node_modules/
62-
}
63-
]
64-
}
60+
loader: "babel-loader",
61+
exclude: /node_modules/,
62+
},
63+
],
64+
},
6565
},
6666

6767
webpackMiddleware: {
68-
stats: 'errors-only'
69-
}
70-
})
71-
}
68+
stats: "errors-only",
69+
},
70+
});
71+
};

Diff for: scripts/generateTysts.ts

+28-28
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
1-
import { readFile, writeFile } from 'fs/promises'
2-
import { format } from 'prettier'
1+
import { readFile, writeFile } from "fs/promises";
2+
import { format } from "prettier";
33

4-
type Mode = 'strict' | 'loose'
4+
type Mode = "strict" | "loose";
55

6-
const startRE = /^\s*(\/\/|\/\*)\s@tysts-start:\s(strict|loose)/
7-
const endRE = /^\s*(\/\/\s)?@tysts-end:\s(strict|loose)/
6+
const startRE = /^\s*(\/\/|\/\*)\s@tysts-start:\s(strict|loose)/;
7+
const endRE = /^\s*(\/\/\s)?@tysts-end:\s(strict|loose)/;
88

9-
const tysts = ['core', 'batch', 'groups', 'transaction'] as const
9+
const tysts = ["core", "batch", "groups", "transaction"] as const;
1010

11-
Promise.all(tysts.map((tyst) => generateTyst(tyst)))
11+
Promise.all(tysts.map((tyst) => generateTyst(tyst)));
1212

13-
async function generateTyst(tyst: typeof tysts[number]) {
14-
const content = await readFile(`./src/tysts/${tyst}.ts`, 'utf-8')
15-
const lines = content.split('\n')
13+
async function generateTyst(tyst: (typeof tysts)[number]) {
14+
const content = await readFile(`./src/tysts/${tyst}.ts`, "utf-8");
15+
const lines = content.split("\n");
1616

17-
const generatingMode: Mode[] = ['loose']
18-
let code = ''
19-
let mode: undefined | Mode = undefined
17+
const generatingMode: Mode[] = ["loose"];
18+
let code = "";
19+
let mode: undefined | Mode = undefined;
2020

2121
for (let index = 0; index < lines.length; index++) {
22-
const line = lines[index]!
22+
const line = lines[index]!;
2323
if (mode) {
2424
// Check if mode ends
25-
const endMatches = line.match(endRE)
25+
const endMatches = line.match(endRE);
2626
if (endMatches) {
27-
const endMode = endMatches[2]
27+
const endMode = endMatches[2];
2828
if (endMode !== mode)
2929
throw new Error(
3030
`Mismatched @tysts-end: expected ${mode} but got ${endMode}. Line: ${
3131
index + 1
32-
}`
33-
)
34-
mode = undefined
35-
continue
32+
}`,
33+
);
34+
mode = undefined;
35+
continue;
3636
}
3737

3838
// Add line if it's the generating mode otherwise ignore
39-
if (generatingMode.includes(mode)) code += line + '\n'
39+
if (generatingMode.includes(mode)) code += line + "\n";
4040

41-
continue
41+
continue;
4242
}
4343

44-
const startMatches = line.match(startRE)
44+
const startMatches = line.match(startRE);
4545
if (startMatches) {
46-
mode = startMatches[2] as Mode
47-
continue
46+
mode = startMatches[2] as Mode;
47+
continue;
4848
}
4949

50-
code += line + '\n'
50+
code += line + "\n";
5151
}
5252

53-
const prettyCode = await format(code, { parser: 'typescript' })
53+
const prettyCode = await format(code, { parser: "typescript" });
5454

55-
return writeFile(`./src/tysts/${generatingMode}/${tyst}.ts`, prettyCode)
55+
return writeFile(`./src/tysts/${generatingMode}/${tyst}.ts`, prettyCode);
5656
}

0 commit comments

Comments
 (0)