Skip to content

Allow extensionless js files to be read using the cli #1131

@tomgco

Description

@tomgco

Currently the CLI engine looks explicitly for filenames that end in a .js see:

if (path.extname(filename) === ".js") {

It would be a nice feature for files which use shebangs to infer the interpreter from #!/usr/bin/env node or similar when no extension is found.

else if (path.extname(filename) === "") {
   // one of the three methods below
}

I have thought about a couple of ways to make this work:

  • Read the first n bytes to see if contains #! and node
  • Use libmagic or file(1) to determine file type
  • Allow the user to explicitly state the files which are to be linted as config.

By allowing this we can allow users who write JS on the server side using d8 or spidermonkey to explicitly define the interpreter that will be used at execution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussioncoreRelates to ESLint's core APIs and featuresenhancementThis change enhances an existing feature of ESLint

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions