Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
ESLint shared configuration for all rules within a plugin

I've created a es lint plugin that provides me with a rule which checks that provided import is not in a dynamic list of blacklisted imports.

The list is loaded from a JSON file.

Currently I am loading this file in the create method of a rule, but the rule is being recreated for each file, which in turn makes the linter slow.

I've found the following text in the ESLint documentation, but no other mention of a way to share some global object within an invocation of the linter.

https://eslint.org/docs/latest/user-guide/configuring/configuration-files#adding-shared-settings

ESLint supports adding shared settings into configuration files. Plugins use settings to specify information that should be shared across all of its rules. You can add settings object to ESLint configuration file and it will be supplied to every rule being executed. This may be useful if you are adding custom rules and want them to have access to the same information and be easily configurable.

Is this supported? I've tried exporting a settings object in the index.js of the plugin, but it is not being picked up at all.

module.exports.settings = {
    "sharedData": "Hello"
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Looks like I already have a workaround, but wondering if someone will come up with a better solution.

What I did in the end was to load the configuration in the index of the rule itself, which is loaded at the start of ESLint.

Instead of depending on context.getCwd() I've fallen back to _dirname. Which proved to be enough for my use case.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!