Package Exports
- eslint-plugin-isaacscript
- eslint-plugin-isaacscript/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eslint-plugin-isaacscript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
eslint-plugin-isaacscript
eslint-plugin-isaacscript is a collection of miscellaneous ESLint rules that can help make your JavaScript/TypeScript code more safe or more strict.
This plugin is named after (and used in) the IsaacScript framework. But you don't have to know anything about IsaacScript to use it - you can use these rules with any JavaScript/TypeScript project.
Alternatively, if you want to get off the ground and running with ESLint + TypeScript in a new project, then you should check out the isaacscript-lint meta-package.
This project is written in TypeScript.
Install / Usage
npm install --save-dev eslint eslint-plugin-isaacscript- Add
"plugin:isaacscript/recommended"to theextendssection of your.eslintrc.jsfile. (This will automatically add the plugin and add all of the recommended rules.)- Alternatively, if you want to only enable some specific rules, then add
"isaacscript"to thepluginssection of your.eslintrc.jsfile, and then add the specific rules that you want in therulessection.
- Alternatively, if you want to only enable some specific rules, then add
Configs
recommended- Enables just the recommended rules.all- Enables all the rules. You would probably never want to use this config, unless you wanted to enable every rule except for one or two specific rules (since specifying a blacklist would be less verbose than specifying a whitelist, in this case).
Rules
Each rule has emojis denoting:
- ✅ - if it belongs to the
recommendedconfiguration - 🔧 - if some problems reported by the rule are automatically fixable by the
--fixcommand line option - 💭 - if it requires type information
| Name | Description | ✅ | 🔧 | 💭 |
|---|---|---|---|---|
isaacscript/complete-sentences-jsdoc |
Enforces complete sentences for JSDoc comments | ✅ | ||
isaacscript/complete-sentences-line-comments |
Enforces complete sentences for multi-line leading line comments | ✅ | ||
isaacscript/enum-member-number-separation |
Disallows numbers next to letters in enum members | |||
isaacscript/eqeqeq-fix |
Requires the use of === and !== (and automatically fixes) |
✅ | 🔧 | |
isaacscript/format-jsdoc-comments |
Disallows /** comments longer than N characters and multi-line comments that can be merged together |
✅ | 🔧 | |
isaacscript/format-line-comments |
Disallows // comments longer than N characters and multi-line comments that can be merged together |
✅ | 🔧 | |
isaacscript/jsdoc-code-block-language |
Requires a language specification for every JSDoc code block | ✅ | ||
isaacscript/member-ordering |
Require a consistent member declaration order | |||
isaacscript/no-empty-jsdoc |
Disallows empty JSDoc comments | ✅ | 🔧 | |
isaacscript/no-empty-line-comments |
Disallows empty line comments | ✅ | 🔧 | |
isaacscript/no-explicit-array-loops |
Disallows explicit iteration for arrays | ✅ | 🔧 | 💭 |
isaacscript/no-explicit-map-set-loops |
Disallows explicit iteration for maps and sets | ✅ | 🔧 | 💭 |
isaacscript/no-invalid-default-map |
Disallows invalid constructors for the DefaultMap class | 💭 | ||
isaacscript/no-let-any |
Disallows declaring variables with let that do not have a type | ✅ | 💭 | |
isaacscript/no-object-any |
Disallows declaring objects and arrays that do not have a type | ✅ | 💭 | |
isaacscript/no-object-methods-with-map-set |
Disallows using object methods with maps and sets | ✅ | 💭 | |
isaacscript/no-template-curly-in-string-fix |
Disallows template literal placeholder syntax in regular strings (and automatically fixes) | ✅ | 🔧 | |
isaacscript/no-throw |
Disallows the usage of "throw" | 💭 | ||
isaacscript/no-unsafe-plusplus |
Disallow unsafe and confusing uses of the "++" and "--" operators | ✅ | 💭 | |
isaacscript/no-useless-return-no-fix |
Disallows redundant return statements (and does not automatically fix) | ✅ | ||
isaacscript/no-void-return-type |
Disallows void return types on non-exported functions | ✅ | 🔧 | |
isaacscript/prefer-plusplus |
Require "++" or "--" operators instead of assignment operators where applicable | ✅ | 🔧 | |
isaacscript/prefer-postfix-plusplus |
Require "i++" instead of "++i" | ✅ | 💭 | |
isaacscript/require-capital-const-assertions |
Requires const assertions on objects with a capital letter | ✅ | 🔧 | |
isaacscript/require-capital-read-only |
Requires arrays/maps/sets with a capital letter to be read-only | ✅ | 💭 | |
isaacscript/strict-enums |
Disallows the usage of unsafe enum patterns | ✅ | 💭 |
Automatic Fixing
You probably already use Prettier, which is helpful to automatically format files. You probably even have your IDE set up to run Prettier every time your save a file. This kind of thing saves you a tremendous amount of time - you can type out a bunch of code completely unformatted, and then press Ctrl + s at the end to automatically fix everything. (Alternatively, you could press Ctrl + shift + f to format the file without saving it, but it's simpler to just use one hotkey for everything.)
In a similar way to Prettier, this ESLint plugin contains several rules that are designed to automatically apply whenever you save the file (like the format-jsdoc-comments rule). These rules are "fixers", which are applied when ESLint is executed with the "--fix" flag. So, in the same way that you configure Prettier to run on save, you should also configure eslint --fix to run on save.
For example, if you use VSCode, and you have the Prettier and the ESLint extensions installed, you can add the following to your repository's .vscode/settings.json file:
{
// Automatically run the formatter when certain files are saved.
"[javascript]": {
"editor.codeActionsOnSave": ["source.fixAll.eslint"],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.tabSize": 2
},
"[typescript]": {
"editor.codeActionsOnSave": ["source.fixAll.eslint"],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.tabSize": 2
}
}Comment Formatting
For a discussion around comments and the motivations for some of the comment rules in the plugin, see this page.
Contributing
Thanks for helping out with this open-source project!
If you are adding a new rule, start by using the create-rule.sh script to automate a few things:
./create-rule.sh foo "This is a description of the foo rule."
git status # Show what the script didAdditionally, You can contact me on Discord if you are doing a PR and have questions.