eslint-plugin-airtight

raw JSON →
2.0.0 verified Sat Apr 25 auth: no javascript

An ESLint plugin providing additional rules for TypeScript/JavaScript, including export-inline, param-types (migration helper), return-await (bug finder), sequelize-comment (feature), and unbounded-concurrency (bug finder). Version 2.0.0, maintained by Snyk, with TypeScript types included. Last release 2022-09-26. Differentiators: rules derived from eslint-plugin-sinful with a focus on security and correctness; param-types aids migration by adding types based on configuration; unbounded-concurrency prevents resource starvation by enforcing concurrency limits.

error Error: Cannot find module 'eslint-plugin-airtight'
cause Package not installed or incorrect import syntax (CommonJS vs ESM).
fix
npm install eslint-plugin-airtight --save-dev and ensure using import or correct require path.
error Configuration for rule "airtight/param-types" is invalid: value must be object.
cause Misconfigured rule options: param-types expects an object, not array or string.
fix
Use format: 'airtight/param-types': ['warn', { user: ['./lib/dtos', 'UserDTO'] }]
error TypeError: Cannot read properties of undefined (reading 'map')
cause The unbounded-concurrency rule tried to access a property on an undefined AST node, possibly due to an incomplete syntax tree.
fix
Ensure ESLint parser is correctly configured (e.g., @typescript-eslint/parser for TypeScript).
gotcha The rules are ESM-only; CommonJS require may not work correctly with ESLint's plugin resolution.
fix Use import syntax or upgrade ESLint to version that supports ESM plugins.
deprecated The rule 'export-inline' is stylistic and may conflict with other formatters like Prettier.
fix Consider using Prettier for consistent formatting instead.
gotcha The rule 'param-types' requires careful configuration; incorrect path/import can break TypeScript compilation.
fix Ensure the import path in config is relative to the target file, or use absolute paths.
gotcha The rule 'return-await' may false-positively flag valid patterns where the catch block intentionally does nothing.
fix Add ignore patterns or disable rule in specific files.
gotcha The rule 'unbounded-concurrency' requires installing p-map as a peer dependency.
fix Run npm install p-map.
npm install eslint-plugin-airtight
yarn add eslint-plugin-airtight
pnpm add eslint-plugin-airtight

This shows how to configure eslint-plugin-airtight rules in an ESLint config file and demonstrates the param-types and unbounded-concurrency rules.

// .eslintrc.cjs
module.exports = {
  plugins: ['airtight'],
  rules: {
    'airtight/export-inline': 'warn',
    'airtight/param-types': ['warn', { user: ['./lib/dtos', 'UserDTO'] }],
    'airtight/return-await': 'error',
    'airtight/sequelize-comment': 'warn',
    'airtight/unbounded-concurrency': 'error',
  },
};

// Example file
function foo(user, name: string) {  // 'user' will have type UserDTO added
  const p = new Promise((resolve) => {});
  return await Promise.all([p]); // error: use pMap with concurrency
}