-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESLint should respect XDG basedir spec when finding user-level .eslintrc #6008
Comments
ESLint doesn't expect I'm not familiar with XDG, so let me try to understand what you're saying. Are you saying that when we search for |
There is also I guess we can use any good module to reach this logic. |
Just realized that this would be a breaking change, since putting |
@jasonkarns there are a few open questions I asked on this. Can you take a look? |
Sorry for the inactivity...
The goal of the XDG basedir spec is to replace the role of
Does this mean that eslint does not merge project-level and user-level (
I suppose it could be looked at this way, though I feel that's a bit of a stretch. (There's no change to the API, for one.) Personally, I would consider this a new feature. Further, the likelihood that anyone has existing
The common practice when following the XDG basedir spec is to expect a tool-specific folder ( So, assuming defaults, one would use |
To answer your first question: User-level config files are ignored completely in favor of project config files if project config files are found. Regarding configuration merge: When linting a file, we first look for an
And with each config found in ancestor directories, we merge those configurations, with child-directory configurations having higher precedence. Only if we find no configuration files, either in the project or in ancestor directories, we will look in |
Thanks for your interest in improving eslint. Unfortunately, it looks like consensus couldn't be reached on this issue and so I'm closing it. While we wish we'd be able to accommodate everyone's requests, we do need to prioritize. We've found that issues failing to reach consensus after 21 days tend never to reach consensus, and as such, we close those issues. This doesn't mean the idea isn't interesting, just that it's not something the team can commit to. |
eslint v2.8.0
eslint does not respect the XDG basedir specification which defines where user-specific configuration files should be located.
Since eslint already expects
$HOME/.eslintrc
, it needs to continue supporting that. (At least until a major version bump.) I propose:XDG_CONFIG_DIRS
is a colon (:
) separated list of paths under which config files can be found. They are listed by preference (withXDG_CONFIG_HOME
taking precedence over them all). As it seems that eslint currently does not merge local.eslintrc
file with~/.eslintrc
, I propose those semantics remain and carry over to the config dir lookup. So eslint would search$XDG_CONFIG_HOME/eslint/config
then each of the paths fromXDG_CONFIG_DIRS
(suffixed with/eslint/config
) taking the first file it finds (not merging if multiple files are found). If no file is found, fall back to~/.eslintrc
as before.Also note, both
XDG_CONFIG_HOME
andXDG_CONFIG_DIRS
have default values specified (~/.config
and/etc/xdg
, respectively), so it is not sufficient to check for the env vars being set.Luckily, @sindresorhus has published xdg-basedir so actually following the logic above is trivial.
require('xdg-basedir').configDirs
returns a preference-sorted array, withXDG_CONFIG_HOME
already as first element; and with default values for the env vars already applied. We merely need to iterate over the array, searching foreslint/config
and take the first one we find (defaulting again to~/.eslintrc
)The text was updated successfully, but these errors were encountered: