Skip to content

Commit

Permalink
chore(lint): add default-case ESLint rule (#1418)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored Oct 21, 2020
1 parent 574bf6f commit c272a55
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 27 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
// Those ESLint rules are not enabled by Prettier, ESLint recommended rules
// nor standard JavaScript. However, they are still useful
'array-callback-return': [2, { allowImplicit: true, checkForEach: true }],
'default-case': 2,
'func-name-matching': [2, { considerPropertyDescriptor: true }],
'max-params': [2, { max: 4 }],
'multiline-comment-style': [2, 'separate-lines'],
Expand Down
13 changes: 3 additions & 10 deletions src/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,11 @@ This will allow for Netlify Continuous deployment to build branch & PR previews.
For more details on Netlify CI checkout the docs: http://bit.ly/2N0Jhy5
`)
let message
switch (repo.error) {
case "Couldn't find origin url": {
message = `Unable to find a remote origin URL. Please add a git remote.
if (repo.error === "Couldn't find origin url") {
console.log(`Unable to find a remote origin URL. Please add a git remote.
git remote add origin https://github.com/YourUserName/RepoName.git
`
break
}
}
if (message) {
console.log(message)
`)
}

const NEW_SITE_NO_GIT = 'Yes, create and deploy site manually'
Expand Down
9 changes: 5 additions & 4 deletions src/functions-templates/js/fauna-crud/fauna-crud.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ exports.handler = async (event, context) => {
statusCode: 500,
body: 'invalid segments in DELETE request, must be /.netlify/functions/fauna-crud/123456',
}
}
return {
statusCode: 500,
body: 'unrecognized HTTP Method, must be one of GET/POST/PUT/DELETE',
default:
return {
statusCode: 500,
body: 'unrecognized HTTP Method, must be one of GET/POST/PUT/DELETE',
}
}
}
4 changes: 2 additions & 2 deletions src/functions-templates/js/url-shortener/url-shortener.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports.handler = (event, context, callback) => {
case 'DELETE':
// your code here
return
default:
return callback(new Error('unrecognized HTTP Method, must be one of GET/POST/PUT/DELETE'))
}

return callback(new Error('unrecognized HTTP Method, must be one of GET/POST/PUT/DELETE'))
}
17 changes: 6 additions & 11 deletions src/utils/get-repo-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,7 @@ async function getRepoData(remote) {
repo_branch: repoData.branch,
allowed_branches: [repoData.branch],
host: remoteData.host,
}

switch (remoteData.host) {
case 'github.com': {
repo.provider = 'github'
break
}
case 'gitlab.com': {
repo.provider = 'gitlab'
break
}
provider: PROVIDERS[remoteData.host],
}
} catch (error) {
// console.log('error', error)
Expand All @@ -70,4 +60,9 @@ async function getRepoData(remote) {
return repo
}

const PROVIDERS = {
'github.com': 'github',
'gitlab.com': 'gitlab',
}

module.exports = getRepoData
2 changes: 2 additions & 0 deletions src/utils/link/link-by-prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`)
}
break
}
default:
return
}

if (!site) {
Expand Down

0 comments on commit c272a55

Please sign in to comment.