UNPKG

eslint-plugin-roku

Version:

The ESLint custom plugin with rules and parser for .brs files

37 lines (36 loc) 973 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const CAMELCASE_PATTERN = /^_?[a-z]+[a-zA-Z0-9]*$/; const meta = { docs: { category: 'Stylistic Issues', description: 'Check that function name with is camelcase, ignoring leading `_`', recommended: true, }, fixable: 'code', messages: { invalid: `Function name: "{{name}}" should match expression ${CAMELCASE_PATTERN.source}`, }, schema: [], }; exports.meta = meta; const create = (context) => { function testName(node) { const { id } = node; const { name } = id; if (!CAMELCASE_PATTERN.test(name)) { context.report({ data: { name, }, messageId: 'invalid', node, }); } } return { FunctionDeclaration: testName, SubDeclaration: testName, }; }; exports.create = create;