Skip to content

Commit

Permalink
add a linter rule to check if exists in package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
bzhang0 committed Nov 7, 2021
1 parent f2a1e38 commit 7146fb5
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

/**
* @file Rule to check if package.json includes 'sdk-type'
* @author Ben Zhang
*/

import { Rule } from "eslint";
import { getRuleMetaData, getVerifiers, stripPath } from "../utils";

//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------

export = {
meta: getRuleMetaData(
"ts-package-json-sdktype-exists",
"check if package.json includes 'sdk-type'",
"code"
),
create: (context: Rule.RuleContext): Rule.RuleListener => {
const verifiers = getVerifiers(context, {
outer: "sdk-type",
});
return stripPath(context.getFilename()) === "package.json"
? ({
// callback functions

// check to see if package.json includes 'sdk-type'
"ExpressionStatement > ObjectExpression": verifiers.existsInFile,
} as Rule.RuleListener)
: {};
}
};

0 comments on commit 7146fb5

Please sign in to comment.