-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move linting to perennial #1489
Comments
Do you prefer chipper/eslint/**/*.{js,mjs} moved to perennial/eslint or perennial/js/eslint? |
I care most about how it holds the cache. Could we put everything in perennial/js/eslint and then save the cache to chipper/dist? |
I just got bit by this in #1492 and needed to instead run |
|
In-progress patch: Subject: [PATCH] chmod +x sage, see https://github.com/phetsims/chipper/issues/1481
---
Index: perennial/tsconfig.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial/tsconfig.json b/perennial/tsconfig.json
--- a/perennial/tsconfig.json (revision ae515be16fbe8971a4f984879102ca2bc9bfd434)
+++ b/perennial/tsconfig.json (date 1729200747548)
@@ -5,9 +5,6 @@
"extends": "../chipper/tsconfig/shared/tsconfig-node.json",
"include": [
"js/**/*",
- "test/**/*",
- // TODO: this is horrible, MK would prefer to just ts-expect-error when importing instead. Let's talk https://github.com/phetsims/chipper/issues/1489
- // TODO: Not only horrible, but it means that we lint chipper when we try to just lint perennial/ https://github.com/phetsims/chipper/issues/1489
- "../chipper/js/grunt/lint.js"
+ "test/**/*"
]
}
\ No newline at end of file
Index: chipper/js/grunt/Gruntfile.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/grunt/Gruntfile.js b/chipper/js/grunt/Gruntfile.js
--- a/chipper/js/grunt/Gruntfile.js (revision cf1ba1ca3afc0e01765cba2de5bda62b96a8dd28)
+++ b/chipper/js/grunt/Gruntfile.js (date 1729201417831)
@@ -44,13 +44,13 @@
*
* @param {string} task - The name of the task
*/
- function registerPerennialTask( task ) {
- grunt.registerTask( task, 'Run grunt --help in perennial to see documentation', () => {
- grunt.log.writeln( '(Forwarding task to perennial)' );
+ function forwardToRepo( forwardingRepo, task ) {
+ grunt.registerTask( task, `Run grunt --help in ${forwardingRepo} to see documentation`, () => {
+ grunt.log.writeln( `(Forwarding task to ${forwardingRepo})` );
const args = [ `--repo=${repo}`, ...process.argv.slice( 2 ) ];
const isWindows = /^win/.test( process.platform );
- gruntSpawn( grunt, isWindows ? 'grunt.cmd' : 'grunt', args, '../perennial', argsString => {
+ gruntSpawn( grunt, isWindows ? 'grunt.cmd' : 'grunt', args, `../${forwardingRepo}`, argsString => {
grunt.log.debug( `running grunt ${argsString} in ../${repo}` );
} );
} );
@@ -74,8 +74,14 @@
'production',
'prototype',
'create-sim',
- 'lint-everything',
+ 'lint-everything', // on mixed shas
'generate-data',
'release-branch-list'
- ].forEach( registerPerennialTask );
+ ].forEach( task => forwardToRepo( 'perennial', task ) );
+
+ [
+ 'lint',
+ 'lint-all'
+ // ].forEach( task => forwardToRepo( 'perennial-alias', task ) );
+ ].forEach( task => forwardToRepo( 'perennial', task ) );
};
\ No newline at end of file
Index: quake/js/grunt/tasks/default.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/quake/js/grunt/tasks/default.ts b/quake/js/grunt/tasks/default.ts
--- a/quake/js/grunt/tasks/default.ts (revision 5e65162ca567839cbd0429262e7d9324a5e8adf2)
+++ b/quake/js/grunt/tasks/default.ts (date 1729201839987)
@@ -14,7 +14,7 @@
*/
( async () => {
- await ( await import( '../../../../chipper/js/grunt/tasks/lint.ts' ) ).lintTask;
+ await ( await import( '../../../../perennial-alias/js/grunt/tasks/lint.ts' ) ).lintTask;
await import( './build.ts' );
Index: chipper/js/scripts/hook-pre-commit-task.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/chipper/js/scripts/hook-pre-commit-task.js b/chipper/js/scripts/hook-pre-commit-task.js
--- a/chipper/js/scripts/hook-pre-commit-task.js (revision cf1ba1ca3afc0e01765cba2de5bda62b96a8dd28)
+++ b/chipper/js/scripts/hook-pre-commit-task.js (date 1729200737478)
@@ -16,7 +16,7 @@
const generatePhetioMacroAPI = require( '../phet-io/generatePhetioMacroAPI' );
const CacheLayer = require( '../../../chipper/js/common/CacheLayer' );
const phetioCompareAPISets = require( '../phet-io/phetioCompareAPISets' );
-const lint = require( '../../../chipper/js/grunt/lint' );
+const lint = require( '../../../perennial-alias/js/grunt/lint' );
const reportMedia = require( '../../../chipper/js/grunt/reportMedia' );
const puppeteerQUnit = require( '../../../aqua/js/local/puppeteerQUnit' );
const Transpiler = require( '../../../chipper/js/common/Transpiler' );
Index: perennial/js/grunt/tasks/lint-everything.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial/js/grunt/tasks/lint-everything.ts b/perennial/js/grunt/tasks/lint-everything.ts
--- a/perennial/js/grunt/tasks/lint-everything.ts (revision ae515be16fbe8971a4f984879102ca2bc9bfd434)
+++ b/perennial/js/grunt/tasks/lint-everything.ts (date 1729200816807)
@@ -8,6 +8,7 @@
import grunt from 'grunt';
import getDataFile from '../../common/getDataFile';
import getOption from './util/getOption';
+import lint from '../lint.js';
( async () => {
@@ -18,15 +19,6 @@
const chipAway = getOption( 'chip-away' );
const showProgressBar = !getOption( 'hide-progress-bar' );
- let lint;
- try {
- lint = ( await import( '../../../../chipper/js/grunt/lint.js' ) ).default;
- }
- catch( e ) {
- console.log( 'lint process not found, is your chipper repo up to date?' );
- lint;
- }
-
// The APIs are the same for these two versions of lint support
if ( lint && ( lint.chipperAPIVersion === 'promisesPerRepo1' || lint.chipperAPIVersion === 'npx' ) ) {
const lintReturnValue = await lint( activeRepos, {
Index: perennial/js/grunt/tasks/lint.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/perennial/js/grunt/tasks/lint.ts b/perennial/js/grunt/tasks/lint.ts
--- a/perennial/js/grunt/tasks/lint.ts (revision ae515be16fbe8971a4f984879102ca2bc9bfd434)
+++ b/perennial/js/grunt/tasks/lint.ts (date 1729201389592)
@@ -1,29 +1,35 @@
-// Copyright 2024, University of Colorado Boulder
+// Copyright 2013-2024, University of Colorado Boulder
/**
- * Lints this repository only
- *
- * @author Michael Kauzmann (PhET Interactive Simulations)
+ * lint js files. Options:
+ * --disable-eslint-cache: cache will not be read from, and cache will be cleared for next run.
+ * --fix: autofixable changes will be written to disk
+ * --chip-away: output a list of responsible devs for each repo with lint problems
+ * --repos: comma separated list of repos to lint in addition to the repo from running
*
+ * @author Sam Reid (PhET Interactive Simulations)
*/
-import assert from 'assert';
-import grunt from 'grunt';
-import execute from '../../common/execute';
-import gruntCommand from '../../common/gruntCommand';
-import getOption from './util/getOption.ts';
+import * as grunt from 'grunt';
+import getOption from './util/getOption.js';
+import getRepo from './util/getRepo.js';
+import lint from '../lint.js';
-( async () => {
+const repo = getRepo();
- const index = process.argv.indexOf( 'lint' );
- assert( index >= 0, 'lint command does not appear' );
- const tail = process.argv.slice( index + 1 );
+export const lintTask = ( async () => {
+ const cache = !getOption( 'disable-eslint-cache' );
+ const fix = getOption( 'fix' );
+ const chipAway = getOption( 'chip-away' );
- // Prevent from also linting the chipper repo
- if ( !getOption( 'repo' ) ) {
- tail.push( '--repo=perennial' );
- }
+ const extraRepos = getOption( 'repos' ) ? getOption( 'repos' ).split( ',' ) : [];
+
+ const lintReturnValue = await lint( [ repo, ...extraRepos ], {
+ cache: cache,
+ fix: fix,
+ chipAway: chipAway
+ } );
- // Forward to chipper, supporting all of the options
- // @ts-expect-error, remove in https://github.com/phetsims/perennial/issues/369
- grunt.log.writeln( ( await execute( gruntCommand, [ 'lint', ...tail ], '../chipper', { errors: 'resolve' } ) ).stdout );
+ if ( !lintReturnValue.ok ) {
+ grunt.fail.fatal( 'Lint failed' );
+ }
} )();
\ No newline at end of file
|
I pushed the results of these "history moves":
We still need to deal with:
|
Signed-off-by: Michael Kauzmann <michael.kauzmann@colorado.edu>
|
|
Signed-off-by: Michael Kauzmann <michael.kauzmann@colorado.edu>
Signed-off-by: Michael Kauzmann <michael.kauzmann@colorado.edu>
Signed-off-by: Michael Kauzmann <michael.kauzmann@colorado.edu>
Signed-off-by: Michael Kauzmann <michael.kauzmann@colorado.edu>
Signed-off-by: Michael Kauzmann <michael.kauzmann@colorado.edu>
Signed-off-by: Michael Kauzmann <michael.kauzmann@colorado.edu>
Converting lint.js to typescript now. |
Signed-off-by: Michael Kauzmann <michael.kauzmann@colorado.edu>
@zepumph and I reviewed and everything looks good. One more TODO and other things in side issues. |
One last todo:
|
Signed-off-by: Michael Kauzmann <michael.kauzmann@colorado.edu>
Signed-off-by: Michael Kauzmann <michael.kauzmann@colorado.edu>
linting is a tool that is needed for perennial and for chipper. Let's have it be in the repo that is dependencyless.
chipper/eslint/
to perennial. (And keep history?!?!?!) Side issue: Movechipper/eslint/
to perennial #1500The text was updated successfully, but these errors were encountered: