The local ESlint plugin is causing issues with installing dependencies on our CI environment

I have developed a personalized ESLint plugin specifically for one project and have not made it public. It is saved in a folder within my project because I only intend to use it internally, and I see no need to create a separate repository for it. However, I have encountered an issue where it disrupts the proper installation of dependencies on the CI/CD pipeline with `npm ci` or `npm i`, even though there are no problems when installing locally.

Below is the error message I receive from the CI system:

$ npm ci && npm run build:mfe
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /builds/teleoptometry/telo-ui/node_modules/eslint-plugin-telo/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/builds/teleoptometry/telo-ui/node_modules/eslint-plugin-telo/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2023-07-14T10_31_53_477Z-debug.log

Here is the configuration I have:

// .eslintrc.js

module.exports = {
  extends: ['react-app'],
  plugins: ['react-hooks', 'telo'], <--- telo is my plugin name
  rules: {
    [...other rules...]
    'telo/use-telo-navigate': 'error', <--- my rule
  },
}

// package.json

"devDependencies": {
  "eslint-plugin-telo": "file:./eslint"
}

The structure of my eslint folder is as follows:

https://i.sstatic.net/46iuH.png

// my ./src/eslint/index.js file simply imports the rule

module.exports = {
  rules: { 'use-telo-navigate': require('./rules/use-telo-navigate') },
}

I suspect that the issue lies in how I link the ESLint plugin in `package.json`, but I am unsure why it functions correctly on my local machine.

Perhaps I should consider extracting the ESLint plugin into a new repository (unfortunately, I am not utilizing a monorepo) and importing it using `npm link` or similar methods, although I would prefer to avoid this solution.

I anticipate my current setup to function properly as it is. What could be going wrong?

Answer №1

After discovering my mistake, I learned that ESLint no longer allows rules to be dynamically plugged in at runtime from a directory or file using the --rulesDir argument. Now, it is required to use a package instead. You can find more information on this change in this GitHub discussion.

To resolve this issue, I simply ran

cd ./eslint && npm init -y
to create a package.json file alongside the existing index.js file.

However, if you prefer the old behavior of using --rulesDir, there are plugins available such as eslint-plugin-local-rules and eslint-plugin-rulesdir

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

Ways to include input values

In my form, there are 4 text boxes labeled as customer_phy_tot, customer_che_tot, and customer_bio_tot. I want to add up the values entered in these 3 boxes and display the sum in a 4th input box called customer_pcb_tot. customer_bio_obt.blur(function(){ ...

What steps are required when utilizing ngModelOptions allowInvalid = true in AngularJS?

As a newcomer to AngularJS, I am currently navigating a complex form and it seems like incorporating the ngModelOptions { allowInvalid: true } option could prove beneficial. I can only assume that AngularJS's default behavior of discarding the model ...

Fixing NextJS ReferenceError: Request undefined due to using outdated Node version

Whenever I execute npm run dev in my Next.js project, an error pops up: .../node_modules/next/dist/server/web/spec-extension/request.js:28 class NextRequest extends Request { ^ ReferenceError: Request is not defined at Object ...

Show only specific items in an AngularJS application

As a newcomer to AngularJS and the Ionic framework, I'm currently working with the basic Starter Tabs Ionic template. I would like to implement a "Favourite/Bookmark" feature for certain items and display them on a separate tab. The structure of my b ...

What is the best way to create a responsive div containing multiple images?

I am working on a slider and my approach is to create a div and insert 4 images inside it. The images will be stacked one above the other using position: absolute, with a width of 1013px, max-width of 100%, and height set to auto for responsiveness. The is ...

"Encountering a strange behavior in Vue.js: the created() hook

I made a custom feature to refresh my data from the database by clicking a button: <template> <base-projects :projects="projects" /> </template> <script> import { mapGetters } from 'vuex'; import Projects from './ ...

Exploring the interplay of Node.js, createServer function, and the asynchronous Event

In the world of node.js, how does the event loop interact with the http module's createServer method and its callback function? Can similar functionality to createServer be created in userland without modifying node's core system code? My unders ...

Tips for enabling TypeScript's static typings to function during runtime

function multiply(num: number): number { console.log(num * 10) // NaN return num * 10 } multiply("not-a-number") // result == NaN When attempting to call the function above with a hardcoded invalid argument type, TypeScript correctly identifies and w ...

Troubleshooting: Why Your Angular Data Binding is Failing

I am integrating a WCF REST service with an AngularJS application. My goal is to retrieve account information based on the account number provided, however, I am encountering an issue where the text "Account_Type" is displayed three times before showing th ...

Is it possible to line up Ajax request in Javascript?

I am seeking a way to schedule an Ajax request to occur every second. The code I currently have in place functions flawlessly. window.onload = function () { setTimeout(doStuff, 1000); // Wait before continuing } function doStuff() { ...

Using scriptlet based IDs in jQuery selectors involves incorporating JavaScript syntax within the jQuery selector to

I need to incorporate dynamic ids in my form, which are based on jsp variables within a scriptlet. How do I correctly select the desired element using jQuery's id selector without encountering any errors? Below is the code snippet: <form name="in ...

Error encountered when asynchronously iterating over an object in TypeScript

Could someone please help me understand why I am getting an error with this code? var promise = new Promise((resolve, reject) => { resolve([1, 2, 3, 4, 5]); }); async function doSomethingAsync() { var data = await promise; data.forEach(v = ...

Difficulty arises when collapsed text in Bootstrap clashes with the footer design

Hey there! I'm working on this website using Bootstrap, and I've encountered a problem. When you click the "See Wikipedia" button, the content expands and overlaps the footer in a strange way without changing the page height. I've tried adju ...

Is storing text in data-content and utilizing bootstrap-popover.js compatible?

Is it possible to display HTML content in a popover using ? How reliable is it to store text in data-content? Can we expect it to function properly across all browsers? ...

Tips for updating routerlink in navigation bar in Angular 4

I'm encountering an issue with routing to the wrong routelink. How can I prevent this from happening? My apologies for my lack of experience. The error message displayed in the Chrome console is: ERROR Error: Uncaught (in promise): Error: Cannot mat ...

How to retrieve a form submission from Jquery HandsonTable in PHP using $_POST

Recently, I've started diving into the world of javascript/jquery/ajax. My current project involves fetching data from a jQuery handsonTable () and integrating it with my PHP code. The process includes generating a table from a MySQL database, utili ...

Guide on organizing a multi-dimensional array of objects based on property value using javascript?

I am faced with the challenge of sorting a multidimensional array based on values, but the selection is dependent on the parentID. This is my current array: const result = [ [{value: 123, parentID: 1}, {value: 'string123', parentID: 2}], [{ ...

Transferring data between modules in nodejs

Within my custom module, there is a method designed to query the database and check if a given username exists. I need certain values to be returned in order to determine the query result at a higher level. var findUserbyUsername=function(username) { ...

Using Vue to dynamically wrap a component with a tag

Have you ever wondered how the v-if directive in Vue.js can hide an entire component along with its content based on a condition? I am curious to know: Is it possible to only hide the surrounding tag or component without removing its contents? ...

Passing Selectize.js load callback to a custom function

I set up selectize.js to gather configuration options from html data attributes. One of the configurations involves specifying a js function for custom data loading (not just simple ajax loading). Everything was working smoothly until I tried running an as ...