Skip to content
moduleeslint-plugin-warp-drive

Lint rules for helping to ensure best practices and hygiene when using WarpDrive.

πŸ’‘ Backwards Compatibility

For security and backwards compatibility, this Package is also available as eslint-plugin-ember-data

Rules ​

  • πŸ› οΈ has Autofix
  • 〽️ has Partial Autofix
  • βœ… Recommended
  • πŸ’œ TypeScript Aware

🏷️ Categories

  • 🐞 Helps prevent buggy code
  • ⚑️ Helps prevent performance issues
  • πŸ† Enforces a best practice
RuleDescription🏷️✨
no-create-record-rerenderHelps avoid patterns that often lead to excess or broken rendersπŸžβš‘οΈβœ…
no-invalid-relationshipsEnsures the basic part of relationship configuration is setup appropriatelyπŸ†βœ…
no-legacy-request-patternsRestricts usage of deprecated or discouraged request patternsπŸ†βœ…
no-external-request-patternsRestricts usage of discouraged non-warp-drive request patternsπŸ†βœ…
no-invalid-resource-typesEnsures resource types follow a conventional pattern when used in common APIsπŸ†βœ…πŸ› οΈ
no-invalid-resource-idsEnsures resource ids are strings when used in common APIsπŸ†βœ…πŸ› οΈ
no-legacy-importsEnsures imports use paths specified by the Package Unification RFCπŸ†βœ…πŸ› οΈ
no-test-module-hooksDisallow hooks.beforeEach/hooks.afterEach in favor of setup functions each test calls explicitly⚑️
template-always-use-request-contentEnsures the result of a <Request> is actually consumed🐞
template-require-request-error-blockEnsures <Request>/<Await> always provide an :error block🐞
require-request-error-blockEnsures <Request> is always given a states.error handler🐞

Usage ​

Recommended Rules are available as a flat config for easy consumption:

ts
// eslint.config.js (flat config)
const WarpDriveRecommended = require('eslint-plugin-warp-drive/recommended');

module.exports = [
  ...WarpDriveRecommended,
];

The template rules, template-always-use-request-content and template-require-request-error-block, are available as a separate flat config, since it also sets ember-eslint-parser as the parser for .gjs/.gts files:

ts
// eslint.config.js (flat config)
const WarpDriveRecommended = require('eslint-plugin-warp-drive/recommended');
const WarpDriveTemplateRecommended = require('eslint-plugin-warp-drive/recommended-templates');

module.exports = [
  ...WarpDriveRecommended,
  ...WarpDriveTemplateRecommended,
];

The React rule, require-request-error-block, is available as a separate flat config, since it also enables JSX parsing for .jsx/.tsx files:

ts
// eslint.config.js (flat config)
const WarpDriveRecommended = require('eslint-plugin-warp-drive/recommended');
const WarpDriveReactRecommended = require('eslint-plugin-warp-drive/recommended-react');

module.exports = [
  ...WarpDriveRecommended,
  ...WarpDriveReactRecommended,
];

The internal rule, no-test-module-hooks, encodes conventions for a large test suite like WarpDrive's own rather than for app code, so it is kept out of recommended and is available as its own flat config:

ts
// eslint.config.js (flat config)
const WarpDriveRecommended = require('eslint-plugin-warp-drive/recommended');
const WarpDriveInternalRecommended = require('eslint-plugin-warp-drive/recommended-internal');

module.exports = [
  ...WarpDriveRecommended,
  ...WarpDriveInternalRecommended,
];

Guides ​

  • Linting: install the plugin and enable its recommended, template and React configs.

Variables ​

Released under the MIT License.