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
];