question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Config file not found in project root, instead looking in node_modules folder

See original GitHub issue

Which version of lesshint are you using? Using Lesshint 3.1.1

How are you running lesshint? CLI, Node.js API, Grunt/Gulp plugin? via npm start - lesshint is being run via lesshint-webpack-plugin

If you’re reporting a bug, please show us some code that’s failing.

module.exports = function (path) {
    path = path || process.cwd();
    const stats = fs.statSync(path);
    let config;

    if (stats.isFile()) {
        // A file was passed, try to load it
        config = loadConfig(path);
    } else {
        // Try to find a config file instead
        const rcfinder = new RcFinder('.lesshintrc', {
            loader: loadConfig
        });

        config = rcfinder.find(path);
    }

    return config;
};

What did you expect to happen? I am running webpack from a webpack.config.js file and using the lesshint-webpack-plugin in my plugins. From the documentation, lesshint should look for a .lesshintrc file in my project root (ie. same folder as the webpack config file), however it does not see my .lesshintrc file.

When debugging the config-loader.js file of lesshint, I noticed that the process.cwd() seems to return the lesshint plugin in the node_modules directory, instead of the top level project root folder, thus it cannot find my .lesshintrc file and just uses the default.

is this a bug or working properly? i don’t mind setting the path to a .json file instead, however i thought it’s supposed to just look for my file directly, and documentation seemed to suggest that that’s how it should work.

Thanks guys 😃

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lucastobrazilcommented, Mar 31, 2017

Ahh nice! thanks 😃 Will do.

0reactions
jwilssoncommented, Mar 31, 2017

@shellscape Good idea! I’ll reach out to them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do node_modules packages read config files in the ...
First search in path.dirname(process.mainModule.filename) then go up the directory tree ../, ../../, ../../../ and so on until you find the ...
Read more >
node_modules folder is always marked as "library root" with ...
In my current project, I can Navigate (including non-project files) to some external npm dependencies like angular, but not to my own company's...
Read more >
Configuration - Quokka.js
The settings in the global config file are applied to all Quokka files, no matter if you are running Quokka in an opened...
Read more >
Configuration Files - ESLint - Pluggable JavaScript Linter
By default, ESLint looks for configuration files in all parent folders up to the root directory. This can be useful if you want...
Read more >
Configuring Jest
If the file specified by path is not found, an error is returned. For example, with the following configuration: JavaScript; TypeScript. /** @ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found