-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Normalize quotes around string literals (#59)
* feat: Modify RepresenterRewriteOutput to use quotes around string literals This commit modifies the RepresenterRewriteOutput class to ensure that string literals are enclosed in backticks (`) when generating the representation. --------- Co-authored-by: Erik Schierboom <[email protected]>
- Loading branch information
1 parent
78eb07c
commit 97a9968
Showing
10 changed files
with
106 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
test/fixtures/general/normalize-quotes/expected_mapping.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"IDENTIFIER_1": "colourDuo", | ||
"IDENTIFIER_2": "checkNulls", | ||
"IDENTIFIER_3": "checkNumbers", | ||
"IDENTIFIER_4": "checkString", | ||
"IDENTIFIER_5": "checkBool", | ||
"IDENTIFIER_6": "checkNesting", | ||
"IDENTIFIER_7": "first", | ||
"IDENTIFIER_8": "second", | ||
"IDENTIFIER_9": "rest", | ||
"IDENTIFIER_10": "COLORS", | ||
"IDENTIFIER_11": "indexOf" | ||
} |
10 changes: 10 additions & 0 deletions
10
test/fixtures/general/normalize-quotes/expected_representation.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const decodedValue = IDENTIFIER_1 => { | ||
let IDENTIFIER_2 = [null, null, null]; | ||
let IDENTIFIER_3 = 666; | ||
let IDENTIFIER_4 = `please work`; | ||
let IDENTIFIER_5 = true; | ||
let IDENTIFIER_6 = `this string has "double" and escaped 'single'`; | ||
let [IDENTIFIER_7, IDENTIFIER_8, ...IDENTIFIER_9] = IDENTIFIER_1; | ||
return Number(IDENTIFIER_10.IDENTIFIER_11(IDENTIFIER_7) + `` + IDENTIFIER_10.IDENTIFIER_11(IDENTIFIER_8)); | ||
}; | ||
const IDENTIFIER_10 = [`black`, `brown`, `red`, `orange`, `yellow`, `green`, `blue`, `violet`, `grey`, `white`]; |
30 changes: 30 additions & 0 deletions
30
test/fixtures/general/normalize-quotes/resistor-color-duo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// This is only a SKELETON file for the 'Resistor Color Duo' exercise. It's been provided as a | ||
// convenience to get you started writing code faster. | ||
// | ||
|
||
export const decodedValue = (colourDuo) => { | ||
let checkNulls = [null, null, null] | ||
let checkNumbers = 666 | ||
let checkString = "please work" | ||
let checkBool = true | ||
let checkNesting = 'this string has "double" and escaped \'single\'' | ||
let [first, second, ...rest] = colourDuo | ||
return Number(COLORS.indexOf(first) +''+ COLORS.indexOf(second)) | ||
}; | ||
|
||
// Here is a comment that contains 'single' and "double" quotes | ||
// And here is another one with `backticks` | ||
|
||
const COLORS = [ | ||
'black', | ||
"brown", | ||
`red`, | ||
"orange", | ||
'yellow', | ||
"green", | ||
'blue', | ||
'violet', | ||
'grey', | ||
'white', | ||
] |
23 changes: 23 additions & 0 deletions
23
test/fixtures/general/normalize-quotes/resistor-color-duo.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { decodedValue } from './resistor-color-duo'; | ||
|
||
describe('Resistor Colors', () => { | ||
test('Brown and black', () => { | ||
expect(decodedValue(['brown', 'black'])).toEqual(10); | ||
}); | ||
|
||
xtest('Blue and grey', () => { | ||
expect(decodedValue(['blue', 'grey'])).toEqual(68); | ||
}); | ||
|
||
xtest('Yellow and violet', () => { | ||
expect(decodedValue(['yellow', 'violet'])).toEqual(47); | ||
}); | ||
|
||
xtest('Orange and orange', () => { | ||
expect(decodedValue(['orange', 'orange'])).toEqual(33); | ||
}); | ||
|
||
xtest('Ignore additional colors', () => { | ||
expect(decodedValue(['green', 'brown', 'orange'])).toEqual(51); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
test/fixtures/general/normalize-whitespace/expected_representation.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const twoFer = (IDENTIFIER_1 = 'you') => `One for ${IDENTIFIER_1}, one for me.`; | ||
export const twoFer = (IDENTIFIER_1 = `you`) => `One for ${IDENTIFIER_1}, one for me.`; |
2 changes: 1 addition & 1 deletion
2
test/fixtures/general/remove-comments/expected_representation.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const twoFer = (IDENTIFIER_1 = 'you') => `One for ${IDENTIFIER_1}, one for me.`; | ||
export const twoFer = (IDENTIFIER_1 = `you`) => `One for ${IDENTIFIER_1}, one for me.`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const twoFer = (IDENTIFIER_1 = 'you') => `One for ${IDENTIFIER_1}, one for me.`; | ||
export const twoFer = (IDENTIFIER_1 = `you`) => `One for ${IDENTIFIER_1}, one for me.`; |