Enable the ESLint no-var rule in the external/builder/ folder
				
					
				
			As part of testing this, I've diffed the output of `gulp mozcentral` with/without this patch and the *only* difference is the incremented `version`/`build` numbers.
This commit is contained in:
		
							parent
							
								
									06494ccdac
								
							
						
					
					
						commit
						f0f307a4b5
					
				
							
								
								
									
										10
									
								
								external/builder/.eslintrc
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								external/builder/.eslintrc
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | ||||
| { | ||||
|   "extends": [ | ||||
|     "../.eslintrc" | ||||
|   ], | ||||
| 
 | ||||
|   "rules": { | ||||
|     // ECMAScript 6 | ||||
|     "no-var": "error", | ||||
|   }, | ||||
| } | ||||
							
								
								
									
										16
									
								
								external/builder/builder.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								external/builder/builder.js
									
									
									
									
										vendored
									
									
								
							| @ -33,6 +33,11 @@ const fs = require("fs"), | ||||
|  * //#endif
 | ||||
|  */ | ||||
| function preprocess(inFilename, outFilename, defines) { | ||||
|   let lineNumber = 0; | ||||
|   function loc() { | ||||
|     return fs.realpathSync(inFilename) + ":" + lineNumber; | ||||
|   } | ||||
| 
 | ||||
|   // TODO make this really read line by line.
 | ||||
|   const lines = fs.readFileSync(inFilename).toString().split("\n"); | ||||
|   const totalLines = lines.length; | ||||
| @ -118,10 +123,7 @@ function preprocess(inFilename, outFilename, defines) { | ||||
|   let state = STATE_NONE; | ||||
|   const stack = []; | ||||
|   const control = /^(?:\/\/|<!--)\s*#(if|elif|else|endif|expand|include|error)\b(?:\s+(.*?)(?:-->)?$)?/; | ||||
|   let lineNumber = 0; | ||||
|   var loc = function () { | ||||
|     return fs.realpathSync(inFilename) + ":" + lineNumber; | ||||
|   }; | ||||
| 
 | ||||
|   while ((line = readLine()) !== null) { | ||||
|     ++lineNumber; | ||||
|     const m = control.exec(line); | ||||
| @ -277,11 +279,11 @@ exports.preprocessCSS = preprocessCSS; | ||||
|  * the first. | ||||
|  */ | ||||
| function merge(defaults, defines) { | ||||
|   const ret = {}; | ||||
|   for (var key in defaults) { | ||||
|   const ret = Object.create(null); | ||||
|   for (const key in defaults) { | ||||
|     ret[key] = defaults[key]; | ||||
|   } | ||||
|   for (key in defines) { | ||||
|   for (const key in defines) { | ||||
|     ret[key] = defines[key]; | ||||
|   } | ||||
|   return ret; | ||||
|  | ||||
							
								
								
									
										18
									
								
								external/builder/preprocessor2.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								external/builder/preprocessor2.js
									
									
									
									
										vendored
									
									
								
							| @ -34,14 +34,14 @@ function handlePreprocessorAction(ctx, actionName, args, loc) { | ||||
|         if (!arg || arg.type !== "Literal" || typeof arg.value !== "string") { | ||||
|           throw new Error("No code for testing is given"); | ||||
|         } | ||||
|         var isTrue = !!evalWithDefines(arg.value, ctx.defines); | ||||
|         const isTrue = !!evalWithDefines(arg.value, ctx.defines); | ||||
|         return { type: "Literal", value: isTrue, loc }; | ||||
|       case "eval": | ||||
|         arg = args[0]; | ||||
|         if (!arg || arg.type !== "Literal" || typeof arg.value !== "string") { | ||||
|           throw new Error("No code for eval is given"); | ||||
|         } | ||||
|         var result = evalWithDefines(arg.value, ctx.defines); | ||||
|         const result = evalWithDefines(arg.value, ctx.defines); | ||||
|         if ( | ||||
|           typeof result === "boolean" || | ||||
|           typeof result === "string" || | ||||
| @ -62,14 +62,14 @@ function handlePreprocessorAction(ctx, actionName, args, loc) { | ||||
|         if (!arg || arg.type !== "Literal" || typeof arg.value !== "string") { | ||||
|           throw new Error("Path to JSON is not provided"); | ||||
|         } | ||||
|         var jsonPath = arg.value; | ||||
|         let jsonPath = arg.value; | ||||
|         if (jsonPath.indexOf(ROOT_PREFIX) === 0) { | ||||
|           jsonPath = path.join( | ||||
|             ctx.rootPath, | ||||
|             jsonPath.substring(ROOT_PREFIX.length) | ||||
|           ); | ||||
|         } | ||||
|         var jsonContent = fs.readFileSync(jsonPath).toString(); | ||||
|         const jsonContent = fs.readFileSync(jsonPath).toString(); | ||||
|         const parsedJSON = acorn.parse("(" + jsonContent + ")", { | ||||
|           ecmaVersion: ACORN_ECMA_VERSION, | ||||
|         }); | ||||
| @ -175,7 +175,7 @@ function postprocessNode(ctx, node) { | ||||
|               case "string": | ||||
|               case "boolean": | ||||
|               case "number": | ||||
|                 var equal = node.left.value === node.right.value; | ||||
|                 const equal = node.left.value === node.right.value; | ||||
|                 return { | ||||
|                   type: "Literal", | ||||
|                   value: (node.operator[0] === "=") === equal, | ||||
| @ -210,7 +210,7 @@ function postprocessNode(ctx, node) { | ||||
|       } | ||||
|       break; | ||||
|     case "BlockStatement": | ||||
|       var subExpressionIndex = 0; | ||||
|       let subExpressionIndex = 0; | ||||
|       while (subExpressionIndex < node.body.length) { | ||||
|         switch (node.body[subExpressionIndex].type) { | ||||
|           case "EmptyStatement": | ||||
| @ -219,7 +219,7 @@ function postprocessNode(ctx, node) { | ||||
|             continue; | ||||
|           case "BlockStatement": | ||||
|             // Block statements inside a block are moved to the parent one.
 | ||||
|             var subChildren = node.body[subExpressionIndex].body; | ||||
|             const subChildren = node.body[subExpressionIndex].body; | ||||
|             Array.prototype.splice.apply( | ||||
|               node.body, | ||||
|               [subExpressionIndex, 1].concat(subChildren) | ||||
| @ -240,7 +240,7 @@ function postprocessNode(ctx, node) { | ||||
|       break; | ||||
|     case "FunctionDeclaration": | ||||
|     case "FunctionExpression": | ||||
|       var block = node.body; | ||||
|       const block = node.body; | ||||
|       if ( | ||||
|         block.body.length > 0 && | ||||
|         block.body[block.body.length - 1].type === "ReturnStatement" && | ||||
| @ -292,7 +292,7 @@ function fixComments(ctx, node) { | ||||
| function traverseTree(ctx, node) { | ||||
|   // generic node processing
 | ||||
|   for (const i in node) { | ||||
|     var child = node[i]; | ||||
|     const child = node[i]; | ||||
|     if (typeof child === "object" && child !== null && child.type) { | ||||
|       const result = traverseTree(ctx, child); | ||||
|       if (result !== child) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user