diff --git a/Makefile b/Makefile index a9942d2..c357c06 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,9 @@ NODE_MODULES_BIN_DIR = $(NODE_MODULES_DIR)/.bin MAIN_FILE = $(LIB_DIR)/peg.js -PARSER_SRC_FILE = $(SRC_DIR)/parser.pegjs -PARSER_OUT_FILE = $(LIB_DIR)/parser.js +PARSER_SRC_FILE = $(SRC_DIR)/parser.pegjs +PARSER_OUT_FILE = $(LIB_DIR)/parser.js +PARSER_OUT_FILE_NEW = $(LIB_DIR)/parser.js.new BROWSER_FILE_DEV = $(BROWSER_DIR)/peg-$(PEGJS_VERSION).js BROWSER_FILE_MIN = $(BROWSER_DIR)/peg-$(PEGJS_VERSION).min.js @@ -41,7 +42,20 @@ all: browser # Generate the grammar parser parser: - $(PEGJS) $(PARSER_SRC_FILE) $(PARSER_OUT_FILE) + # We need to prepend ESLint header to the generated parser file because we + # don't want the various unused variables there to get reported. This is a bit + # tricky because the file is used when generating its own new version, which + # means we can't start writing the header there until we call $(PEGJS). + + $(PEGJS) $(PARSER_SRC_FILE) $(PARSER_OUT_FILE_NEW) + + rm -f $(PARSER_OUT_FILE) + + echo '/* eslint no-unused-vars: 0 */' >> $(PARSER_OUT_FILE) + echo >> $(PARSER_OUT_FILE) + cat $(PARSER_OUT_FILE_NEW) >> $(PARSER_OUT_FILE) + + rm $(PARSER_OUT_FILE_NEW) # Build the browser version of the library browser: diff --git a/lib/parser.js b/lib/parser.js index 630783c..96237c2 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -1,3 +1,5 @@ +/* eslint no-unused-vars: 0 */ + module.exports = (function() { "use strict";