Skip to content

Commit

Permalink
remove "Standard JS" exception using ternary in tests (#87)
Browse files Browse the repository at this point in the history
* remove remaining curly exception from .eslintrc.yml
* use a ternary in an if statement in init-with-example-with-log.test.js
* use `lint:fix` to fix formatting in the new ternary
* use the new ternary in some other test cases
* update lint notes in package.json
  (There are no longer any exceptions to the eslint rules from "Standard JS".)
  • Loading branch information
brodybits committed Dec 30, 2020
1 parent 860d540 commit b5ebe38
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 46 deletions.
2 changes: 0 additions & 2 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@ rules:
singleQuote: true
spaceBeforeFunctionParen: true
trailingComma: none
# TODO resolve ignored "Standard JS" rule:
curly: 0
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"- Prettier is used alone for the markup (*.md, *.json, *.yml) files",
"- Prettier `--end-of-line=auto` option is needed for CI on Windows.",
"- eslint-config-standard is used together with some eslint plugins",
" to check conformance to 'Standard JS' rules, with a very limited",
" number of exceptions at this point."
" to check conformance to 'Standard JS' rules, now with no exceptions."
],
"lint": "run-scripts lint:eslint lint:markup",
"lint:markup": "prettier --check --end-of-line=auto ./**/*.md ./**/*.json ./**/*.yml",
Expand Down
9 changes: 3 additions & 6 deletions tests/init-with-example/init-with-example-with-log.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ jest.mock('prompts', () => args => {
jest.mock('execa', () => (cmd, args, opts) => {
mockCallSnapshot.push({ execa: [cmd, args, opts] })
if (cmd === 'git') {
if (args[1] === 'user.email')
return Promise.resolve({ stdout: 'alice@example.com' })
else
return Promise.resolve({
stdout: 'Alice'
})
return args[1] === 'user.email'
? Promise.resolve({ stdout: 'alice@example.com' })
: Promise.resolve({ stdout: 'Alice' })
} else {
return Promise.resolve()
}
Expand Down
9 changes: 3 additions & 6 deletions tests/no-example/no-example-module-all.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,9 @@ jest.mock('prompts', () => args => {
jest.mock('execa', () => (cmd, args, opts) => {
mockCallSnapshot.push({ execa: [cmd, args, opts] })
if (cmd === 'git') {
if (args[1] === 'user.email')
return Promise.resolve({ stdout: 'alice@example.com' })
else
return Promise.resolve({
stdout: 'Alice'
})
return args[1] === 'user.email'
? Promise.resolve({ stdout: 'alice@example.com' })
: Promise.resolve({ stdout: 'Alice' })
} else {
return Promise.resolve()
}
Expand Down
9 changes: 3 additions & 6 deletions tests/tvos/view-with-example/tvos-view-with-example.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ jest.mock('prompts', () => args => {
jest.mock('execa', () => (cmd, args, opts) => {
mockCallSnapshot.push({ execa: [cmd, args, opts] })
if (cmd === 'git') {
if (args[1] === 'user.email')
return Promise.resolve({ stdout: 'alice@example.com' })
else
return Promise.resolve({
stdout: 'Alice'
})
return args[1] === 'user.email'
? Promise.resolve({ stdout: 'alice@example.com' })
: Promise.resolve({ stdout: 'Alice' })
} else {
return Promise.resolve()
}
Expand Down
9 changes: 3 additions & 6 deletions tests/tvos/with-example/tvos-with-example.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ jest.mock('prompts', () => args => {
jest.mock('execa', () => (cmd, args, opts) => {
mockCallSnapshot.push({ execa: [cmd, args, opts] })
if (cmd === 'git') {
if (args[1] === 'user.email')
return Promise.resolve({ stdout: 'alice@example.com' })
else
return Promise.resolve({
stdout: 'Alice'
})
return args[1] === 'user.email'
? Promise.resolve({ stdout: 'alice@example.com' })
: Promise.resolve({ stdout: 'Alice' })
} else {
return Promise.resolve()
}
Expand Down
9 changes: 3 additions & 6 deletions tests/view/no-example/init-view-no-example-with-log.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ jest.mock('prompts', () => args => {
jest.mock('execa', () => (cmd, args, opts) => {
mockCallSnapshot.push({ execa: [cmd, args, opts] })
if (cmd === 'git') {
if (args[1] === 'user.email')
return Promise.resolve({ stdout: 'alice@example.com' })
else
return Promise.resolve({
stdout: 'Alice'
})
return args[1] === 'user.email'
? Promise.resolve({ stdout: 'alice@example.com' })
: Promise.resolve({ stdout: 'Alice' })
} else {
return Promise.resolve()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ jest.mock('prompts', () => args => {
jest.mock('execa', () => (cmd, args, opts) => {
mockCallSnapshot.push({ execa: [cmd, args, opts] })
if (cmd === 'git') {
if (args[1] === 'user.email')
return Promise.resolve({ stdout: 'alice@example.com' })
else
return Promise.resolve({
stdout: 'Alice'
})
return args[1] === 'user.email'
? Promise.resolve({ stdout: 'alice@example.com' })
: Promise.resolve({ stdout: 'Alice' })
} else {
return Promise.resolve()
}
Expand Down
9 changes: 3 additions & 6 deletions tests/with-apple-networking/with-apple-networking.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ jest.mock('prompts', () => args => {
jest.mock('execa', () => (cmd, args, opts) => {
mockCallSnapshot.push({ execa: [cmd, args, opts] })
if (cmd === 'git') {
if (args[1] === 'user.email')
return Promise.resolve({ stdout: 'alice@example.com' })
else
return Promise.resolve({
stdout: 'Alice'
})
return args[1] === 'user.email'
? Promise.resolve({ stdout: 'alice@example.com' })
: Promise.resolve({ stdout: 'Alice' })
} else {
return Promise.resolve()
}
Expand Down

0 comments on commit b5ebe38

Please sign in to comment.