diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 9d5ce399a..000000000 --- a/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "printWidth": 120, - "singleQuote": true, - "trailingComma": "es5" -} diff --git a/cmds/docs/edit.js b/cmds/docs/edit.js index ee24f4d1b..6c936e09d 100644 --- a/cmds/docs/edit.js +++ b/cmds/docs/edit.js @@ -33,7 +33,7 @@ exports.args = [ }, ]; -exports.run = async function(opts) { +exports.run = async function (opts) { const { slug, key, version } = opts; if (!key) { diff --git a/cmds/docs/index.js b/cmds/docs/index.js index dc6744ac3..fdd1b24d3 100644 --- a/cmds/docs/index.js +++ b/cmds/docs/index.js @@ -33,7 +33,7 @@ exports.args = [ }, ]; -exports.run = function(opts) { +exports.run = function (opts) { const { folder, key, version } = opts; if (!key) { @@ -98,10 +98,7 @@ exports.run = function(opts) { const matter = frontMatter(file); // Stripping the markdown extension from the filename const slug = filename.replace(path.extname(filename), ''); - const hash = crypto - .createHash('sha1') - .update(file) - .digest('hex'); + const hash = crypto.createHash('sha1').update(file).digest('hex'); return request .get(`${config.host}/api/v1/docs/${slug}`, { diff --git a/cmds/login.js b/cmds/login.js index f432aa403..a75b161d1 100644 --- a/cmds/login.js +++ b/cmds/login.js @@ -36,7 +36,7 @@ async function getCredentials(opts) { }; } -exports.run = async function(opts) { +exports.run = async function (opts) { let { email, password, project, token } = opts; // We only want to prompt for input outside of the test environment diff --git a/cmds/oas.js b/cmds/oas.js index 8e314ce6b..3aa3d7ec7 100644 --- a/cmds/oas.js +++ b/cmds/oas.js @@ -9,7 +9,7 @@ exports.position = 1; exports.args = []; -exports.run = function() { +exports.run = function () { const cp = spawn(path.join(__dirname, '..', 'node_modules', '.bin', 'oas'), process.argv.slice(3), { stdio: 'inherit', }); diff --git a/cmds/open.js b/cmds/open.js index 747d71e4f..21ebdd2b7 100644 --- a/cmds/open.js +++ b/cmds/open.js @@ -12,7 +12,7 @@ exports.position = 2; exports.args = []; -exports.run = function(opts) { +exports.run = function (opts) { const project = configStore.get('project'); if (!project) { return Promise.reject(new Error(`Please login using \`${config.cli} ${loginCmd.command}\`.`)); diff --git a/cmds/swagger.js b/cmds/swagger.js index b092ee2e7..051baa34a 100644 --- a/cmds/swagger.js +++ b/cmds/swagger.js @@ -41,7 +41,7 @@ exports.args = [ }, ]; -exports.run = async function(opts) { +exports.run = async function (opts) { const { spec, version } = opts; let { key, id } = opts; let selectedVersion; diff --git a/cmds/versions/create.js b/cmds/versions/create.js index 4bcadc278..1a33593b6 100644 --- a/cmds/versions/create.js +++ b/cmds/versions/create.js @@ -49,7 +49,7 @@ exports.args = [ }, ]; -exports.run = async function(opts) { +exports.run = async function (opts) { let versionList; const { key, version, codename, fork, main, beta, isPublic } = opts; diff --git a/cmds/versions/delete.js b/cmds/versions/delete.js index e4a9f8456..d604abdc9 100644 --- a/cmds/versions/delete.js +++ b/cmds/versions/delete.js @@ -22,7 +22,7 @@ exports.args = [ }, ]; -exports.run = async function(opts) { +exports.run = async function (opts) { const { key, version } = opts; if (!key) { diff --git a/cmds/versions/index.js b/cmds/versions/index.js index 7e51abe18..de96afbd5 100644 --- a/cmds/versions/index.js +++ b/cmds/versions/index.js @@ -79,7 +79,7 @@ const getVersionFormatted = version => { return output.join('\n'); }; -exports.run = function(opts) { +exports.run = function (opts) { const { key, version, raw } = opts; if (!key) { diff --git a/cmds/versions/update.js b/cmds/versions/update.js index a1c50b93b..ee4e7e6d6 100644 --- a/cmds/versions/update.js +++ b/cmds/versions/update.js @@ -43,7 +43,7 @@ exports.args = [ }, ]; -exports.run = async function(opts) { +exports.run = async function (opts) { const { key, version, codename, newVersion, main, beta, isPublic, deprecated } = opts; if (!key) { diff --git a/lib/prompts.js b/lib/prompts.js index 704c4f599..54046ce6a 100644 --- a/lib/prompts.js +++ b/lib/prompts.js @@ -69,6 +69,7 @@ exports.createVersionPrompt = (versionList, opts, isUpdate) => [ skip() { return opts.fork || isUpdate; }, + // eslint-disable-next-line sonarjs/no-identical-functions choices: versionList.map(v => { return { message: v.version, diff --git a/package-lock.json b/package-lock.json index c6acc54a2..c0cd1f52f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -224,18 +224,18 @@ } }, "@babel/runtime": { - "version": "7.8.7", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.8.7.tgz", - "integrity": "sha512-+AATMUFppJDw6aiR5NVPHqIQBlV/Pj8wY/EZH+lmvRdUo9xBaz/rF3alAwFJQavvKfeOlPE7oaaDHVbcySbCsg==", + "version": "7.9.2", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.9.2.tgz", + "integrity": "sha512-NE2DtOdufG7R5vnfQUTehdTfNycfUANEtCa9PssN9O/xmTzP4E08UI797ixaei6hBEVL9BI/PsdJS5x7mWoB9Q==", "dev": true, "requires": { "regenerator-runtime": "^0.13.4" } }, "@babel/runtime-corejs3": { - "version": "7.8.7", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.8.7.tgz", - "integrity": "sha512-sc7A+H4I8kTd7S61dgB9RomXu/C+F4IrRr4Ytze4dnfx7AXEpCrejSNpjx7vq6y/Bak9S6Kbk65a/WgMLtg43Q==", + "version": "7.9.2", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.9.2.tgz", + "integrity": "sha512-HHxmgxbIzOfFlZ+tdeRKtaxWOMUoCG5Mu3wKeUmOxjYrwb3AAHgnmtCUbPPK11/raIWLIBK250t8E2BPO0p7jA==", "dev": true, "requires": { "core-js-pure": "^3.0.0", @@ -893,9 +893,9 @@ } }, "@readme/eslint-config": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/@readme/eslint-config/-/eslint-config-1.15.0.tgz", - "integrity": "sha512-Mpj4/PPcmpEvjGnRKTDl9Ns/wsox0BD0RBoXg0n5jNLqDf7lbldTpjOvTxn6AbLBKf8FZG8kwH5VqgQgjbEEJQ==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@readme/eslint-config/-/eslint-config-2.0.0.tgz", + "integrity": "sha512-hKFBAmyAK+8IdQ9UBxxCSrBLOWAM6FIBrLR2LskYlyamIKbWmjSrgBpTEXo72Rgmg3VIl2Y3lCjGabgF9RL5oA==", "dev": true, "requires": { "eslint-config-airbnb-base": "^14.0.0", @@ -1035,20 +1035,20 @@ "dev": true }, "@typescript-eslint/experimental-utils": { - "version": "2.23.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.23.0.tgz", - "integrity": "sha512-OswxY59RcXH3NNPmq+4Kis2CYZPurRU6mG5xPcn24CjFyfdVli5mySwZz/g/xDbJXgDsYqNGq7enV0IziWGXVQ==", + "version": "2.24.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.24.0.tgz", + "integrity": "sha512-DXrwuXTdVh3ycNCMYmWhUzn/gfqu9N0VzNnahjiDJvcyhfBy4gb59ncVZVxdp5XzBC77dCncu0daQgOkbvPwBw==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.23.0", + "@typescript-eslint/typescript-estree": "2.24.0", "eslint-scope": "^5.0.0" } }, "@typescript-eslint/typescript-estree": { - "version": "2.23.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.23.0.tgz", - "integrity": "sha512-pmf7IlmvXdlEXvE/JWNNJpEvwBV59wtJqA8MLAxMKLXNKVRC3HZBXR/SlZLPWTCcwOSg9IM7GeRSV3SIerGVqw==", + "version": "2.24.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.24.0.tgz", + "integrity": "sha512-RJ0yMe5owMSix55qX7Mi9V6z2FDuuDpN6eR5fzRJrp+8in9UF41IGNQHbg5aMK4/PjVaEQksLvz0IA8n+Mr/FA==", "dev": true, "requires": { "debug": "^4.1.1", @@ -2962,9 +2962,9 @@ } }, "eslint-config-prettier": { - "version": "6.10.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.10.0.tgz", - "integrity": "sha512-AtndijGte1rPILInUdHjvKEGbIV06NuvPrqlIEaEaWtbtvJh464mDeyGMdZEQMsGvC0ZVkiex1fSNcC4HAbRGg==", + "version": "6.10.1", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.10.1.tgz", + "integrity": "sha512-svTy6zh1ecQojvpbJSgH3aei/Rt7C6i090l5f2WQ4aB05lYHeZIR1qL4wZyyILTbtmnbHP5Yn8MrsOJMGa8RkQ==", "dev": true, "requires": { "get-stdin": "^6.0.0" @@ -7572,9 +7572,9 @@ "dev": true }, "prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.1.tgz", + "integrity": "sha512-piXGBcY1zoFOG0MvHpNE5reAGseLmaCRifQ/fmfF49BcYkInEs/naD/unxGNAeOKFA5+JxVrPyMvMlpzcd20UA==", "dev": true }, "prettier-linter-helpers": { @@ -7725,9 +7725,9 @@ } }, "react-is": { - "version": "16.13.0", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.0.tgz", - "integrity": "sha512-GFMtL0vHkiBv9HluwNZTggSn/sCyEt9n02aM0dSAjGGyqyNlAyftYm4phPxdvCigG15JreC5biwxCgTAJZ7yAA==", + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", "dev": true }, "read": { diff --git a/package.json b/package.json index e1015f74a..fdae81910 100644 --- a/package.json +++ b/package.json @@ -49,12 +49,12 @@ "table-layout": "^1.0.0" }, "devDependencies": { - "@readme/eslint-config": "^1.3.1", + "@readme/eslint-config": "^2.0.0", "conventional-changelog-cli": "^2.0.31", "eslint": "^6.2.0", "jest": "^25.1.0", "nock": "^12.0.0", - "prettier": "^1.12.1" + "prettier": "^2.0.1" }, "scripts": { "lint": "eslint .", @@ -75,5 +75,6 @@ "statements": 90 } } - } + }, + "prettier": "@readme/eslint-config/prettier" } diff --git a/test/cmds/docs.test.js b/test/cmds/docs.test.js index 815bd7b87..c31a50979 100644 --- a/test/cmds/docs.test.js +++ b/test/cmds/docs.test.js @@ -224,13 +224,9 @@ describe('rdme docs:edit', () => { expect.assertions(2); const slug = 'getting-started'; - const getMock = nock(config.host) - .get(`/api/v1/docs/${slug}`) - .reply(200, {}); + const getMock = nock(config.host).get(`/api/v1/docs/${slug}`).reply(200, {}); - const putMock = nock(config.host) - .put(`/api/v1/docs/${slug}`) - .reply(400, { error: 'Bad Request' }); + const putMock = nock(config.host).put(`/api/v1/docs/${slug}`).reply(400, { error: 'Bad Request' }); function mockEditor(filename, cb) { return cb(0); @@ -248,9 +244,7 @@ describe('rdme docs:edit', () => { it('should handle error if $EDITOR fails', () => { expect.assertions(1); const slug = 'getting-started'; - nock(config.host) - .get(`/api/v1/docs/${slug}`) - .reply(200, {}); + nock(config.host).get(`/api/v1/docs/${slug}`).reply(200, {}); function mockEditor(filename, cb) { return cb(1); diff --git a/test/cmds/login.test.js b/test/cmds/login.test.js index c33eeef25..fb93d2413 100644 --- a/test/cmds/login.test.js +++ b/test/cmds/login.test.js @@ -28,9 +28,7 @@ describe('rdme login', () => { const project = 'subdomain'; const apiKey = 'abcdefg'; - const mock = nock(config.host) - .post('/api/v1/login', { email, password, project }) - .reply(200, { apiKey }); + const mock = nock(config.host).post('/api/v1/login', { email, password, project }).reply(200, { apiKey }); return cmd.run({ email, password, project }).then(() => { mock.done(); @@ -47,12 +45,10 @@ describe('rdme login', () => { const password = '123456'; const project = 'subdomain'; - const mock = nock(config.host) - .post('/api/v1/login', { email, password, project }) - .reply(400, { - description: 'Invalid email/password', - error: 'Bad Request', - }); + const mock = nock(config.host).post('/api/v1/login', { email, password, project }).reply(400, { + description: 'Invalid email/password', + error: 'Bad Request', + }); return cmd.run({ email, password, project }).catch(err => { mock.done(); @@ -67,12 +63,10 @@ describe('rdme login', () => { const password = '123456'; const project = 'subdomain'; - const mock = nock(config.host) - .post('/api/v1/login', { email, password, project }) - .reply(400, { - description: 'You must provide a Two Factor Code', - error: 'Bad Request', - }); + const mock = nock(config.host).post('/api/v1/login', { email, password, project }).reply(400, { + description: 'You must provide a Two Factor Code', + error: 'Bad Request', + }); return cmd.run({ email, password, project }).catch(err => { mock.done(); diff --git a/test/cmds/versions.test.js b/test/cmds/versions.test.js index 3d2769ce5..7d2687a77 100644 --- a/test/cmds/versions.test.js +++ b/test/cmds/versions.test.js @@ -136,10 +136,7 @@ describe('rdme versions*', () => { is_beta: false, }); - const mockRequest = nock(config.host) - .post(`/api/v1/version`) - .basicAuth({ user: key }) - .reply(400); + const mockRequest = nock(config.host).post(`/api/v1/version`).basicAuth({ user: key }).reply(400); return createVersion.run({ key, version, fork: '0.0.5' }).catch(err => { expect(err.message).toBe('Failed to create a new version using your specified parameters.'); @@ -164,10 +161,7 @@ describe('rdme versions*', () => { }); it('should delete a specific version', async () => { - const mockRequest = nock(config.host) - .delete(`/api/v1/version/${version}`) - .basicAuth({ user: key }) - .reply(200); + const mockRequest = nock(config.host).delete(`/api/v1/version/${version}`).basicAuth({ user: key }).reply(200); return deleteVersion.run({ key, version }).then(() => { mockRequest.done(); @@ -175,10 +169,7 @@ describe('rdme versions*', () => { }); it('should catch any request errors', async () => { - const mockRequest = nock(config.host) - .delete(`/api/v1/version/${version}`) - .basicAuth({ user: key }) - .reply(400); + const mockRequest = nock(config.host).delete(`/api/v1/version/${version}`).basicAuth({ user: key }).reply(400); return deleteVersion.run({ key, version }).catch(err => { expect(err.message).toBe('Failed to delete target version.');