Skip to content

Commit c80e915

Browse files
fix: fixed lint errors
1 parent 55b925d commit c80e915

File tree

8 files changed

+1068
-87
lines changed

8 files changed

+1068
-87
lines changed

core/commons-api/test/errors.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import _ from 'lodash';
2+
13
import {
24
getNotFound,
35
VerdaccioError,
@@ -11,7 +13,6 @@ import {
1113
getServiceUnavailable,
1214
getCode,
1315
} from '../src/index';
14-
import _ from 'lodash';
1516

1617
describe('testing errors', () => {
1718
test('should qualify as an native error', () => {

core/file-locking/src/__tests__/lock.spec.ts

Lines changed: 59 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import path from 'path';
2-
import fs from 'fs';
3-
import { lockFile, unlockFile, readFile } from '../index';
1+
import path from "path";
2+
import fs from "fs";
3+
4+
import { lockFile, unlockFile, readFile } from "../index";
45

56
interface Error {
67
message: string;
@@ -17,97 +18,109 @@ const removeTempFile = (filename: string): void => {
1718
});
1819
};
1920

20-
describe('testing locking', () => {
21-
test('file should be found to be locked', done => {
22-
lockFile(getFilePath('package.json'), (error: Error) => {
21+
describe("testing locking", () => {
22+
test("file should be found to be locked", done => {
23+
lockFile(getFilePath("package.json"), (error: Error) => {
2324
expect(error).toBeNull();
24-
removeTempFile('package.json.lock');
25+
removeTempFile("package.json.lock");
2526
done();
2627
});
2728
});
2829

29-
test('file should fail to be found to be locked', done => {
30-
lockFile(getFilePath('package.fail.json'), (error: Error) => {
31-
expect(error.message).toMatch(/ENOENT: no such file or directory, stat '(.*)package.fail.json'/);
30+
test("file should fail to be found to be locked", done => {
31+
lockFile(getFilePath("package.fail.json"), (error: Error) => {
32+
expect(error.message).toMatch(
33+
/ENOENT: no such file or directory, stat '(.*)package.fail.json'/
34+
);
3235
done();
3336
});
3437
});
3538

36-
test('file should to be found to be unLock', done => {
37-
unlockFile(getFilePath('package.json.lock'), (error: Error) => {
39+
test("file should to be found to be unLock", done => {
40+
unlockFile(getFilePath("package.json.lock"), (error: Error) => {
3841
expect(error).toBeNull();
3942
done();
4043
});
4144
});
4245

43-
test('read file with no options should to be found to be read it as string', done => {
44-
readFile(getFilePath('package.json'), (error: Error, data: any) => {
46+
test("read file with no options should to be found to be read it as string", done => {
47+
readFile(getFilePath("package.json"), (error: Error, data: any) => {
4548
expect(error).toBeNull();
4649
expect(data).toMatchSnapshot();
4750
done();
4851
});
4952
});
5053

51-
test('read file with no options should to be found to be read it as object', done => {
54+
test("read file with no options should to be found to be read it as object", done => {
5255
const options = {
53-
parse: true,
56+
parse: true
5457
};
55-
readFile(getFilePath('package.json'), options, (error: Error, data: any) => {
56-
expect(error).toBeNull();
57-
expect(data).toMatchSnapshot();
58-
done();
59-
});
58+
readFile(
59+
getFilePath("package.json"),
60+
options,
61+
(error: Error, data: any) => {
62+
expect(error).toBeNull();
63+
expect(data).toMatchSnapshot();
64+
done();
65+
}
66+
);
6067
});
6168

62-
test('read file with options (parse) should to be not found to be read it', done => {
69+
test("read file with options (parse) should to be not found to be read it", done => {
6370
const options = {
64-
parse: true,
71+
parse: true
6572
};
66-
readFile(getFilePath('package.fail.json'), options, (error: Error) => {
67-
expect(error.message).toMatch(/ENOENT: no such file or directory, open '(.*)package.fail.json'/);
73+
readFile(getFilePath("package.fail.json"), options, (error: Error) => {
74+
expect(error.message).toMatch(
75+
/ENOENT: no such file or directory, open '(.*)package.fail.json'/
76+
);
6877
done();
6978
});
7079
});
7180

72-
test('read file with options should to be found to be read it and fails to be parsed', done => {
81+
test("read file with options should to be found to be read it and fails to be parsed", done => {
7382
const options = {
74-
parse: true,
83+
parse: true
7584
};
7685
const errorMessage =
77-
process.platform === 'win32'
78-
? 'Unexpected token } in JSON at position 47'
79-
: 'Unexpected token } in JSON at position 44';
80-
readFile(getFilePath('wrong.package.json'), options, (error: Error) => {
86+
process.platform === "win32"
87+
? "Unexpected token } in JSON at position 47"
88+
: "Unexpected token } in JSON at position 44";
89+
readFile(getFilePath("wrong.package.json"), options, (error: Error) => {
8190
expect(error.message).toEqual(errorMessage);
8291
done();
8392
});
8493
});
8594

86-
test('read file with options (parse, lock) should to be found to be read it as object', done => {
95+
test("read file with options (parse, lock) should to be found to be read it as object", done => {
8796
const options = {
8897
parse: true,
89-
lock: true,
98+
lock: true
9099
};
91-
readFile(getFilePath('package2.json'), options, (error: Error, data: any) => {
92-
expect(error).toBeNull();
93-
expect(data).toMatchSnapshot();
94-
removeTempFile('package2.json.lock');
95-
done();
96-
});
100+
readFile(
101+
getFilePath("package2.json"),
102+
options,
103+
(error: Error, data: any) => {
104+
expect(error).toBeNull();
105+
expect(data).toMatchSnapshot();
106+
removeTempFile("package2.json.lock");
107+
done();
108+
}
109+
);
97110
});
98111

99-
test('read file with options (parse, lock) should to be found to be read it and fails to be parsed', done => {
112+
test("read file with options (parse, lock) should to be found to be read it and fails to be parsed", done => {
100113
const options = {
101114
parse: true,
102-
lock: true,
115+
lock: true
103116
};
104117
const errorMessage =
105-
process.platform === 'win32'
106-
? 'Unexpected token } in JSON at position 47'
107-
: 'Unexpected token } in JSON at position 44';
108-
readFile(getFilePath('wrong.package.json'), options, (error: Error) => {
118+
process.platform === "win32"
119+
? "Unexpected token } in JSON at position 47"
120+
: "Unexpected token } in JSON at position 44";
121+
readFile(getFilePath("wrong.package.json"), options, (error: Error) => {
109122
expect(error.message).toEqual(errorMessage);
110-
removeTempFile('wrong.package.json.lock');
123+
removeTempFile("wrong.package.json.lock");
111124
done();
112125
});
113126
});

core/file-locking/src/index.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import locker from 'lockfile';
2-
import fs from 'fs';
3-
import path from 'path';
4-
import { Callback } from '@verdaccio/types';
1+
import locker from "lockfile";
2+
import fs from "fs";
3+
import path from "path";
4+
5+
import { Callback } from "@verdaccio/types";
56

67
// locks a file by creating a lock file
78
const lockFile = function(name: string, callback: Callback): void {
@@ -48,7 +49,7 @@ const lockFile = function(name: string, callback: Callback): void {
4849
// number of times to attempt to create a lock
4950
retries: 100,
5051
// time (ms) between tries
51-
retryWait: 100,
52+
retryWait: 100
5253
};
5354
const lockFileName = `${name}.lock`;
5455
locker.lock(lockFileName, lockOpts, () => {
@@ -92,8 +93,12 @@ const unlockFile = function(name: string, next: Callback): void {
9293
* @param {*} options
9394
* @param {*} callback
9495
*/
95-
function readFile(name: string, options: any = {}, callback: any = (): void => {}): void {
96-
if (typeof options === 'function') {
96+
function readFile(
97+
name: string,
98+
options: any = {},
99+
callback: any = (): void => {}
100+
): void {
101+
if (typeof options === "function") {
97102
callback = options;
98103
options = {};
99104
}
@@ -118,7 +123,7 @@ function readFile(name: string, options: any = {}, callback: any = (): void => {
118123

119124
const read = function(): Promise<any> {
120125
return new Promise<any>((resolve, reject): void => {
121-
fs.readFile(name, 'utf8', function(err, contents) {
126+
fs.readFile(name, "utf8", function(err, contents) {
122127
if (err) {
123128
return reject(err);
124129
}

core/readme/tests/readme.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import parseReadme from '../src';
21
import fs from 'fs';
32
import path from 'path';
43

4+
import parseReadme from '../src';
5+
56
function readReadme(project: string, fileName = 'readme.md'): Promise<string> {
67
return new Promise((resolve, reject): void => {
78
fs.readFile(path.join(__dirname, 'partials', project, fileName), 'utf8', (err, data) => {

plugins/audit/src/audit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import request from 'request';
22
import express, { Request, Response } from 'express';
3-
43
import { Logger, IPluginMiddleware, IBasicAuth, PluginOptions } from '@verdaccio/types';
4+
55
import { ConfigAudit } from './types';
66

77
export default class ProxyAudit implements IPluginMiddleware<ConfigAudit> {

plugins/audit/tests/audit.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import ProxyAudit, { ConfigAudit } from '../src/index';
2-
31
import { Logger } from '@verdaccio/types';
42

3+
import ProxyAudit, { ConfigAudit } from '../src/index';
4+
55
const config: ConfigAudit = {
66
enabled: true,
77
} as ConfigAudit;

tools/eslint-config/rules/import.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
extends: ['plugin:import/typescript'],
2+
extends: ['plugin:import/errors', 'plugin:import/warnings', 'plugin:import/typescript'],
33
rules: {
44
'import/order': ['error', { 'newlines-between': 'always' }],
55
},

0 commit comments

Comments
 (0)