@aws-appsync/eslint-plugin

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

一个 elints AppSync JavaScript 的 eslint 插件.

中文使用文档

AWS AppSync ESLint 插件

一个 ESLint 插件,用于擦除和生成出错 用 JavaScript 编写的 AWS AppSync 解析器。 。 。 .

关于

@aws-appsync/slint-plugin (英语) 使用时在代码中捕获无效的语法 应用程序 JS 运行时间。 该插件允许您在开发过程中快速获取对代码的反馈,而无需将您的更改推向云端.

该插件提供了2个规则集,您可以在开发期间使用.

  • plugin:@aws-appsync/base 配置一套基本规则
  • plugin:@aws-appsync/recommended 提供要求 TypeScript 在您的工程中配置的基础规则和附加规则

插件 : @aws- appsync/ base

规则说明

  • no-async:Async进程和承诺不支持.
  • no-await:Async进程和承诺不支持.
  • no-promise:Async进程和承诺不支持.
  • no-classes: 不支持类
  • no-for:因为不支持(其中支持的除外)
  • no-continue数字 : continue 不支持
  • no-generators: 发电机不支持
  • no-yield数字 : yield 不支持
  • no-labels: 不支持标签
  • no-this数字 : this 不支持关键字
  • no-try:不支持试验/渔获物结构
  • no-while: 不支持循环
  • no-disallowed-unary-operators数字 : ++, (中文(简体) ), --,以及 ~ 不允许非本地运算符
  • no-disallowed-binary-operators数字 : instanceof 不允许操作员
  • no-regex: 不支持正则文字
  • no-disallowed-re-assignment: 重新指派 context 和基础属性 context 不允许

插件 : @aws- appsync/ 建议

  • no-recursion: 递归函数调用允许
  • no-disallowed-methods:一些方法不允许. 见 参考文献 用于一整套支持的内置功能
  • no-function-passing: 不允许将函数作为函数参数传递到函数
  • no-function-reassign: 无法重新分配函数
  • no-function-return: 函数不能是函数的返回值

使用量

通过运行在您的工程中安装插件

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

基础配置可通过以下方式设置:

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

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

您可以使用插件的额外规则( 如: 在 插件 : @aws- appsync/ 建议),它需要linter来解析类型脚本。 这些规则可以捕捉不支持的特性,如重复和不允许的方法调用等. 为了利用这些规则,在您的工程中设置 Typescript, 并安装此依赖 :

npm i -D @typescript-eslint/parser

将您的配置文件设定为类似以下内容 :

// 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 是什么?

一个 elints AppSync JavaScript 的 eslint 插件.

如何安装 @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 和提交记录判断。