From ddd4ac378735bbcaf4224ca83b60fc7ba06f9584 Mon Sep 17 00:00:00 2001 From: David Majda Date: Sun, 24 Jan 2016 21:22:21 +0100 Subject: [PATCH] Fix ESLint errors in lib/parser.js Fix the following errors: 31:9 error "parser" is defined but never used no-unused-vars 406:14 error "expected" is defined but never used no-unused-vars 1304:15 error "s1" is defined but never used no-unused-vars 1386:15 error "s1" is defined but never used no-unused-vars 1442:15 error "s1" is defined but never used no-unused-vars --- Makefile | 20 +++++++++++++++++--- lib/parser.js | 2 ++ 2 files changed, 19 insertions(+), 3 deletions(-) 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";