npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

awslint

v2.169.0-alpha.0

Published

Enforces the AWS Construct Library guidelines

Downloads

5,590

Readme

awslint


cdk-constructs: Developer Preview

The APIs of higher level constructs in this module are in developer preview before they become stable. We will only make breaking changes to address unforeseen API issues. Therefore, these APIs are not subject to Semantic Versioning, and breaking changes will be announced in release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.


A linter for the AWS Construct Library's API. It reflects a construct library's module via it's .jsii manifest and checks that the module adheres to the AWS Resource Construct Design Guidelines.

Usage

First, the module must be built through jsii (the linter reads the .jsii manifest).

Now, if you simply run awslint from a module directory, you will see a list of diagnostic messages.

For example:

$ cd @aws-cdk/aws-sns
$ npm run awslint
warning: [awslint:resource-interface:@aws-cdk/aws-sns.Subscription] every resource must have a resource interface 
warning: [awslint:resource-interface:@aws-cdk/aws-sns.TopicPolicy] every resource must have a resource interface 

Each diagnostics includes the following elements:

warning: [awslint:resource-interface:@aws-cdk/aws-sns.Subscription] every resource must have a resource interface 
[------] [-------------------------] [----------------------------] [-------------------------------------------] 
   ^              ^                                 ^                                       ^                        
   |              |                                 |                                       |                        
 level           rule                             scope                                  message                     

Options and Configuration

awslint accepts options either through the command-line (i.e. --debug) or via an awslint key in the module's package.json.

{
  "awslint": {
    "debug": true
  }
}

Include/Exclude

The i/--include and -x/--exclude options can be used to specify which rules will be evaluated.

For example:

# evaluate only the "resource-props" and "import" rules in all scopes
$ npm run awslint -- -i resource-props -i import

# evaluate only the "import" rule in all scopes besides ones that begin with "@aws-cdk/aws-s3"
$ npm run awslint -- -i import -x "*:@aws-cdk/aws-s3*"

Filters are specified using the following pattern:

rule[*][:scope[*]]

If a "*" suffix is provided, the component is treated as a prefix. Otherwise, it is evaluated as a full match.

If scope is not specified, all scopes are implied (*).

Examples:

  • *:* - matches all rules in all scopes
  • *:@aws-cdk/aws-apigateway.IRestApi* - matches all rules in scopes that begin with @aws-cdk/aws-apigateway.IRestApi
  • resource-props - matches the resource-props rule in all scopes
  • resource-* - matches all rules that begin with resource-.
  • resource-*:@aws-cdk/aws-sns* - matches all resource- rules with scope that begins with @aws-cdk/aws-sns.

When a rule is excluded, it will be displayed as skipped: in the output and will always considered to pass.

Saving State

The --save option can be used to capture all failed linting rules and save them as excludes in the module's package.json file. This is useful to bootstrap the linting process and
progressively fix errors.

$ npm run awslint -- --save
[shows errors]

$ cat package.json
{
  ...
  "awslint": {
    "exclude": [
      "...", // added by awslint --save
      "...", // added by awslint --save
    ]
  }
}

$ npm run awslint
[no errors]

If --save is specified, awslint will always exit with status code 0.

Output Options

  • Use --verbose to print all passing linter rules (disabled by default).
  • Use --quiet to hide all warnings and skips (just prints errors)

Listing Rules

To list all linter rules:

$ npm run awslint list
module-name: module name must be @aws-cdk/aws-<namespace>
construct-ctor: signature of all construct constructors should be "scope, id, props"
resource-class: every resource must have a resource class (L2)
...

The AWS Resource Construct Design Guidelines document includes references for all rules. For example, see #construct-interface for a discussion about the "construct-interface" rule.