phetsims / chipper

Tools for developing and building PhET interactive simulations.
http://scenerystack.org/
MIT License
12 stars 14 forks source link

lint rules for new `grunt/tasks/` pattern #1492

Closed zepumph closed 1 month ago

zepumph commented 1 month ago

From https://github.com/phetsims/chipper/issues/1464#issuecomment-2383819582

I'll take a look.

zepumph commented 1 month ago

Turns out that perennial/common/buildLocal.js already existed, so I could just add on brands with a good default. The lint rules are complete. @samreid can you give me a spot check?

samreid commented 1 month ago

When I rename a grunt task like commits-since.ts to commitsSince.ts, the rule allows it since the regex still passes. How should we proceed? Keep in mind kite has generate-svgPath-parser.ts

zepumph commented 1 month ago

@samreid and I will rename (un)published-readme and the kite task svgPath to lower case and then commit this patch:

Subject: [PATCH] fdas
---
Index: eslint/rules/grunt-task-kebab-case.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/eslint/rules/grunt-task-kebab-case.js b/eslint/rules/grunt-task-kebab-case.js
--- a/eslint/rules/grunt-task-kebab-case.js (revision 7c07e0fce43f066ccf8e40b8c36d947037991c7f)
+++ b/eslint/rules/grunt-task-kebab-case.js (date 1729200177441)
@@ -14,7 +14,7 @@
 //------------------------------------------------------------------------------

 const isGruntTaskFileRegex = /[\\/]grunt[\\/]tasks[\\/]?/;
-const validKebabCase = /^[a-z][a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/;
+const validKebabCase = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
 const path = require( 'path' );

 module.exports = {
@@ -36,7 +36,7 @@
           context.report( {
             node: node,
             loc: node.loc,
-            message: `files in "grunt/tasks/" must use kebab-case by convention (no snake or camel): ${parsed.filename}`
+            message: `files in "grunt/tasks/" must use kebab-case by convention (no snake or camel): ${parsed.base}`
           } );
         }
       }
zepumph commented 1 month ago

The rule and renames have been pushed. Commits from today are on development branches, but everything is behaving well there. I'll keep open until branches are merged to main.

zepumph commented 1 month ago

Last todo handled. Pushed to main. Ready to close.