Skip to content

Commit

Permalink
Add *.js suffix in relative require statements, remove unnecessary es…
Browse files Browse the repository at this point in the history
…lint-disable directives, rename require variables, see #1498
  • Loading branch information
samreid committed Oct 28, 2024
1 parent 88ae8a4 commit 10053d6
Show file tree
Hide file tree
Showing 51 changed files with 116 additions and 118 deletions.
2 changes: 1 addition & 1 deletion js/common/ChipperStringUtilTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @author Michael Kauzmann (PhET Interactive Simulations)
*/

const ChipperStringUtils = require( './ChipperStringUtils' );
const ChipperStringUtils = require( './ChipperStringUtils.js' );
const qunit = require( 'qunit' );
qunit.module( 'ChipperStringUtils' );

Expand Down
10 changes: 5 additions & 5 deletions js/common/Transpiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
const fs = require( 'fs' );
const path = require( 'path' );
const crypto = require( 'crypto' );
const CacheLayer = require( './CacheLayer' );
const wgslMinify = require( './wgslMinify' );
const wgslPreprocess = require( './wgslPreprocess' );
const wgslStripComments = require( './wgslStripComments' );
const webpackGlobalLibraries = require( './webpackGlobalLibraries' );
const CacheLayer = require( './CacheLayer.js' );
const wgslMinify = require( './wgslMinify.js' );
const wgslPreprocess = require( './wgslPreprocess.js' );
const wgslStripComments = require( './wgslStripComments.js' );
const webpackGlobalLibraries = require( './webpackGlobalLibraries.js' );
const core = require( '@babel/core' );
const assert = require( 'assert' );
const _ = require( 'lodash' );
Expand Down
2 changes: 1 addition & 1 deletion js/common/stringEncoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/

const _ = require( 'lodash' );
const toLessEscapedString = require( './toLessEscapedString' );
const toLessEscapedString = require( './toLessEscapedString.js' );

const PUSH_TOKEN = '\u0001'; // push string on the stack
const PUSH_TOKEN_SLASH = '\u0002'; // push `${string}/` on the stack
Expand Down
2 changes: 1 addition & 1 deletion js/common/wgslGetSymbolInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

const _ = require( 'lodash' );
const wgslStripComments = require( './wgslStripComments' );
const wgslStripComments = require( './wgslStripComments.js' );

const KEYWORDS = [
'alias',
Expand Down
2 changes: 1 addition & 1 deletion js/grunt/GruntfileTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const qunit = require( 'qunit' );
const { execSync } = require( 'child_process' );
qunit.module( 'GruntfileTests' );

const gruntCommand = require( '../../../perennial-alias/js/common/gruntCommand' );
const gruntCommand = require( '../../../perennial-alias/js/common/gruntCommand.js' );

qunit.test( 'first test', assert => {

Expand Down
30 changes: 15 additions & 15 deletions js/grunt/buildRunnable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@ import webpackBuild from './webpackBuild';
import getPreloads from './getPreloads.js';

const assert = require( 'assert' );
const ChipperStringUtils = require( '../common/ChipperStringUtils' );
const getLicenseEntry = require( '../common/getLicenseEntry' );
const copyDirectory = require( './copyDirectory' );
const copySupplementalPhetioFiles = require( './copySupplementalPhetioFiles' );
const getA11yViewHTMLFromTemplate = require( './getA11yViewHTMLFromTemplate' );
const getAllThirdPartyEntries = require( './getAllThirdPartyEntries' );
const getPhetLibs = require( './getPhetLibs' );
const getPrunedLocaleData = require( './getPrunedLocaleData' );
const getStringMap = require( './getStringMap' );
const getTitleStringKey = require( './getTitleStringKey' );
const ChipperStringUtils = require( '../common/ChipperStringUtils.js' );
const getLicenseEntry = require( '../common/getLicenseEntry.js' );
const copyDirectory = require( './copyDirectory.js' );
const copySupplementalPhetioFiles = require( './copySupplementalPhetioFiles.js' );
const getA11yViewHTMLFromTemplate = require( './getA11yViewHTMLFromTemplate.js' );
const getAllThirdPartyEntries = require( './getAllThirdPartyEntries.js' );
const getPhetLibs = require( './getPhetLibs.js' );
const getPrunedLocaleData = require( './getPrunedLocaleData.js' );
const getStringMap = require( './getStringMap.js' );
const getTitleStringKey = require( './getTitleStringKey.js' );
const grunt = require( 'grunt' );
const jimp = require( 'jimp' );
const loadFileAsDataURI = require( '../common/loadFileAsDataURI' );
const minify = require( './minify' );
const loadFileAsDataURI = require( '../common/loadFileAsDataURI.js' );
const minify = require( './minify.js' );
const nodeHTMLEncoder = require( 'node-html-encoder' ); // eslint-disable-line phet/require-statement-match
const packageRunnable = require( './packageRunnable' );
const packageRunnable = require( './packageRunnable.js' );

const reportUnusedMedia = require( './reportUnusedMedia' );
const reportUnusedMedia = require( './reportUnusedMedia.js' );

const zlib = require( 'zlib' );
const phetTimingLog = require( '../../../perennial-alias/js/common/phetTimingLog' );
const phetTimingLog = require( '../../../perennial-alias/js/common/phetTimingLog.js' );

const recordTime = async <T>( name: string, asyncCallback: () => Promise<T>, timeCallback: ( time: number, result: T ) => void ): Promise<T> => {
const beforeTime = Date.now();
Expand Down
8 changes: 4 additions & 4 deletions js/grunt/buildStandalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import getLocalesFromRepository from './getLocalesFromRepository';
const assert = require( 'assert' );
const fs = require( 'fs' );
const grunt = require( 'grunt' );
const minify = require( './minify' );
const minify = require( './minify.js' );
const _ = require( 'lodash' );
const getStringMap = require( './getStringMap' );
const ChipperConstants = require( '../common/ChipperConstants' );
const getStringMap = require( './getStringMap.js' );
const ChipperConstants = require( '../common/ChipperConstants.js' );

const getPhetLibs = require( './getPhetLibs' );
const getPhetLibs = require( './getPhetLibs.js' );

/**
* Builds standalone JS deliverables (e.g. dot/kite/scenery)
Expand Down
4 changes: 2 additions & 2 deletions js/grunt/commitsSince.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import * as grunt from 'grunt';
* @author Chris Malley (PixelZoom, Inc.)
*/

const execute = require( '../../../perennial-alias/js/common/execute' );
const getPhetLibs = require( './getPhetLibs' );
const execute = require( '../../../perennial-alias/js/common/execute.js' );
const getPhetLibs = require( './getPhetLibs.js' );

module.exports = async function( repo: string, dateString: string ): Promise<void> {

Expand Down
2 changes: 1 addition & 1 deletion js/grunt/copyDirectory.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
const _ = require( 'lodash' );
const assert = require( 'assert' );
const grunt = require( 'grunt' );
const minify = require( './minify' );
const minify = require( './minify.js' );

/**
* @param {string} src - the source directory
Expand Down
12 changes: 6 additions & 6 deletions js/grunt/copySupplementalPhetioFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ import check from '../../../perennial-alias/js/grunt/check.ts';

const assert = require( 'assert' );
const archiver = require( 'archiver' );
const ChipperStringUtils = require( '../common/ChipperStringUtils' );
const copyDirectory = require( '../grunt/copyDirectory' );
const execute = require( '../../../perennial-alias/js/common/execute' );
const ChipperStringUtils = require( '../common/ChipperStringUtils.js' );
const copyDirectory = require( '../grunt/copyDirectory.js' );
const execute = require( '../../../perennial-alias/js/common/execute.js' );
const grunt = require( 'grunt' );
const generatePhetioMacroAPI = require( '../phet-io/generatePhetioMacroAPI' );
const generatePhetioMacroAPI = require( '../phet-io/generatePhetioMacroAPI.js' );

const minify = require( '../grunt/minify' );
const minify = require( '../grunt/minify.js' );
const marked = require( 'marked' );

const getPhetLibs = require( './getPhetLibs' );
const getPhetLibs = require( './getPhetLibs.js' );
const path = require( 'path' );
const webpack = require( 'webpack' );

Expand Down
2 changes: 1 addition & 1 deletion js/grunt/createMipmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as fs from 'fs';
import * as grunt from 'grunt';

const jpeg = require( 'jpeg-js' ); // eslint-disable-line phet/require-statement-match
const mipmapDownscale = require( '../../../chipper/js/common/mipmapDownscale' );
const mipmapDownscale = require( '../../../chipper/js/common/mipmapDownscale.js' );
const pngjs = require( 'pngjs' );

type TMipmap = {
Expand Down
4 changes: 2 additions & 2 deletions js/grunt/generateA11yViewHTML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/

// modules
const getA11yViewHTMLFromTemplate = require( './getA11yViewHTMLFromTemplate' );
const writeFileAndGitAdd = require( '../../../perennial-alias/js/common/writeFileAndGitAdd' );
const getA11yViewHTMLFromTemplate = require( './getA11yViewHTMLFromTemplate.js' );
const writeFileAndGitAdd = require( '../../../perennial-alias/js/common/writeFileAndGitAdd.js' );

import ChipperConstants from '../common/ChipperConstants.js';
import ChipperStringUtils from '../common/ChipperStringUtils.js';
Expand Down
6 changes: 3 additions & 3 deletions js/grunt/generateDevelopmentHTML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.js';
import fixEOL from '../../../perennial-alias/js/common/fixEOL.js';
import getPreloads from './getPreloads';

const ChipperStringUtils = require( '../common/ChipperStringUtils' );
const getStringRepos = require( './getStringRepos' );
const writeFileAndGitAdd = require( '../../../perennial-alias/js/common/writeFileAndGitAdd' );
const ChipperStringUtils = require( '../common/ChipperStringUtils.js' );
const getStringRepos = require( './getStringRepos.js' );
const writeFileAndGitAdd = require( '../../../perennial-alias/js/common/writeFileAndGitAdd.js' );
const grunt = require( 'grunt' );

// TODO: Get rid of all IntentionalAny, see https://github.com/phetsims/chipper/issues/1437
Expand Down
8 changes: 4 additions & 4 deletions js/grunt/generateREADME.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
*/


const ChipperStringUtils = require( '../common/ChipperStringUtils' );
const ChipperStringUtils = require( '../common/ChipperStringUtils.js' );
import fixEOL from '../../../perennial-alias/js/common/fixEOL.js';
const getPhetLibs = require( './getPhetLibs' );
const getTitleStringKey = require( './getTitleStringKey' );
const writeFileAndGitAdd = require( '../../../perennial-alias/js/common/writeFileAndGitAdd' );
const getPhetLibs = require( './getPhetLibs.js' );
const getTitleStringKey = require( './getTitleStringKey.js' );
const writeFileAndGitAdd = require( '../../../perennial-alias/js/common/writeFileAndGitAdd.js' );
import * as grunt from 'grunt';

/**
Expand Down
2 changes: 1 addition & 1 deletion js/grunt/generateTestHTML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import * as _ from 'lodash';
const generateDevelopmentHTML = require( './generateDevelopmentHTML' );
const generateDevelopmentHTML = require( './generateDevelopmentHTML.js' );
import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.js';

module.exports = async ( repo: string, options: IntentionalAny ): Promise<void> => {
Expand Down
6 changes: 3 additions & 3 deletions js/grunt/getA11yViewHTMLFromTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* @author Michael Kauzmann (PhET Interactive Simulations)
*/

const ChipperConstants = require( '../common/ChipperConstants' );
const ChipperStringUtils = require( '../common/ChipperStringUtils' );
const ChipperConstants = require( '../common/ChipperConstants.js' );
const ChipperStringUtils = require( '../common/ChipperStringUtils.js' );
import fixEOL from '../../../perennial-alias/js/common/fixEOL.js';
const getTitleStringKey = require( './getTitleStringKey' );
const getTitleStringKey = require( './getTitleStringKey.js' );
import * as grunt from 'grunt';

/**
Expand Down
2 changes: 1 addition & 1 deletion js/grunt/getCopyrightLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @author Jonathan Olson <jonathan.olson@colorado.edu>
*/

const execute = require( '../../../perennial-alias/js/common/execute' );
const execute = require( '../../../perennial-alias/js/common/execute.js' );

/**
* @param repo - The repository of the file to update (should be a git root)
Expand Down
6 changes: 3 additions & 3 deletions js/grunt/getDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*/

const assert = require( 'assert' );
const ChipperStringUtils = require( '../common/ChipperStringUtils' );
const execute = require( '../../../perennial-alias/js/common/execute' );
const getPhetLibs = require( './getPhetLibs' );
const ChipperStringUtils = require( '../common/ChipperStringUtils.js' );
const execute = require( '../../../perennial-alias/js/common/execute.js' );
const getPhetLibs = require( './getPhetLibs.js' );
const grunt = require( 'grunt' );

// Our definition of an allowed simName is defined in the buildServer: https://github.com/phetsims/perennial/blob/78025b7ae6064e9ab5260cea5e532f3bf24c3ec8/js/build-server/taskWorker.js#L99-L98
Expand Down
6 changes: 3 additions & 3 deletions js/grunt/getInitializationScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

// modules
const assert = require( 'assert' );
const ChipperConstants = require( '../common/ChipperConstants' );
const ChipperStringUtils = require( '../common/ChipperStringUtils' );
const ChipperConstants = require( '../common/ChipperConstants.js' );
const ChipperStringUtils = require( '../common/ChipperStringUtils.js' );
const fs = require( 'fs' );
const grunt = require( 'grunt' );
const transpileForBuild = require( './transpileForBuild.js' );
const stringEncoding = require( '../common/stringEncoding' );
const stringEncoding = require( '../common/stringEncoding.js' );

import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.ts';

Expand Down
2 changes: 1 addition & 1 deletion js/grunt/getLicenseKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import getPreloads from './getPreloads.js';

const _ = require( 'lodash' );
const webpackGlobalLibraries = require( '../common/webpackGlobalLibraries' );
const webpackGlobalLibraries = require( '../common/webpackGlobalLibraries.js' );
const grunt = require( 'grunt' );

/**
Expand Down
2 changes: 1 addition & 1 deletion js/grunt/getPhetLibs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

const _ = require( 'lodash' );
const assert = require( 'assert' );
const ChipperConstants = require( '../common/ChipperConstants' );
const ChipperConstants = require( '../common/ChipperConstants.js' );
const grunt = require( 'grunt' );

/**
Expand Down
2 changes: 1 addition & 1 deletion js/grunt/getPrunedLocaleData.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

const _ = require( 'lodash' );
const ChipperConstants = require( '../common/ChipperConstants' );
const ChipperConstants = require( '../common/ChipperConstants.js' );
const fs = require( 'fs' );

/**
Expand Down
6 changes: 3 additions & 3 deletions js/grunt/getStringMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

const _ = require( 'lodash' );
const assert = require( 'assert' );
const ChipperConstants = require( '../common/ChipperConstants' );
const pascalCase = require( '../common/pascalCase' );
const ChipperStringUtils = require( '../common/ChipperStringUtils' );
const ChipperConstants = require( '../common/ChipperConstants.js' );
const pascalCase = require( '../common/pascalCase.js' );
const ChipperStringUtils = require( '../common/ChipperStringUtils.js' );
const fs = require( 'fs' );
const grunt = require( 'grunt' );
const path = require( 'path' );
Expand Down
4 changes: 2 additions & 2 deletions js/grunt/gruntMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

const assert = require( 'assert' );
require( './checkNodeVersion' );
const registerTasks = require( '../../../perennial-alias/js/grunt/util/registerTasks' );
const gruntSpawn = require( '../../../perennial-alias/js/grunt/util/gruntSpawn' );
const registerTasks = require( '../../../perennial-alias/js/grunt/util/registerTasks.js' );
const gruntSpawn = require( '../../../perennial-alias/js/grunt/util/gruntSpawn.js' );
const _ = require( 'lodash' );

// Allow other Gruntfiles to potentially handle exiting and errors differently
Expand Down
11 changes: 5 additions & 6 deletions js/grunt/modulify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ import IntentionalAny from '../../../phet-core/js/types/IntentionalAny.ts';
import getCopyrightLine from './getCopyrightLine';

const _ = require( 'lodash' );
const createMipmap = require( './createMipmap' );
const createMipmap = require( './createMipmap.js' );
const fs = require( 'fs' );
const path = require( 'path' );
const grunt = require( 'grunt' );
const loadFileAsDataURI = require( '../common/loadFileAsDataURI' );
const pascalCase = require( '../common/pascalCase' );
const loadFileAsDataURI = require( '../common/loadFileAsDataURI.js' );
const pascalCase = require( '../common/pascalCase.js' );
const os = require( 'os' );

const toLessEscapedString = require( '../common/toLessEscapedString' );
const toLessEscapedString = require( '../common/toLessEscapedString.js' );
const assert = require( 'assert' );
const writeFileAndGitAdd = require( '../../../perennial-alias/js/common/writeFileAndGitAdd' );
const writeFileAndGitAdd = require( '../../../perennial-alias/js/common/writeFileAndGitAdd.js' );
const svgo = require( 'svgo' );

// disable lint in compiled files, because it increases the linting time
Expand Down
4 changes: 2 additions & 2 deletions js/grunt/packageRunnable.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

// modules
const assert = require( 'assert' );
const ChipperStringUtils = require( '../common/ChipperStringUtils' );
const getTitleStringKey = require( './getTitleStringKey' );
const ChipperStringUtils = require( '../common/ChipperStringUtils.js' );
const getTitleStringKey = require( './getTitleStringKey.js' );
const grunt = require( 'grunt' );
const pako = require( 'pako' );
const fs = require( 'fs' );
Expand Down
6 changes: 3 additions & 3 deletions js/grunt/packageXHTML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

// modules
const assert = require( 'assert' );
const ChipperConstants = require( '../common/ChipperConstants' );
const ChipperStringUtils = require( '../common/ChipperStringUtils' );
const getTitleStringKey = require( './getTitleStringKey' );
const ChipperConstants = require( '../common/ChipperConstants.js' );
const ChipperStringUtils = require( '../common/ChipperStringUtils.js' );
const getTitleStringKey = require( './getTitleStringKey.js' );
const grunt = require( 'grunt' );
const nodeHTMLEncoder = require( 'node-html-encoder' ); // eslint-disable-line phet/require-statement-match

Expand Down
6 changes: 3 additions & 3 deletions js/grunt/reportMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
*/


const ChipperConstants = require( '../common/ChipperConstants' );
const getLicenseEntry = require( '../common/getLicenseEntry' );
const getPhetLibs = require( '../grunt/getPhetLibs' );
const ChipperConstants = require( '../common/ChipperConstants.js' );
const getLicenseEntry = require( '../common/getLicenseEntry.js' );
const getPhetLibs = require( '../grunt/getPhetLibs.js' );
const grunt = require( 'grunt' );
const path = require( 'path' );

Expand Down
2 changes: 1 addition & 1 deletion js/grunt/reportThirdParty.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

const _ = require( 'lodash' );
const assert = require( 'assert' );
const ChipperConstants = require( '../common/ChipperConstants' );
const ChipperConstants = require( '../common/ChipperConstants.js' );
const fs = require( 'fs' );
const grunt = require( 'grunt' );
const https = require( 'https' );
Expand Down
2 changes: 1 addition & 1 deletion js/grunt/reportUnusedMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

// modules
const ChipperConstants = require( '../../../chipper/js/common/ChipperConstants' );
const ChipperConstants = require( '../../../chipper/js/common/ChipperConstants.js' );
const grunt = require( 'grunt' );

/**
Expand Down
Loading

0 comments on commit 10053d6

Please sign in to comment.