Skip to content

Commit

Permalink
fix: remove eslint, update gax, fix generated protos, run the generat…
Browse files Browse the repository at this point in the history
…or (#955)

Run the latest version of the generator, update google-gax, update gts, and remove direct dependencies on eslint.
  • Loading branch information
alexander-fenster committed Apr 11, 2020
1 parent 2fc68ba commit 544a061
Show file tree
Hide file tree
Showing 60 changed files with 250 additions and 302 deletions.
1 change: 0 additions & 1 deletion .eslintignore
@@ -1,5 +1,4 @@
**/node_modules
src/**/doc/*
build/
docs/
protos/
15 changes: 0 additions & 15 deletions .eslintrc.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -12,3 +12,4 @@ system-test/*key.json
.DS_Store
package-lock.json
__pycache__
.vscode
8 changes: 5 additions & 3 deletions .prettierignore
@@ -1,3 +1,5 @@
node_modules/*
samples/node_modules/*
src/**/doc/*
**/node_modules
build/
docs/
.coverage/
protos/
8 changes: 0 additions & 8 deletions .prettierrc

This file was deleted.

4 changes: 0 additions & 4 deletions codecov.yaml

This file was deleted.

19 changes: 8 additions & 11 deletions package.json
Expand Up @@ -5,7 +5,7 @@
"license": "Apache-2.0",
"author": "Google Inc.",
"engines": {
"node": ">=8.10.0"
"node": ">=10"
},
"repository": "googleapis/nodejs-pubsub",
"main": "./build/src/index.js",
Expand All @@ -31,7 +31,7 @@
"system-test": "mocha build/system-test --timeout 600000",
"samples-test": "cd samples/ && npm link ../ && npm install && npm test && cd ../",
"test": "c8 mocha build/test",
"lint": "gts check",
"lint": "gts fix",
"predocs": "npm run compile",
"docs": "jsdoc -c .jsdoc.js",
"fix": "gts fix",
Expand All @@ -42,7 +42,8 @@
"pretest": "npm run compile",
"docs-test": "linkinator docs",
"predocs-test": "npm run docs",
"benchwrapper": "node bin/benchwrapper.js"
"benchwrapper": "node bin/benchwrapper.js",
"prelint": "cd samples; npm link ../; npm install"
},
"dependencies": {
"@google-cloud/paginator": "^3.0.0",
Expand All @@ -55,7 +56,7 @@
"async-each": "^1.0.1",
"extend": "^3.0.2",
"google-auth-library": "^6.0.0",
"google-gax": "^2.0.0",
"google-gax": "^2.1.0",
"is-stream-ended": "^0.1.4",
"lodash.snakecase": "^4.1.1",
"p-defer": "^3.0.0",
Expand All @@ -76,12 +77,9 @@
"@types/uuid": "^7.0.0",
"c8": "^7.0.0",
"codecov": "^3.0.0",
"eslint": "^6.0.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.0.0",
"execa": "^4.0.0",
"grpc": "^1.24.0",
"gts": "^1.0.0",
"gts": "^2.0.0",
"jsdoc": "^3.6.2",
"jsdoc-fresh": "^1.0.1",
"jsdoc-region-tag": "^1.0.2",
Expand All @@ -91,10 +89,9 @@
"mv": "^2.1.1",
"ncp": "^2.0.0",
"null-loader": "^3.0.0",
"prettier": "^1.18.2",
"proxyquire": "^2.0.0",
"sinon": "^9.0.0",
"source-map-support": "^0.5.9",
"tmp": "^0.1.0",
"ts-loader": "^6.2.1",
"typescript": "3.6.4",
"uuid": "^7.0.0",
Expand Down
1 change: 0 additions & 1 deletion samples/.eslintrc.yml
@@ -1,4 +1,3 @@
---
rules:
no-console: off
node/no-missing-require: off
2 changes: 1 addition & 1 deletion samples/getTopicPolicy.js
Expand Up @@ -43,7 +43,7 @@ function main(topicName = 'YOUR_TOPIC_NAME') {
async function getTopicPolicy() {
// Retrieves the IAM policy for the topic
const [policy] = await pubSubClient.topic(topicName).iam.getPolicy();
console.log(`Policy for topic: %j.`, policy.bindings);
console.log('Policy for topic: %j.', policy.bindings);
}

getTopicPolicy().catch(console.error);
Expand Down
4 changes: 2 additions & 2 deletions samples/listenForErrors.js
Expand Up @@ -48,7 +48,7 @@ async function main(subscriptionName = 'YOUR_SUBSCRIPTION_NAME', timeout = 10) {
const subscription = pubSubClient.subscription(subscriptionName);

// Create an event handler to handle messages
const messageHandler = function(message) {
const messageHandler = function (message) {
// Do something with the message
console.log(`Message: ${message}`);

Expand All @@ -57,7 +57,7 @@ async function main(subscriptionName = 'YOUR_SUBSCRIPTION_NAME', timeout = 10) {
};

// Create an event handler to handle errors
const errorHandler = function(error) {
const errorHandler = function (error) {
// Do something with the error
console.error(`ERROR: ${error}`);
throw error;
Expand Down
2 changes: 1 addition & 1 deletion samples/listenForOrderedMessages.js
Expand Up @@ -64,7 +64,7 @@ async function main(
const subscription = pubSubClient.subscription(subscriptionName);

// Create an event handler to handle messages
const messageHandler = function(message) {
const messageHandler = function (message) {
// Buffer the message in an object (for later ordering)
outstandingMessages[message.attributes.counterId] = message;

Expand Down
5 changes: 4 additions & 1 deletion samples/publishWithRetrySettings.js
Expand Up @@ -50,7 +50,10 @@ function main(
});

async function publishWithRetrySettings() {
const formattedTopic = publisherClient.projectTopicPath(projectId, topicName);
const formattedTopic = publisherClient.projectTopicPath(
projectId,
topicName
);

// Publishes the message as a string, e.g. "Hello, world!" or JSON.stringify(someObject)
const dataBuffer = Buffer.from(data);
Expand Down
2 changes: 1 addition & 1 deletion samples/setSubscriptionPolicy.js
Expand Up @@ -62,7 +62,7 @@ function main(subscriptionName = 'YOUR_SUBSCRIPTION_NAME') {
.subscription(subscriptionName)
.iam.setPolicy(newPolicy);

console.log(`Updated policy for subscription: %j`, updatedPolicy.bindings);
console.log('Updated policy for subscription: %j', updatedPolicy.bindings);
}

setSubscriptionPolicy().catch(console.error);
Expand Down
2 changes: 1 addition & 1 deletion samples/setTopicPolicy.js
Expand Up @@ -61,7 +61,7 @@ function main(topicName = 'YOUR_TOPIC_NAME') {
const [updatedPolicy] = await pubSubClient
.topic(topicName)
.iam.setPolicy(newPolicy);
console.log(`Updated policy for topic: %j`, updatedPolicy.bindings);
console.log('Updated policy for topic: %j', updatedPolicy.bindings);
}

setTopicPolicy().catch(console.error);
Expand Down
2 changes: 1 addition & 1 deletion samples/subscribeWithFlowControlSettings.js
Expand Up @@ -78,7 +78,7 @@ function main(
message.ack();
};

subscription.on(`message`, messageHandler);
subscription.on('message', messageHandler);

setTimeout(() => {
subscription.close();
Expand Down
2 changes: 1 addition & 1 deletion samples/synchronousPullWithLeaseManagement.js
Expand Up @@ -100,7 +100,7 @@ function main(
console.log(`Acknowledged: "${message.message.data}".`);
// Exit after the message is acknowledged.
waiting = false;
console.log(`Done.`);
console.log('Done.');
} else {
// If the message is not yet processed..
const modifyAckRequest = {
Expand Down
32 changes: 16 additions & 16 deletions samples/system-test/subscriptions.test.js
Expand Up @@ -100,8 +100,8 @@ describe('subscriptions', () => {
const expected =
`Subscription: ${fullSubscriptionNameOne}` +
`\nTopic: ${fullTopicNameOne}` +
`\nPush config: ` +
`\nAck deadline: 10s`;
'\nPush config: ' +
'\nAck deadline: 10s';
assert.include(output, expected);
});

Expand All @@ -124,15 +124,15 @@ describe('subscriptions', () => {
it('should listen for messages', async () => {
const messageIds = await pubsub
.topic(topicNameOne)
.publish(Buffer.from(`Hello, world!`));
.publish(Buffer.from('Hello, world!'));
const output = execSync(
`${commandFor('listenForMessages')} ${subscriptionNameOne}`
);
assert.match(output, new RegExp(`Received message ${messageIds}:`));
});

it('should listen for messages synchronously', async () => {
await pubsub.topic(topicNameOne).publish(Buffer.from(`Hello, world!`));
await pubsub.topic(topicNameOne).publish(Buffer.from('Hello, world!'));
const output = execSync(
`${commandFor('synchronousPull')} ${projectId} ${subscriptionNameOne}`
);
Expand All @@ -141,7 +141,7 @@ describe('subscriptions', () => {
});

it('should listen for messages synchronously with lease management', async () => {
await pubsub.topic(topicNameOne).publish(Buffer.from(`Hello, world!`));
await pubsub.topic(topicNameOne).publish(Buffer.from('Hello, world!'));
const output = execSync(
`${commandFor(
'synchronousPullWithLeaseManagement'
Expand All @@ -153,7 +153,7 @@ describe('subscriptions', () => {
it('should listen to messages with flow control', async () => {
const topicTwo = pubsub.topic(topicNameTwo);
await topicTwo.subscription(subscriptionNameFour).get({autoCreate: true});
await topicTwo.publish(Buffer.from(`Hello, world!`));
await topicTwo.publish(Buffer.from('Hello, world!'));

const output = execSync(
`${commandFor(
Expand All @@ -162,15 +162,15 @@ describe('subscriptions', () => {
);
assert.include(
output,
`ready to receive messages at a controlled volume of 5 messages.`
'ready to receive messages at a controlled volume of 5 messages.'
);
const [subscriptions] = await pubsub.topic(topicNameTwo).getSubscriptions();
assert(subscriptions.some(s => s.name === fullSubscriptionNameFour));
});

it('should listen for error messages', () => {
assert.throws(
() => execSync(`node listenForErrors nonexistent-subscription`),
() => execSync('node listenForErrors nonexistent-subscription'),
/Resource not found/
);
});
Expand All @@ -184,7 +184,7 @@ describe('subscriptions', () => {
spy.calls.push(args);
log(...args);
};
const expected = `Hello, world!`;
const expected = 'Hello, world!';
const expectedBuffer = Buffer.from(expected);
const publishedMessageIds = [];
const topicTwo = pubsub.topic(topicNameTwo);
Expand All @@ -207,7 +207,7 @@ describe('subscriptions', () => {
);
assert.strictEqual(spy.calls.length, 1);
assert.deepStrictEqual(spy.calls[0], [
`* %d %j %j`,
'* %d %j %j',
publishedMessageIds[1],
expected,
{counterId: '1'},
Expand All @@ -222,13 +222,13 @@ describe('subscriptions', () => {
);
assert.strictEqual(spy.calls.length, 3);
assert.deepStrictEqual(spy.calls[1], [
`* %d %j %j`,
'* %d %j %j',
publishedMessageIds[2],
expected,
{counterId: '2'},
]);
assert.deepStrictEqual(spy.calls[2], [
`* %d %j %j`,
'* %d %j %j',
publishedMessageIds[0],
expected,
{counterId: '3'},
Expand All @@ -244,13 +244,13 @@ describe('subscriptions', () => {
const policy = results[0];
assert.deepStrictEqual(policy.bindings, [
{
role: `roles/pubsub.editor`,
members: [`group:cloud-logs@google.com`],
role: 'roles/pubsub.editor',
members: ['group:cloud-logs@google.com'],
condition: null,
},
{
role: `roles/pubsub.viewer`,
members: [`allUsers`],
role: 'roles/pubsub.viewer',
members: ['allUsers'],
condition: null,
},
]);
Expand Down
10 changes: 5 additions & 5 deletions samples/system-test/topics.test.js
Expand Up @@ -60,7 +60,7 @@ describe('topics', () => {
const _pullOneMessage = subscriptionObj => {
return new Promise((resolve, reject) => {
const timeoutHandler = setTimeout(() => {
reject(new Error(`_pullOneMessage timed out`));
reject(new Error('_pullOneMessage timed out'));
}, 55000);

subscriptionObj.once('error', reject).once('message', message => {
Expand Down Expand Up @@ -208,13 +208,13 @@ describe('topics', () => {
const [policy] = results;
assert.deepStrictEqual(policy.bindings, [
{
role: `roles/pubsub.editor`,
members: [`group:cloud-logs@google.com`],
role: 'roles/pubsub.editor',
members: ['group:cloud-logs@google.com'],
condition: null,
},
{
role: `roles/pubsub.viewer`,
members: [`allUsers`],
role: 'roles/pubsub.viewer',
members: ['allUsers'],
condition: null,
},
]);
Expand Down
2 changes: 1 addition & 1 deletion samples/testSubscriptionPermissions.js
Expand Up @@ -51,7 +51,7 @@ function main(subscriptionName = 'YOUR_SUBSCRIPTION_NAME') {
.subscription(subscriptionName)
.iam.testPermissions(permissionsToTest);

console.log(`Tested permissions for subscription: %j`, permissions);
console.log('Tested permissions for subscription: %j', permissions);
}

testSubscriptionPermissions().catch(console.error);
Expand Down
2 changes: 1 addition & 1 deletion samples/testTopicPermissions.js
Expand Up @@ -52,7 +52,7 @@ function main(topicName = 'YOUR_TOPIC_NAME') {
.topic(topicName)
.iam.testPermissions(permissionsToTest);

console.log(`Tested permissions for topic: %j`, permissions);
console.log('Tested permissions for topic: %j', permissions);
}

testTopicPermissions().catch(console.error);
Expand Down
3 changes: 0 additions & 3 deletions src/.eslintrc.yml

This file was deleted.

4 changes: 3 additions & 1 deletion src/helper.ts
Expand Up @@ -22,6 +22,7 @@ import * as path from 'path';
import * as gapicConfig from './iam_policy_service_client_config.json';
import {ProjectIdCallback} from 'google-auth-library';
import * as protosTypes from '../protos/protos';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const {version} = require('../../package.json');
/**
* Google Cloud IAM Client.
Expand Down Expand Up @@ -95,7 +96,7 @@ export class IamClient {
const iamPolicyStub = gaxGrpc.createStub(
opts.fallback
? (protos as protobuf.Root).lookupService('google.iam.v1.IAMPolicy')
: // tslint:disable-next-line no-any
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
(protos as any).google.iam.v1.IAMPolicy,
opts
) as Promise<{[method: string]: Function}>;
Expand All @@ -114,6 +115,7 @@ export class IamClient {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
}
// eslint-disable-next-line prefer-spread
return stub[methodName].apply(stub, args);
},
(err: Error | null | undefined) => () => {
Expand Down

0 comments on commit 544a061

Please sign in to comment.