Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Tokesh <[email protected]>
  • Loading branch information
Tokesh committed Feb 27, 2025
1 parent fd72587 commit ff98a0e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions tools/src/linter/SchemaVisitingValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ export default class SchemaVisitingValidator {
return errors
}

validateFile(filePath: string): ValidationError[] {
validate_file(file_path: string): ValidationError[] {
const errors: ValidationError[] = []
const visitor = this.createVisitor(errors)

const targetFile = [...this._namespaces_folder.files, ...this._schemas_folder.files].find(f => f.file === filePath)

if (!targetFile) {
return [{ message: `File not found in namespaces/schemas: ${filePath}`, file: filePath }]
const target_file = [...this._namespaces_folder.files, ...this._schemas_folder.files].find(f => f.file === filePath)

Check failure on line 60 in tools/src/linter/SchemaVisitingValidator.ts

View workflow job for this annotation

GitHub Actions / lint

'filePath' is not defined

Check failure on line 60 in tools/src/linter/SchemaVisitingValidator.ts

View workflow job for this annotation

GitHub Actions / validate

Cannot find name 'filePath'. Did you mean 'file_path'?

if (!target_file) {
return [{ message: `File not found in namespaces/schemas: ${file_path}`, file: file_path }]
}

visitor.visit_specification(new SpecificationContext(targetFile.file), targetFile.spec())
visitor.visit_specification(new SpecificationContext(target_file.file), target_file.spec())

return errors
}
Expand Down
20 changes: 10 additions & 10 deletions tools/src/linter/SpecValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class SpecValidator {
schemas_validator: SchemasValidator
schema_refs_validator: SchemaRefsValidator
inline_object_schema_validator: SchemaVisitingValidator
changedOnly: boolean
changed_only: boolean

constructor (root_folder: string, logger: Logger, changedOnly: boolean) {

Check failure on line 33 in tools/src/linter/SpecValidator.ts

View workflow job for this annotation

GitHub Actions / lint

Parameter name `changedOnly` must match one of the following formats: snake_case, UPPER_CASE
this.logger = logger
Expand All @@ -39,31 +39,31 @@ export default class SpecValidator {
this.schemas_validator = new SchemasValidator(root_folder, logger)
this.schema_refs_validator = new SchemaRefsValidator(this.namespaces_folder, this.schemas_folder)
this.inline_object_schema_validator = new SchemaVisitingValidator(this.namespaces_folder, this.schemas_folder)
this.changedOnly = changedOnly
this.changed_only = changedOnly
}

private getChangedFiles(): string[] {
try {
const output = execSync('git diff --name-only origin/main', { encoding: 'utf-8' })
return output.split('\n').filter(file => file.endsWith('.yml') || file.endsWith('.yaml'))
} catch (error) {
this.logger.error('Error:' + error)
this.logger.error(`Error getting changed files: ${error}`)

Check failure on line 50 in tools/src/linter/SpecValidator.ts

View workflow job for this annotation

GitHub Actions / lint

Invalid type "unknown" of template literal expression
return []
}
}

validateChangedFiles(): ValidationError[] {
const changedFiles = this.getChangedFiles()
validate_changed_files(): ValidationError[] {
const changed_files = this.getChangedFiles()

Check failure on line 57 in tools/src/linter/SpecValidator.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
if (changedFiles.length === 0) {
if (changed_files.length === 0) {
this.logger.log('No valid files to check')
return []
}

Check failure on line 62 in tools/src/linter/SpecValidator.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
this.logger.log(`Checking diff files:\n${changedFiles.join('\n')}`)
this.logger.log(`Checking diff files:\n${changed_files.join('\n')}`)
let errors: ValidationError[] = []

Check failure on line 65 in tools/src/linter/SpecValidator.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
for (const file of changedFiles) {
for (const file of changed_files) {
let normalizedFile = file

Check failure on line 67 in tools/src/linter/SpecValidator.ts

View workflow job for this annotation

GitHub Actions / lint

Variable name `normalizedFile` must match one of the following formats: snake_case, UPPER_CASE

Check failure on line 68 in tools/src/linter/SpecValidator.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
if (file.startsWith('spec/')) {
Expand All @@ -72,14 +72,14 @@ export default class SpecValidator {
normalizedFile = relative(resolve('schemas'), resolve(file))
}

Check failure on line 74 in tools/src/linter/SpecValidator.ts

View workflow job for this annotation

GitHub Actions / lint

Trailing spaces not allowed
errors = errors.concat(this.inline_object_schema_validator.validateFile(normalizedFile))
errors = errors.concat(this.inline_object_schema_validator.validate_file(normalizedFile))
}

return errors
}

validate (): ValidationError[] {
if (this.changedOnly) return this.validateChangedFiles()
if (this.changed_only) return this.validate_changed_files()

const component_errors = [
...this.namespaces_folder.validate(),
Expand Down

0 comments on commit ff98a0e

Please sign in to comment.