@endo/eslint-plugin
v3.0.0
Published
ESLint plugin for using Endo
Readme
@endo/eslint-plugin
ESLint rules and shareable configs for Hardened JavaScript and Endo packages.
Installation
npm install --save-dev eslint @endo/eslint-pluginUsage
ESLint 9+ (Flat Config)
In your eslint.config.js (or .mjs/.cjs):
import endoPlugin from '@endo/eslint-plugin';
export default [
// Apply the recommended rules for Hardened JS code.
...endoPlugin.configs['flat/recommended'],
];ESLint 8 (Legacy Config)
In your .eslintrc.json (or .eslintrc.js, etc.):
{
"extends": ["plugin:@endo/recommended"]
}Shareable Configs
recommended / flat/recommended
Core rules for code written to run under Hardened JavaScript (post-lockdown()).
// flat config
...endoPlugin.configs['flat/recommended']
// legacy
{ "extends": ["plugin:@endo/recommended"] }Breaking change (v3): This config no longer bundles
@jessie.js/eslint-plugin. Consumers who want the Jessiesafe-await-separatorrule and theuse-jessieprocessor must install@jessie.js/eslint-pluginand configure it directly:import jessie from '@jessie.js/eslint-plugin'; import endo from '@endo/eslint-plugin'; export default [ ...endo.configs['flat/recommended'], ...jessie.configs['flat/recommended'], { processor: jessie.processors['use-jessie'] }, ];
recommended-requiring-type-checking / flat/recommended-requiring-type-checking
Extends recommended and adds the restrict-comparison-operands rule, which requires TypeScript type information.
// flat config
...endoPlugin.configs['flat/recommended-requiring-type-checking']
// legacy
{ "extends": ["plugin:@endo/recommended-requiring-type-checking"] }style / flat/style
Opinionated JS coding-style rules: @stylistic/eslint-plugin, jsdoc, and prettier.
...endoPlugin.configs['flat/style']imports / flat/imports
Rules about how packages should use imports: require file extensions, disallow extraneous dependencies, prefer named exports.
...endoPlugin.configs['flat/imports']strict / flat/strict
style + imports + recommended in one config.
...endoPlugin.configs['flat/strict']internal / flat/internal
The opinionated baseline used by all packages within the Endo monorepo itself. Extends strict and adds TypeScript-ESLint. Not intended for external use.
...endoPlugin.configs['flat/internal']ses / flat/ses
Extends internal with strict global-variable restrictions for SES bootstrap code that runs before lockdown().
...endoPlugin.configs['flat/ses']daemon / flat/daemon (deprecated)
Alias for internal/flat/internal.
Rules
| Rule | Description | Fixable |
|------|-------------|---------|
| @endo/assert-fail-as-throw | Make assert.fail() count as a throw in ESLint's control-flow analysis | — |
| @endo/harden-exports | Ensure each named export is immediately followed by harden() | 🔧 |
| @endo/no-assign-to-exported-let-var-or-function | Disallow reassignment of exported let/var/function bindings | — |
| @endo/no-harden-pattern-maker | Warn when hardening pattern-maker return values (they are already hardened) | — |
| @endo/no-multi-name-local-export | Disallow exporting the same local binding under multiple names | — |
| @endo/no-polymorphic-call | Disallow method calls on non-local receiver objects | — |
| @endo/restrict-comparison-operands | Restrict </>/<=/>= to operands of compatible types | — |
Configuring Individual Rules
// flat config
export default [
{
plugins: { '@endo': endoPlugin },
rules: {
'@endo/harden-exports': 'error',
'@endo/no-polymorphic-call': 'warn',
},
},
];// legacy (.eslintrc.json)
{
"plugins": ["@endo"],
"rules": {
"@endo/harden-exports": "error",
"@endo/no-polymorphic-call": "warn"
}
}Compatibility
| ESLint version | How to use |
|----------------|------------|
| 9.x | eslint.config.js flat config, use flat/* configs |
| 8.x | .eslintrc.* legacy config, use bare config names |
The plugin ships both legacy (recommended, internal, …) and flat (flat/recommended, flat/internal, …) configs so you can use whichever ESLint version your project requires.
