Skip to content

Commit

Permalink
recommit things that were not copied over from chipper, #364 phetsims…
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Oct 22, 2024
1 parent ba275ee commit 5b52996
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions js/eslint/rules/grunt-task-kebab-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -36,7 +36,7 @@ module.exports = {
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}`
} );
}
}
Expand Down
8 changes: 5 additions & 3 deletions js/eslint/rules/no-import-from-grunt-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

const hasFileSlash = /[\\/]/;
const isGruntTaskFileRegex = /[\\/]grunt[\\/]tasks[\\/]/;
const isGruntTaskUilsFileRegex = /[\\/]grunt[\\/]tasks[\\/]util[\\/]/;
const path = require( 'path' );

module.exports = {
create: context => {


const filename = context.filename;
const dir = path.dirname( filename );
if ( !isGruntTaskFileRegex.test( filename ) ) {
Expand All @@ -28,8 +28,10 @@ module.exports = {
const importValue = node.source.value;
const fullImportFilename = path.join( dir, importValue ); // Absolute path

// Don't check on something like 'fs' && check on the absolute path to support something like './tasks/x.js'
if ( hasFileSlash.test( importValue ) && isGruntTaskFileRegex.test( fullImportFilename ) ) {
// Don't check on something like 'fs' && check on the absolute path to support something like './tasks/x.js' &&
// allow using getOption/getRepo from outside the directory
if ( hasFileSlash.test( importValue ) && isGruntTaskFileRegex.test( fullImportFilename ) &&
!isGruntTaskUilsFileRegex.test( fullImportFilename ) ) {
context.report( {
node: node,
loc: node.loc,
Expand Down

0 comments on commit 5b52996

Please sign in to comment.