Skip to content

Commit 5b1a0bc

Browse files
committed
fixed lint errors
1 parent cd3875a commit 5b1a0bc

File tree

7 files changed

+33
-18
lines changed

7 files changed

+33
-18
lines changed

repo-scripts/size-analysis/analysis-helper.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,9 @@ export async function generateReportForModule(
733733
`Firebase Module locates at ${moduleLocation}: ${ErrorCode.PKG_JSON_DOES_NOT_EXIST}`
734734
);
735735
}
736-
const packageJson = require(packageJsonPath);
736+
const packageJson = JSON.parse(
737+
fs.readFileSync(packageJsonPath, { encoding: 'utf-8' })
738+
);
737739
// to exclude <modules>-types modules
738740
const TYPINGS: string = 'typings';
739741
if (packageJson[TYPINGS]) {
@@ -822,7 +824,9 @@ async function traverseDirs(
822824
if (
823825
fs.lstatSync(p).isDirectory() &&
824826
fs.existsSync(`${p}/package.json`) &&
825-
require(`${p}/package.json`)[generateSizeAnalysisReportPkgJsonField]
827+
JSON.parse(fs.readFileSync(`${p}/package.json`, { encoding: 'utf-8' }))[
828+
generateSizeAnalysisReportPkgJsonField
829+
]
826830
) {
827831
const subModuleReports: Report[] = await traverseDirs(
828832
p,

repo-scripts/size-analysis/analysis.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
import { mapWorkspaceToPackages } from '../../scripts/release/utils/workspace';
2828
import { projectRoot } from '../../scripts/utils';
2929
import * as yargs from 'yargs';
30+
import * as fs from 'fs';
3031

3132
/**
3233
* Support Command Line Options
@@ -93,7 +94,9 @@ async function main(): Promise<void> {
9394
`${projectRoot}/packages-exp/*`
9495
]);
9596
allModulesLocation = allModulesLocation.filter(path => {
96-
const json = require(`${path}/package.json`);
97+
const json = JSON.parse(
98+
fs.readFileSync(`${path}/package.json`, { encoding: 'utf-8' })
99+
);
97100
return (
98101
json.name.startsWith('@firebase') &&
99102
!json.name.includes('-compat') &&
@@ -102,7 +105,9 @@ async function main(): Promise<void> {
102105
});
103106
if (argv.inputModule) {
104107
allModulesLocation = allModulesLocation.filter(path => {
105-
const json = require(`${path}/package.json`);
108+
const json = JSON.parse(
109+
fs.readFileSync(`${path}/package.json`, { encoding: 'utf-8' })
110+
);
106111
return argv.inputModule.includes(json.name);
107112
});
108113
}
@@ -128,4 +133,6 @@ async function main(): Promise<void> {
128133
}
129134
}
130135

131-
main();
136+
main().catch(error => {
137+
console.log(error);
138+
});

repo-scripts/size-analysis/package.json

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
77
"main": "dist/index.cjs.js",
88
"esm2017": "dist/index.esm2017.js",
9-
"files": ["dist"],
9+
"files": [
10+
"dist"
11+
],
1012
"scripts": {
1113
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
1214
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
@@ -16,18 +18,22 @@
1618
"type-check": "tsc -p . --noEmit"
1719
},
1820
"dependencies": {
19-
"typescript": "3.9.7",
21+
"@firebase/app": "0.6.10",
22+
"@firebase/util": "0.3.1",
2023
"rollup": "2.23.0",
24+
"rollup-plugin-commonjs": "10.1.0",
2125
"rollup-plugin-json": "4.0.0",
26+
"rollup-plugin-node-resolve": "5.2.0",
2227
"rollup-plugin-replace": "2.2.0",
2328
"rollup-plugin-typescript2": "0.27.1",
24-
"rollup-plugin-commonjs": "10.1.0",
25-
"rollup-plugin-node-resolve": "5.2.0"
29+
"tmp": "^0.2.1",
30+
"typescript": "3.9.7",
31+
"terser": "4.8.0",
32+
"yargs": "15.4.1"
2633
},
2734
"license": "Apache-2.0",
2835
"devDependencies": {
29-
"@firebase/logger": "0.2.6",
30-
"@firebase/util": "0.3.1"
36+
"@firebase/logger": "0.2.6"
3137
},
3238
"repository": {
3339
"directory": "repo-scripts/size-analysis",
@@ -43,4 +49,4 @@
4349
],
4450
"reportDir": "./coverage/node"
4551
}
46-
}
52+
}

repo-scripts/size-analysis/test/test-inputs/assortedImports.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import '@firebase/logger';
1919
import * as fs from 'fs';
2020
import {
2121
basicFuncExportEnumDependenciesBar,
22-
basicFuncExternalDependenciesBar
22+
basicFuncExternalDependenciesBar,
23+
BasicClassExportBar as BasicClassExportBarRenamed
2324
} from './bar';
24-
import { BasicClassExportBar as BasicClassExportBarRenamed } from './bar';
2525
import defaultExport from '@firebase/app';
2626
console.log(
2727
fs,

repo-scripts/size-analysis/test/test-inputs/far.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export function basicUniqueFuncFar(
6565
export function basicUniqueFuncFar(x: number): { suit: string; card: number };
6666
export function basicUniqueFuncFar(
6767
x: number | Array<{ suit: string; card: number }>
68-
) {
68+
): number | { suit: string; card: number } {
6969
if (typeof x === 'object') {
7070
const pickedCard = Math.floor(Math.random() * x.length);
7171
return pickedCard;

repo-scripts/size-analysis/test/test-inputs/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,9 @@ export function basicUniqueFunc(
9595
}
9696
}
9797

98-
const appsNotExported: Map<string, number> = new Map();
9998
const apps: Map<string, number> = new Map();
10099
export { apps };
101100

102-
class FooNotExported {}
103101
class Foo {}
104102
export { Foo as Foo1 };
105103

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14705,7 +14705,7 @@ [email protected], tmp@^0.0.33:
1470514705
dependencies:
1470614706
os-tmpdir "~1.0.2"
1470714707

14708-
14708+
[email protected], tmp@^0.2.1:
1470914709
version "0.2.1"
1471014710
resolved "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14"
1471114711
integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==

0 commit comments

Comments
 (0)