Atom.config.get('bool') not working like I expect


#1

So I do not know javascript but did a couple packages in it recently. I am currently working on a new settings interface for one of my packages for linting ansible and code is not behaving like I would expect. Code looks like:

export default {
  config: {
...
    useRulesDirs: {
      title: 'Use non-default rules directories with Ansible-Lint.',
      type: 'boolean',
      default: false
    },
...
};

if (atom.config.get('useRulesDirs')) {
  "do stuff"
}

I have thoroughly verified that after checking the relevant box in the package settings that the block of code within the conditional never executes. This code would work, given syntactical differences, in all the languages I do know. Is this a peculiarity with javascript or the Atom API? What extra thing do I need to do here to get this conditional working?


#2

The name of the config key is incorrect. By default, Atom prepends your package name to the beginning of the config key, so if your package was named “package-name”, then the config key you would retrieve from would be package-name.useRulesDirs.


#3

Yeah that does seem to be what I forgot here. Thanks for the help!