[go: nahoru, domu]

Skip to content

Commit

Permalink
prefer arrow fns, turn off no-var in .js files (firebase#2107)
Browse files Browse the repository at this point in the history
* prefer arrow functions in callbacks

* turn off no-var and arrow-functions in js
  • Loading branch information
bkendall committed Apr 6, 2020
1 parent 73062b2 commit 7d996da
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 29 deletions.
17 changes: 11 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ module.exports = {
rules: {
"jsdoc/newline-after-description": "off",
"jsdoc/require-jsdoc": ["warn", { publicOnly: true }],
"no-restricted-globals": ["error", "name", "length"],
"prefer-arrow-callback": "error",
"prettier/prettier": "error",
"valid-jsdoc": "off", // This is deprecated but included in recommended configs.
"require-jsdoc": "off", // This rule is deprecated and superseded by jsdoc/require-jsdoc.
"require-atomic-updates": "off", // This rule is so noisy and isn't useful: https://github.com/eslint/eslint/issues/11899
"require-jsdoc": "off", // This rule is deprecated and superseded by jsdoc/require-jsdoc.
"valid-jsdoc": "off", // This is deprecated but included in recommended configs.

"no-prototype-builtins": "warn", // TODO(bkendall): remove, allow to error.
"no-restricted-globals": ["error", "name", "length"],
"no-useless-escape": "warn", // TODO(bkendall): remove, allow to error.
"prefer-const": "warn", // TODO(bkendall): remove, allow to error.
"prefer-promise-reject-errors": "warn", // TODO(bkendall): remove, allow to error.
Expand All @@ -30,6 +32,9 @@ module.exports = {
{
files: ["*.ts"],
rules: {
"jsdoc/require-param-type": "off",
"jsdoc/require-returns-type": "off",

"@typescript-eslint/await-thenable": "warn", // TODO(bkendall): remove, allow to error.
"@typescript-eslint/ban-types": "warn", // TODO(bkendall): remove, allow to error.
"@typescript-eslint/camelcase": "warn", // TODO(bkendall): remove, allow to error.
Expand All @@ -46,8 +51,6 @@ module.exports = {
"@typescript-eslint/require-await": "warn", // TODO(bkendall): remove, allow to error.
"@typescript-eslint/unbound-method": "warn", // TODO(bkendall): remove, allow to error.
camelcase: "warn", // TODO(bkendall): remove, allow to error.
"jsdoc/require-param-type": "off",
"jsdoc/require-returns-type": "off",
"new-cap": "warn", // TODO(bkendall): remove, allow to error.
"no-case-declarations": "warn", // TODO(bkendall): remove, allow to error.
"no-constant-condition": "warn", // TODO(bkendall): remove, allow to error.
Expand All @@ -68,8 +71,10 @@ module.exports = {
"@typescript-eslint/prefer-includes": "off",
"@typescript-eslint/prefer-regexp-exec": "off",
"@typescript-eslint/unbound-method": "off",

"no-invalid-this": "warn", // TODO(bkendall): remove, allow to error.
"no-var": "warn", // TODO(bkendall): remove, allow to error.
"no-var": "off", // TODO(bkendall): remove, allow to error.
"prefer-arrow-callback": "off", // TODO(bkendall): remove, allow to error.
},
},
{
Expand Down
31 changes: 14 additions & 17 deletions scripts/extensions-emulator-tests/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class TriggerEndToEndTest {

const req = request.get(url);

req.on("response", function(response: request.Response) {
req.on("response", (response: request.Response) => {
response.body = "";
response.on("data", (data) => {
response.body += data.toString();
Expand All @@ -173,7 +173,7 @@ class TriggerEndToEndTest {
});
});

req.once("error", function(err: Error) {
req.once("error", (err: Error) => {
done(err);
});
}
Expand Down Expand Up @@ -203,7 +203,7 @@ class TriggerEndToEndTest {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function readConfig(configPath: string, done: (err: any, conf?: Config) => any): void {
fs.readFile(configPath, function(err: Error | null, data: Buffer) {
fs.readFile(configPath, (err: Error | null, data: Buffer) => {
if (err) {
done(err);
return;
Expand All @@ -219,7 +219,7 @@ function readConfig(configPath: string, done: (err: any, conf?: Config) => any):
});
}

describe("extension emulator", function() {
describe("extension emulator", () => {
let test: TriggerEndToEndTest;

before(function(done) {
Expand All @@ -231,10 +231,7 @@ describe("extension emulator", function() {
async.series(
[
function(done: (err?: Error) => void) {
readConfig(`${EXTENSION_ROOT}/${TEST_CONFIG_FILE}`, function(
err: Error,
config?: Config
) {
readConfig(`${EXTENSION_ROOT}/${TEST_CONFIG_FILE}`, (err: Error, config?: Config) => {
if (err) {
done(new Error("Error reading test config: " + err));
return;
Expand Down Expand Up @@ -265,14 +262,14 @@ describe("extension emulator", function() {
done();
});

it("should execute an HTTP function", function(done) {
test.invokeHttpFunction(TEST_FUNCTION_NAME, function(
err: Error | null,
response?: request.Response
) {
expect(response?.statusCode).to.equal(200);
expect(response?.body).to.equal("Hello World from greet-the-world");
done(err);
});
it("should execute an HTTP function", (done) => {
test.invokeHttpFunction(
TEST_FUNCTION_NAME,
(err: Error | null, response?: request.Response) => {
expect(response?.statusCode).to.equal(200);
expect(response?.body).to.equal("Hello World from greet-the-world");
done(err);
}
);
}).timeout(EMULATOR_TEST_TIMEOUT);
});
8 changes: 3 additions & 5 deletions src/deploy/storage/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ export default async function(context: any, options: any): Promise<void> {
const toRelease: Array<{ bucket: string; rules: any }> = [];
for (const ruleConfig of rules) {
if (ruleConfig.target) {
options.rc
.target(options.project, "storage", ruleConfig.target)
.forEach(function(bucket: string) {
toRelease.push({ bucket: bucket, rules: ruleConfig.rules });
});
options.rc.target(options.project, "storage", ruleConfig.target).forEach((bucket: string) => {
toRelease.push({ bucket: bucket, rules: ruleConfig.rules });
});
} else {
toRelease.push({ bucket: ruleConfig.bucket, rules: ruleConfig.rules });
}
Expand Down
2 changes: 1 addition & 1 deletion src/errorOut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function errorOut(error: Error): void {

logError(fbError);
process.exitCode = fbError.exit || 2;
setTimeout(function() {
setTimeout(() => {
process.exit();
}, 250);
}

0 comments on commit 7d996da

Please sign in to comment.