Yaffs site version 1.1
[yaffs-website] / web / modules / contrib / advagg / advagg_validator / src / Form / JsHintForm.php
1 <?php
2
3 namespace Drupal\advagg_validator\Form;
4
5 use Drupal\Core\Form\FormStateInterface;
6
7 /**
8  * Configure form for JsHint validation of JavaScript files.
9  */
10 class JsHintForm extends BaseValidatorForm {
11
12   /**
13    * {@inheritdoc}
14    */
15   public function getFormId() {
16     return 'advagg_validator_jshint';
17   }
18
19   /**
20    * {@inheritdoc}
21    */
22   public function buildForm(array $form, FormStateInterface $form_state) {
23     $form = parent::generateForm('js');
24     $form['#attached']['library'][] = 'advagg_validator/jshint';
25     $ignore_list = $this->config('advagg_validator.settings')->get('jshint_ignore');
26     if (is_array($ignore_list)) {
27       $ignore_list = implode(',', $ignore_list);
28     }
29     $form['#attached']['drupalSettings']['jshint'] = [
30       'browser' => TRUE,
31       'curly' => TRUE,
32       'eqeqeq' => TRUE,
33       'forin' => TRUE,
34       'latedef' => TRUE,
35       'newcap' => TRUE,
36       'noarg' => TRUE,
37       'strict' => TRUE,
38       'trailing' => TRUE,
39       'undef' => TRUE,
40       'unused' => TRUE,
41       'predef' => [
42         'Drupal' => FALSE,
43         'drupalSettings' => FALSE,
44         'domready' => FALSE,
45         'jQuery' => FALSE,
46         '_' => FALSE,
47         'matchMedia' => FALSE,
48         'Backbone' => FALSE,
49         'Modernizr' => FALSE,
50         'VIE' => FALSE,
51         'CKEDITOR' => FALSE,
52       ],
53       'ignore' => $ignore_list,
54     ];
55     $form = parent::buildForm($form, $form_state);
56     unset($form['actions']);
57     return $form;
58   }
59
60 }