Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jkyoutsey/53a0ceaa0dfe21b21685ab091e09235a to your computer and use it in GitHub Desktop.
Save jkyoutsey/53a0ceaa0dfe21b21685ab091e09235a to your computer and use it in GitHub Desktop.
TypeScript Bazel Lint Rule Functions Must Return Value
// A list of well-known functions that the return value must be used. If unused
// then the function call is either a no-op (e.g. 'foo.trim()' foo is unchanged)
// or can be replaced by another (Array.map() should be replaced with a loop or
// Array.forEach() if the return value is unused).
const METHODS_TO_CHECK = new Set<string>([
['Array', 'concat'],
['Array', 'filter'],
['Array', 'map'],
['Array', 'slice'],
['Function', 'bind'],
['Object', 'create'],
['string', 'concat'],
['string', 'normalize'],
['string', 'padStart'],
['string', 'padEnd'],
['string', 'repeat'],
['string', 'slice'],
['string', 'split'],
['string', 'substr'],
['string', 'substring'],
['string', 'toLocaleLowerCase'],
['string', 'toLocaleUpperCase'],
['string', 'toLowerCase'],
['string', 'toUpperCase'],
['string', 'trim'],
].map(list => list.join('#')));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment