@aws-appsync/eslint-plugin

中文文档
2.0.2发布于 2025/04/30Apache-2.0TypeScriptCommonJS近 30 天下载 8.7万

An eslint plugin that lints AppSync JavaScript.

原始使用文档

AWS AppSync ESLint Plugin

An ESLint plugin that lints and produces errors for AWS AppSync resolvers written in JavaScript.

About

@aws-appsync/eslint-plugin catches invalid syntax in your code when leveraging the APPSYNC_JS runtime. The plugin allows you to quickly get feedback about your code during development without having to push your changes to the cloud.

The plugin provides 2 rule sets that you can use during development.

  • plugin:@aws-appsync/base configures a base set of rules
  • plugin:@aws-appsync/recommended provides the base rules and additional rules that requires TypeScript to be configured in your project

plugin:@aws-appsync/base

Rule Description

  • no-async: Async processes and promises are not supported.
  • no-await: Async processes and promises are not supported.
  • no-promise: Async processes and promises are not supported.
  • no-classes: Classes are not supported
  • no-for: for is not supported(except for for-in and for-of, which are supported)
  • no-continue: continue is not supported
  • no-generators: generators are not supported
  • no-yield: yield is not supported
  • no-labels: labels are not supported
  • no-this: this keyword is not supported
  • no-try: try/catch structure is not supported
  • no-while: while loops are not supported
  • no-disallowed-unary-operators: ++, --, and ~ unary operators are not allowed
  • no-disallowed-binary-operators: instanceof operator is not allowed
  • no-regex: regex literals are not supported
  • no-disallowed-re-assignment: re-assigning context and base properties of context are not allowed

plugin:@aws-appsync/recommended

  • no-recursion: recursive function calls re ot allowed
  • no-disallowed-methods: some methods are not allowed. See the reference for a full set of supported built-in functions
  • no-function-passing: Passing functions as function arguments to functions is not allowed
  • no-function-reassign: Functions cannot be reassigned
  • no-function-return: functions cannot be the return value of functions

Usage

Install the plugin in your project by running

npm install -D @aws-appsync/eslint-plugin

The base configuration can be set up by adding the following:

// eslint.config.mjs
import appsync from '@aws-appsync/eslint-plugin';

/** @type {import('eslint').Linter.Config[]} */
export default [
    appsync.configs.base,
    // ...other config
];

You can use additional rules of the plugin (e.g.: in plugin:@aws-appsync/recommended) that requires the linter to parse TypeScript. These rules can catch unsupported features like recursion and disallowed method calls. To leverage these rules, setup Typescript in your project, and install this dependency:

npm i -D @typescript-eslint/parser

Set your config file to something similar to the following:

// eslint.config.mjs
import appsync from '@aws-appsync/eslint-plugin';

/** @type {import('eslint').Linter.Config[]} */
export default [
    { languageOptions: { parserOptions: { projectService: true } } },
    appsync.configs.recommended,
    // ...other config
];

版本与发布记录

@aws-appsync/eslint-plugin 共发布 12 个版本,首次发布于 2022/11/17;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.0.2latest2025/04/301.5 年前
2.0.12025/01/181.8 年前
1.10.12024/11/012 年前
1.10.02024/10/312 年前
1.6.02023/11/282 年前
1.4.02023/09/073 年前

关于 @aws-appsync/eslint-plugin 的常见问题

@aws-appsync/eslint-plugin 是什么?

An eslint plugin that lints AppSync JavaScript.

如何安装 @aws-appsync/eslint-plugin?

在项目目录运行 npm install @aws-appsync/eslint-plugin,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:eslint(^8.57.0 || ^9.0.0)、typescript(^3.9.6 || ^4.0.0 || ^5.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@aws-appsync/eslint-plugin 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@aws-appsync/eslint-plugin 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@aws-appsync/eslint-plugin 可以商用吗?

@aws-appsync/eslint-plugin 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@aws-appsync/eslint-plugin 的下载量有多少?

根据 npm 官方下载统计,@aws-appsync/eslint-plugin 在 2026/10/07 – 2026/11/05 这 30 天内被下载 87,122 次,日均约 2,904 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@aws-appsync/eslint-plugin 还在维护吗?

最新版本 2.0.2 发布于 2025/04/30(1.5 年前);至今共发布 12 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/11/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。