Skip to content

Commit

Permalink
allow importing from tasks/util/, #1499
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kauzmann <michael.kauzmann@colorado.edu>
  • Loading branch information
zepumph committed Oct 21, 2024
1 parent ed4a296 commit f46cd9a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions 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 f46cd9a

Please sign in to comment.