Possibility to add custom variables to linter


#1

I’m currently working on a Discord bot, I’ll use the fs module to load commands somewhat like CommonJS does.

const code = fs.readFileSync(`${dir}/${file}`, 'utf8')
const fn = new Function('command', 'Command', 'Client', 'Discord', 'db', code)

Where a command file could look like:

command.register = class PingCommand extends Command
{
  constructor ()
  {
    super(Client, {
      name: 'ping',
      aliases: [ ],
      group: 'utils',
      permissions: [ 0 /* 0: anyone can execute this */ ],
      args: { /* No arguments needed here */ }
    })
  }

  async run (message, args, Account /* The fixed account that includes data from the database. */ )
  {
    // ...
  }
}

command.register is a set method:

class CommandRegistrar
{
  // ...
  set regiser (command)
  {
    // Verify and save comand
  }
}

29

As you can see there is a few linting errors, is there any way I can add my own syntaxes to it?


#2

You can specify global variables at the top of your file - see https://eslint.org/docs/user-guide/configuring#specifying-globals


#3

Thank you, this solved my issue :heart: