Skip to content

Commit

Permalink
chore: use shared eslint 9 config
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud committed Aug 8, 2024
1 parent c04354d commit 0d0de82
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 75 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

7 changes: 7 additions & 0 deletions .eslintrc → eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import config from '@eik/eslint-config';

export default config;

/*
{
"parser": "@babel/eslint-parser",
"extends": ["airbnb-base", "prettier"],
Expand All @@ -18,3 +23,5 @@
"no-restricted-syntax": [0]
}
}
*/
49 changes: 33 additions & 16 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ const DEFAULT_BUCKET = 'eik_files';
*/

const SinkGCS = class SinkGCS extends Sink {
constructor(storageOptions, {
writeTimeout = 60000,
writeGzip = false,
rootPath = DEFAULT_ROOT_PATH,
bucket = DEFAULT_BUCKET,
} = {}) {
constructor(
storageOptions,
{
writeTimeout = 60000,
writeGzip = false,
rootPath = DEFAULT_ROOT_PATH,
bucket = DEFAULT_BUCKET,
} = {},
) {
super();
if (typeof storageOptions !== 'object' || storageOptions === null) throw new Error('"storageOptions" argument must be provided');;
if (typeof storageOptions !== 'object' || storageOptions === null)
throw new Error('"storageOptions" argument must be provided');
this._writeTimeout = writeTimeout;
this._writeGzip = writeGzip;
this._rootPath = rootPath;
Expand All @@ -31,7 +35,8 @@ const SinkGCS = class SinkGCS extends Sink {
this._metrics = new Metrics();
this._counter = this._metrics.counter({
name: 'eik_core_sink_gcs',
description: 'Counter measuring access to the Google Cloud Storage sink',
description:
'Counter measuring access to the Google Cloud Storage sink',
labels: {
operation: 'n/a',
success: false,
Expand Down Expand Up @@ -81,7 +86,9 @@ const SinkGCS = class SinkGCS extends Sink {
});

gcsStream.on('finish', () => {
this._counter.inc({ labels: { success: true, access: true, operation } });
this._counter.inc({
labels: { success: true, access: true, operation },
});
});

resolve(gcsStream);
Expand Down Expand Up @@ -117,15 +124,17 @@ const SinkGCS = class SinkGCS extends Sink {
gcsStream.read();
});

gcsStream.on('error', error => {
gcsStream.on('error', (error) => {
if (streamClosed) {
this._counter.inc({ labels: { access: true, operation } });
reject(error);
}
});

gcsStream.on('response', response => {
this._counter.inc({ labels: { success: true, access: true, operation } });
gcsStream.on('response', (response) => {
this._counter.inc({
labels: { success: true, access: true, operation },
});

if (response.statusCode === 200) {
streamClosed = false;
Expand All @@ -136,7 +145,11 @@ const SinkGCS = class SinkGCS extends Sink {
obj.stream = gcsStream;
resolve(obj);
} else {
reject(new Error(`Could not read file. Got http status code ${response.statusCode} from GCS`));
reject(
new Error(
`Could not read file. Got http status code ${response.statusCode} from GCS`,
),
);
}
});
});
Expand All @@ -162,14 +175,16 @@ const SinkGCS = class SinkGCS extends Sink {
return;
}

this._counter.inc({ labels: { success: true, access: true, operation } });
this._counter.inc({
labels: { success: true, access: true, operation },
});

this._bucket.deleteFiles(
{
prefix: pathname,
force: true,
},
error => {
(error) => {
if (error) return reject(error);
return resolve();
},
Expand Down Expand Up @@ -197,7 +212,9 @@ const SinkGCS = class SinkGCS extends Sink {
return;
}

this._counter.inc({ labels: { success: true, access: true, operation } });
this._counter.inc({
labels: { success: true, access: true, operation },
});

const src = this._bucket.file(pathname);

Expand Down
16 changes: 5 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,11 @@
"@metrics/client": "^2.5.0"
},
"devDependencies": {
"@babel/eslint-parser": "7.24.7",
"@eik/semantic-release-config": "^1.0.0",
"@semantic-release/changelog": "6.0.3",
"@semantic-release/git": "10.0.1",
"eslint": "8.57.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-prettier": "5.1.3",
"prettier": "3.3.2",
"semantic-release": "^24.0.0",
"@eik/eslint-config": "1.0.2",
"@eik/semantic-release-config": "1.0.0",
"eslint": "9.8.0",
"prettier": "3.3.3",
"semantic-release": "24.0.0",
"tap": "18.8.0",
"unique-slug": "4.0.0"
}
Expand Down
2 changes: 1 addition & 1 deletion release.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default {
extends: '@eik/semantic-release-config',
extends: '@eik/semantic-release-config',
};
Loading

0 comments on commit 0d0de82

Please sign in to comment.