UNPKG

npm-groovy-lint

Version:

Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files

57 lines (47 loc) 974 B
// Assignment in condition import { getStringRange } from "../utils.js"; const rule = { range: { type: "function", func: (errLine, errItem) => { return getStringRange(errLine, /(?<!=|!|>|<)=(?!=)/g, errItem); }, }, fix: { label: `Replace "=" by "=="`, type: "replaceString", before: /(?<!=|!|>|<)=(?!=)/g, after: "==", }, tests: [ { sourceBefore: ` if ((value = true)) { println 'should be ==' } while (value = true) { println 'should be ==' } while (value = true && value != false) { println 'should be ==' } (value = true) ? x : y (value = true) ?: x `, sourceAfter: ` if ((value == true)) { println 'should be ==' } while (value == true) { println 'should be ==' } while (value == true && value != false) { println 'should be ==' } (value == true) ? x : y (value == true) ?: x `, }, ], }; export { rule };