aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-09-27 21:15:45 +0100
committerMichael Williamson <mike@zwobble.org>2016-09-27 21:15:45 +0100
commite300cd5236d238fcc3d638d4c481af017d2c623a (patch)
treead8697112146da3706df7f5c239f7abd0767149e
parent99b2d79d13703939f37e3ecb5becfdbf928e604a (diff)
Expect end token when parsing style mappings
-rw-r--r--NEWS5
-rw-r--r--lib/style-reader.js3
-rw-r--r--package.json3
-rw-r--r--test/style-reader.tests.js7
4 files changed, 16 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index eedb309..221b940 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+# 1.2.3
+
+* Expect end token when parsing style mappings. This causes warnings to be
+ emitted instead of silenting ignoring unparsed tokens.
+
# 1.2.2
* Ignore blank lines in style map.
diff --git a/lib/style-reader.js b/lib/style-reader.js
index fe60930..db3bdbc 100644
--- a/lib/style-reader.js
+++ b/lib/style-reader.js
@@ -23,7 +23,8 @@ function createStyleRule() {
lop.rules.sequence.capture(lop.rules.optional(lop.rules.sequence(
lop.rules.tokenOfType("whitespace"),
lop.rules.sequence.capture(htmlPathRule())
- ).head()))
+ ).head())),
+ lop.rules.tokenOfType("end")
).map(function(documentMatcher, htmlPath) {
return {
from: documentMatcher,
diff --git a/package.json b/package.json
index e1c0fac..c466d9f 100644
--- a/package.json
+++ b/package.json
@@ -34,7 +34,8 @@
"uglify-js": "~2.4.8",
"temp": "~0.7.0",
"eslint": "2.13.1",
- "hamjest": "2.13.0"
+ "hamjest": "2.13.0",
+ "flow-bin": "^0.32.0"
},
"browser": {
"./lib/unzip.js": "./browser/unzip.js",
diff --git a/test/style-reader.tests.js b/test/style-reader.tests.js
index 19f9c00..ec17e3a 100644
--- a/test/style-reader.tests.js
+++ b/test/style-reader.tests.js
@@ -162,6 +162,13 @@ test("styleReader.read", {
to: htmlPaths.empty
}
);
+ },
+
+ "error when not all input is consumed": function() {
+ assert.deepEqual(
+ readStyle("r => span a"),
+ new results.Result(null, [results.warning("Did not understand this style mapping, so ignored it: r => span a\nError was at character number 10: Expected end but got whitespace")])
+ );
}
});