How come eslint is unable to detect all files within a directory, yet it can detect a single file?

Here is the organization of my files and directories.

https://i.stack.imgur.com/YWNw3.png

I am looking to set up some eslint rules for my code detection.

In my .eslintrc file, I have included these configuration settings.

{
  "extends": "airbnb",
  "rules": {
    "valid-jsdoc": 2,
    // Disable until Flow supports let and const
    "no-var": 0,
    "react/jsx-uses-react": 1,
    "react/jsx-no-undef": 2,
    "react/wrap-multilines": 2,
    "func-names": 0,
    "new-cap": 0,
    "no-undef": 0,
  },
  "plugins": [
    "react"
  ]
}

I am using npm scripts to execute eslint.

  "scripts": {
    "lint": "eslint src"
  },

Typically, running npm run lint would analyze all the files in the src directory.

However, no output is generated.

https://i.stack.imgur.com/ZIiKw.png

I am unsure why. My initial thought was that maybe there are mistakes in the configuration settings. But when I specified a single file in the npm script

"lint": "eslint src/component/App.jsx"
, eslint worked as expected.

So, what seems to be the issue? Eslint can detect individual files properly, but encounters difficulties with analyzing all files within a specific directory.

https://i.stack.imgur.com/jGUp7.png

Answer №1

When executing eslint src, it will by default search for all files with the extension .js. In your case, you may want to adjust the command to eslint src --ext .js,.jsx. This modification will consider all files within the directory src with either a .js or .jsx extension (personal recommendation).

If using glob patterns is preferable for resolving this issue, you could update your command to eslint src/**/*.jsx

For more information, refer to the CLI documentation: http://eslint.org/docs/user-guide/command-line-interface

Additional assistance with glob patterns can be found here: http://eslint.org/docs/user-guide/configuring#ignoring-files-and-directories

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the most effective method to determine if a given string is suitable for $compile in Angular?

I am currently in the process of creating a directive that is designed to accept a "message" input which may contain HTML and nested Angular directives. In my directive's controller, I am using the following code: var compiled = $compile(message)($sc ...

What is the process for applying a class in jQuery to empty HTML elements?

Working on a WordPress/PHP website and looking to dynamically add a class when child elements are empty? This is the HTML structure: <div class="featured-block"> <a href="/" class="featured-block__item cf"> <div class="featured-bl ...

New Relic identifies mysterious delays caused by MongoDB's findOne method

After setting up newrelic to pinpoint the bottlenecks in my app, I discovered a major issue that has left me stumped. The source of most delays seems to be mongoDB user.findOne, but the biggest challenge is locating where in the code this delay is occurri ...

Adjustable value range slider in HTML5 with ng-repeat directive in AngularJs

I am facing a problem with my HTML5 range slider. After setting a value (status) and sending it to the database, when I reload the page the slider's value is always set to '50'. The slider is being generated within an ng-repeat from AngularJ ...

Live feed of Npm child processes

I'm currently developing a command-line tool for a node.js application that requires running npm commands and displaying the results. Here's what I've come up with so far: import {spawn} from 'child_process'; let projectRoot = &a ...

Is it possible to bring in a `devDependency` into your code?

The Mobx DevTool's README instructs users to install it as a dev dependency, and then import it into their code. This approach raises concerns for me because devDependencies are typically reserved for tools used in the build process or managing end co ...

proper integration of socket.io

I have been experimenting with socket io for my project to display online friends, and I have noticed an issue that seems strange to me. Every time the page is rerendered (whether due to a user changing their profile information or sending a friend request ...

The custom pagination feature in Addsearch UI always default to displaying the first page of search

I am currently using addsearch-ui version 0.7.11 for my project. I have been attempting to integrate a customized pagination function based on this example template. However, I have encountered an issue where the arrow buttons always navigate to the first ...

I possess an array of objects that includes both images and documents. My goal is to examine the mime_type of each object and select the first element in React to be displayed within an <img> tag

I have an array of objects that contain images and documents. My goal is to display the first image only if the mime_type is 'image/jpeg' or 'image/png'. I am working with React. Despite my attempts, I keep encountering undefined resul ...

Having trouble setting up Volta on Windows Subsystem for Linux - Could not locate ELF file

Trying to install volta using the recommended command curl https://get.volta.sh | bash on WSL but encountering errors. This error keeps popping up and I'm struggling to understand its cause. ...

After reloading the page, Nuxt dynamic routes are displaying a 404 error

Hey there! I'm currently diving into a project that involves using nuxt js, and it's all new to me. I've set it up in spa mode without any modifications in the nuxt config file, just sticking with the default settings. Here's how I&apos ...

Automatically tally up the pages and showcase the page numbers for seamless printing

I've been tackling a challenge in my Vue.js application, specifically with generating invoices and accurately numbering the pages. An issue arose when printing the invoice – each page was labeled "Page 1 of 20" irrespective of its actual position in ...

Creating an Observable Collection in Angular using AngularFire2 Firestore

I am currently using material 2 and attempting to develop data tables with pagination and sorting. In order to achieve this, I require my collections to be observable. However, I believe that I might be incorrectly populating or initializing the arrays in ...

Encountering a problem while attempting to utilize a package that requires the importing of a JSON file for internationalization (

As I integrate a package into my Next.js project (v13.4.3), I encounter an issue with a sub-dependency that provides translations via a JSON file. Upon compilation, the following error occurs: - info Collecting page data ..Error: Cannot find module '/ ...

How to send data from JavaScript to ASP.NET

$(document).ready(function () { $("#MainContent_ddlFieldName").on("change", function () { var id = $(this).val(); var name = $(this + "option:selected").text(); $('#<%= lblValue.ClientID %> ...

Relocating sprite graphic to designated location

I am currently immersed in creating a captivating fish animation. My fish sprite is dynamically moving around the canvas, adding a sense of life to the scene. However, my next goal is to introduce food items for the fishes to feast on within the canvas. Un ...

Step-by-step guide to aligning layout using material design in generator-gulp-angular

I am currently using generator-gulp-angular with angular-material-design and ui-router All views are loaded into index.html in the <div ui-view></div> element However, when I attempt to center the element with material design directives insid ...

how can I insert an asp textbox into a div using jquery?

I have an asp.net textbox (<asp:TextBox></asp:TextBox>), and I would like it so that when I click a button, the textbox is placed inside a div like this output (<div><asp:TextBox></asp:TextBox></div>). I tried using the ...

Exploring jQuery: Techniques for Hovering, Changing, and Toggling Images

Currently, I am busy working on my project and I am attempting to achieve this by... I ideally want everything to be operational through click actions for each individual image, allowing them to have their unique "paper". I am aiming for a hover effect an ...

Is there a way for me to provide the product ID based on the selected product?

Is there a way to store the IDs of selected products in a dynamic form with multiple product options? I am able to see the saved products in the console.log(fields, "fields");, but how can I also save the selected product IDs? Any guidance on th ...