This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| testEnvironment: 'node', | |
| transform: {'^.+\\.tsx?$': 'ts-jest'} | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ruleTester.run(RULE_NAME, rule, { | |
| valid: validStatements, | |
| invalid: [ | |
| { code: invalidStatements[0], errors: [{ messageId }], output: validStatements[0] }, | |
| { code: invalidStatements[1], errors: [{ messageId }], output: validStatements[1] }, | |
| { code: invalidStatements[2], errors: [{ messageId }], output: validStatements[2] } | |
| ] | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| context.report({ | |
| messageId: 'readonlyInjectablesRequired', | |
| loc: parameter.loc, | |
| fix: (fixer: RuleFixer) => { | |
| const identifier = parameter.parameter | |
| const fixers: Array<RuleFix> = [ | |
| fixer.insertTextBefore(identifier, 'readonly ') | |
| ]; | |
| return fixers; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| parameters.forEach(parameter => resolveParameter(parameter, context)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| context.report({ | |
| messageId: 'readonlyInjectablesRequired', | |
| loc: parameter.loc | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function resolveParameter(parameter: TSESTree.TSParameterProperty, context: Readonly<RuleContext<MessageIds, Options>>): void { | |
| const isPublic = utils.isParameterPropertyAccessibilityNamed(parameter, 'public'); | |
| const isPrivate = utils.isParameterPropertyAccessibilityNamed(parameter, 'private'); | |
| const isProtected = utils.isParameterPropertyAccessibilityNamed(parameter, 'protected'); | |
| if (!isPublic && !isPrivate && !isProtected) { | |
| return; | |
| } | |
| if (utils.isParameterPropertyReadonly(parameter)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const parameters: Array<TSESTree.TSParameterProperty> = utils.getParameterPropertiesFromMethodDefinition(constructor); | |
| if (!Array.isArray(parameters) || parameters.length === 0) { | |
| return; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (!constructor) { | |
| return; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const classDeclaration: TSESTree.ClassDeclaration = utils.getClassDeclarationFromDecorator(node); | |
| const constructor: TSESTree.MethodDefinition = utils.getConstructorFromClassDeclaration(classDeclaration); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as utils from '../utils/utils'; |
NewerOlder