How do I add a JavaScript file from a module?
You will have to add the js in libraries.yml, like


dirty_forms:
  version: VERSION
  js:
    js/jquery.dirtyforms.js:{}
dirty_forms_ckeditor:
  version: VERSION
  js:
    js/jquery.dirtyforms.ckeditor.js:{}


and then include in the form via

$form['#attached']['library'][] = 'dirty_forms/dirty_forms';