generated from ossf/project-template
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create/implement separate hello.js for hello.html config
Currently configuration is mostly in a YAML file embedded in the lab's HTML. This means that the lab configuration cannot be shared between locales (translations), which is annoying. We can't easily load YAML or JSON from a separate file when running or testing locally. However, we *can* easily load a separate file if it's in JavaScript format. This switches the configuration of lab hello.html so it uses the configuration in hello.js. Signed-off-by: David A. Wheeler <[email protected]>
- Loading branch information
1 parent
a04d174
commit 442c032
Showing
4 changed files
with
160 additions
and
104 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
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 |
---|---|---|
@@ -0,0 +1,104 @@ | ||
info = | ||
{ | ||
"hints": [ | ||
{ | ||
"absent": String.raw`^ console \. log \(`, | ||
"text": " Please use the form console.log(\"...\");", | ||
"examples": [ | ||
[ "" ], | ||
[ "foo" ] | ||
] | ||
}, | ||
{ | ||
"present": "Goodbye", | ||
"text": "You need to change the text Goodbye to something else.", | ||
"examples": [ | ||
[ "console.log(\"Goodbye.\");" ] | ||
] | ||
}, | ||
{ | ||
"present": "hello", | ||
"text": "Please capitalize Hello.", | ||
"examples": [ | ||
[ "console.log(\"hello.\");" ] | ||
] | ||
}, | ||
{ | ||
"present": "World", | ||
"text": "Please lowercase world.", | ||
"examples": [ | ||
[ "console.log(\"Hello, World!\");" ] | ||
] | ||
}, | ||
{ | ||
"present": "Hello[^,]", | ||
"text": "Put a comma immediately after Hello.", | ||
"examples": [ | ||
[ "console.log(\"Hello world.\");" ] | ||
] | ||
}, | ||
{ | ||
"present": "Hello", | ||
"absent": "[Ww]orld", | ||
"text": "There's a Hello, but you need to also mention the world.", | ||
"examples": [ | ||
[ "console.log(\"Hello, \");" ] | ||
] | ||
}, | ||
{ | ||
"present": String.raw`world[^\!]`, | ||
"text": "Put an exclamation point immediately after world.", | ||
"examples": [ | ||
[ "console.log(\"Hello, world.\");" ] | ||
] | ||
}, | ||
{ | ||
"present": String.raw`Hello,\s*world!`, | ||
"absent": String.raw`Hello,\x20world!`, | ||
"text": "You need exactly one space between 'Hello,' and 'world!'", | ||
"examples": [ | ||
[ "console.log(\"Hello, world!\");" ] | ||
] | ||
}, | ||
{ | ||
"present": String.raw`^ console \. log \( Hello`, | ||
"text": "You must quote constant strings using \", ', or `", | ||
"examples": [ | ||
[ "console.log(Hello, world" ], | ||
[ "console.log( Hello, world" ] | ||
] | ||
}, | ||
{ | ||
"absent": String.raw` ; $`, | ||
"text": "Please end this statement with a semicolon. JavaScript does not require a semicolon in this case, but usually when modifying source code you should follow the style of the current code.\n", | ||
"examples": [ | ||
[ " console.log(\"Hello, world!\") " ] | ||
] | ||
} | ||
], | ||
"successes": [ | ||
[ " console . log( \"Hello, world!\" ) ; " ], | ||
[ " console . log( 'Hello, world!' ) ; " ], | ||
[ " console . log( `Hello, world!` ) ; " ] | ||
], | ||
"failures": [ | ||
[ " console . log( Hello, world! ) ; " ], | ||
[ " console . log(\"hello, world!\") ; " ] | ||
], | ||
// All regexes are preprocessed by a set of rules. You can replace them with your | ||
// own set. You can completely eliminate them by providing an empty set of rules: | ||
// "preprocessing" : [ ], | ||
// Here are tests for default preprocessing. You do not need this in | ||
// every lab, but it demonstrates how to create tests for your preprocessing. | ||
"preprocessingTests": [ | ||
[ | ||
String.raw`\s* console \. log \( (["'${BACKQUOTE}])Hello,\x20world!\1 \) ; \s*`, | ||
String.raw`\s*console\s*\.\s*log\s*\(\s*(["'${BACKQUOTE}])Hello,\x20world!\1\s*\)\s*;\s*` | ||
], | ||
[ | ||
String.raw`\s* foo \s+ bar \\string\\ \s*`, | ||
String.raw`\s*foo\s+bar\s*\\string\\\s*` | ||
] | ||
|
||
] | ||
}; |