mirror of
https://github.com/joelwmale/webhook-action.git
synced 2024-08-25 08:08:00 +00:00
1ada95e04a
- Convert project to Javascript/Typescript - Allow custom headers to be passed in (optional) - Allow body to be optional
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
/**
|
|
* @fileoverview Rule to enforce default clauses in switch statements to be last
|
|
* @author Milos Djermanovic
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Rule Definition
|
|
//------------------------------------------------------------------------------
|
|
|
|
module.exports = {
|
|
meta: {
|
|
type: "suggestion",
|
|
|
|
docs: {
|
|
description: "enforce default clauses in switch statements to be last",
|
|
category: "Best Practices",
|
|
recommended: false,
|
|
url: "https://eslint.org/docs/rules/default-case-last"
|
|
},
|
|
|
|
schema: [],
|
|
|
|
messages: {
|
|
notLast: "Default clause should be the last clause."
|
|
}
|
|
},
|
|
|
|
create(context) {
|
|
return {
|
|
SwitchStatement(node) {
|
|
const cases = node.cases,
|
|
indexOfDefault = cases.findIndex(c => c.test === null);
|
|
|
|
if (indexOfDefault !== -1 && indexOfDefault !== cases.length - 1) {
|
|
const defaultClause = cases[indexOfDefault];
|
|
|
|
context.report({ node: defaultClause, messageId: "notLast" });
|
|
}
|
|
}
|
|
};
|
|
}
|
|
};
|