Linting rules for hackmud scripts.
- Permits and validates code enclosure in single top-level anonymous function
- Permits subscript syntax
#fs.user.script()
,#4s.user.script()
- Limited validation of subscript syntax
- Permits
#db
calls - Defines hackmud globals
_START
,_TIMEOUT
,_ST
,_TO
,_END
- Permits
#D
,#G
, and#FMCL
preprocessor directives
This plugin is somewhat hackish, at the moment - the largest caveat is that linted scripts should not contain $S_
, $DB_
, $G
, $D
, or $FMCL
.
Install the ESLint linter and eslint-plugin-hackmud2
, either locally (in the directory containing your scripts, or an ancestor of it) or globally - if you don't know the difference I recommend the latter:
$ npm install --global eslint eslint-plugin-hackmud2
To activate eslint-plugin-hackmud2
, create a .eslintrc.json
configuration file in the root work directories containing the script sources which you'd like to lint (or configure your linter/editor's linter plugin to use the configuration file in the location of your choice).
Add hackmud2
to the plugins section of your .eslintrc.json
configuration file, and "plugin:hackmud2/recommended"
as the base configuration:
{
"plugins": [
"hackmud2"
],
"extends": "plugin:hackmud2/recommended"
}
If your scripts reside in the standard hackmud/{user}/scripts
directories, most ESLint consumers should pick up on a single configuration file in the common hackmud
directory.
$ eslint myscript.js
Many popular editors and IDEs support ESLint integration to provide visual indicators for validation rules. Try searching for how to enable ESLint support for your editor if it is not listed below.
Install the Linter and linter-eslint packages:
$ apm install linter
$ apm install linter-eslint
If you installed eslint
/eslint-plugin-hackmud2
globally, check the "Use global ESLint installation" option in Settings > Packages > linter-eslint > Settings.
Enable ESLint linting in your Workspace's settings - I also recommend disabling VSCode's TypeScript validation engine to suppress extraneous warnings. If it doesn't exist already, create a .vscode
directory in your workspace root containing a settings.json
file. Add the following lines:
{
"javascript.validate.enable": false,
"eslint.enable": true
}