chrome-devtools-frontend
Version:
Chrome DevTools UI
28 lines (25 loc) • 697 B
JavaScript
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
;
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'enforce const enum in TypeScript',
category: 'Possible Errors',
},
fixable: 'code',
schema: [] // no options
},
create: function(context) {
return {
TSEnumDeclaration(node) {
const isConstEnum = node.const === true;
if (!isConstEnum) {
context.report({node, message: 'TypeScript enums must be declared as const enums: const enum Foo {...}'});
}
}
};
}
};