Repository: jquery/jquery
File: build/release.js (JavaScript)

Code before:
"use strict";

var fs = require( "fs" );

module.exports = function( Release ) {

	const distFiles = [
		"dist/jquery.js",
		"dist/jquery.min.js",
		"dist/jquery.min.map",
		"dist/jquery.slim.js",
		"dist/jquery.slim.min.js",
		"dist/jquery.slim.min.map"
	];
	const filesToCommit = [
		...distFiles,
		"src/core.js"
	];
	const cdn = require( "./release/cdn" );
	const dist = require( "./release/dist" );

	const npmTags = Release.npmTags;

	function setSrcVersion( filepath ) {
		var contents = fs.readFileSync( filepath, "utf8" );
		contents = contents.replace( /@VERSION/g, Release.newVersion );
		fs.writeFileSync( filepath, contents, "utf8" );
	}

	// Stop the release process if any of the asynchronous operations fails.
	process.on( "unhandledRejection", reason => {
		console.error( "Unhandled rejection:", reason );
		throw reason;
	} );

	Release.define( {
		npmPublish: true,
		issueTracker: "github",

		/**
		 * Set the version in the src folder for distributing ES modules
		 * and in the amd folder for AMD.
		 */
		_setSrcVersion: function() {
			setSrcVersion( `${ __dirname }/../src/core.js` );
			setSrcVersion( `${ __dirname }/../amd/core.js` );
		},

Review comment (refactor):
@timmywil We had a talk a while ago about the `onevar` rule in ESLint. You said you don't want to remove/change the rule so that code using the preset doesn't need to adapt. However:

1. The rule is *not* actually enabled in the jQuery preset. AFAIK it was removed because Jörn didn't want it in jQuery UI or QUnit due to Git diff issues etc.
2. While we adhere to this way of declaring variables in jQuery code, I'd argue it's actually harmful when used for `const`/`let`. This is because for `var`s we were emulating how the JS engine interprets those declarations; in case of `const`/`let` the declarations are not hoisted and it's common to put them in the middle of the function where they are needed.
3. Other ES6 code in our repo already uses separate declarations per variable so we have some history here. That also means we don't have history of requiring this rule for `const`/`let` so not applying it shouldn't cause issues with code refactorings.

Code after:
"use strict";

var fs = require( "fs" );

module.exports = function( Release ) {

	const distFiles = [
		"dist/jquery.js",
		"dist/jquery.min.js",
		"dist/jquery.min.map",
		"dist/jquery.slim.js",
		"dist/jquery.slim.min.js",
		"dist/jquery.slim.min.map"
	];
	const filesToCommit = [
		...distFiles,
		"src/core.js"
	];
	const cdn = require( "./release/cdn" );
	const dist = require( "./release/dist" );

	const npmTags = Release.npmTags;

	function setSrcVersion( filepath ) {
		var contents = fs.readFileSync( filepath, "utf8" );
		contents = contents.replace( /@VERSION/g, Release.newVersion );
		fs.writeFileSync( filepath, contents, "utf8" );
	}

	Release.define( {
		npmPublish: true,
		issueTracker: "github",

		/**
		 * Set the version in the src folder for distributing ES modules
		 * and in the amd folder for AMD.
		 */
		_setSrcVersion: function() {
			setSrcVersion( `${ __dirname }/../src/core.js` );
			setSrcVersion( `${ __dirname }/../amd/core.js` );
		},

		/**
		 * Generates any release artifacts that should be included in the release.
		 * The callback must be invoked with an array of files that should be
		 * committed before creating the tag.
		 * @param {Function} callback