|
| 1 | +import jqueryConfig from "eslint-config-jquery"; |
| 2 | +import globals from "globals"; |
| 3 | + |
| 4 | +export default [ |
| 5 | + { |
| 6 | + ignores: [ |
| 7 | + "dist/**/*", |
| 8 | + "!dist/jquery-ui.js", |
| 9 | + "!dist/jquery-ui.min.js", |
| 10 | + "external/**/*", |
| 11 | + "tests/lib/vendor/**/*", |
| 12 | + "ui/vendor/**/*" |
| 13 | + ] |
| 14 | + }, |
| 15 | + |
| 16 | + { |
| 17 | + ignores: [ "dist/**/*" ], |
| 18 | + rules: { |
| 19 | + ...jqueryConfig.rules, |
| 20 | + "no-unused-vars": [ |
| 21 | + "error", |
| 22 | + { |
| 23 | + argsIgnorePattern: "^_", |
| 24 | + caughtErrorsIgnorePattern: "^_" |
| 25 | + } |
| 26 | + ] |
| 27 | + } |
| 28 | + }, |
| 29 | + |
| 30 | + { |
| 31 | + files: [ "Gruntfile.js" ], |
| 32 | + languageOptions: { |
| 33 | + ecmaVersion: "latest", |
| 34 | + sourceType: "commonjs", |
| 35 | + globals: { |
| 36 | + ...globals.node |
| 37 | + } |
| 38 | + }, |
| 39 | + rules: { |
| 40 | + strict: [ "error", "global" ] |
| 41 | + } |
| 42 | + }, |
| 43 | + |
| 44 | + { |
| 45 | + files: [ "eslint.config.mjs" ], |
| 46 | + languageOptions: { |
| 47 | + ecmaVersion: "latest", |
| 48 | + sourceType: "module", |
| 49 | + globals: { |
| 50 | + ...globals.node |
| 51 | + } |
| 52 | + }, |
| 53 | + rules: { |
| 54 | + strict: [ "error", "global" ] |
| 55 | + } |
| 56 | + }, |
| 57 | + |
| 58 | + // Source, demos |
| 59 | + { |
| 60 | + files: [ "ui/**/*.js", "demos/**/*.js" ], |
| 61 | + languageOptions: { |
| 62 | + ecmaVersion: 5, |
| 63 | + sourceType: "script", |
| 64 | + globals: { |
| 65 | + ...globals.browser, |
| 66 | + ...globals.jquery, |
| 67 | + define: false, |
| 68 | + Globalize: false |
| 69 | + } |
| 70 | + }, |
| 71 | + rules: { |
| 72 | + strict: [ "error", "function" ], |
| 73 | + |
| 74 | + // The following rule is relaxed due to too many violations: |
| 75 | + "no-unused-vars": [ |
| 76 | + "error", |
| 77 | + { |
| 78 | + args: "after-used", |
| 79 | + argsIgnorePattern: "^_", |
| 80 | + caughtErrorsIgnorePattern: "^_" |
| 81 | + } |
| 82 | + ], |
| 83 | + |
| 84 | + // Too many violations: |
| 85 | + camelcase: "off", |
| 86 | + "no-nested-ternary": "off" |
| 87 | + } |
| 88 | + }, |
| 89 | + { |
| 90 | + files: [ "ui/i18n/**/*.js" ], |
| 91 | + rules: { |
| 92 | + |
| 93 | + // We want to keep all the strings in separate single lines |
| 94 | + "max-len": "off" |
| 95 | + } |
| 96 | + }, |
| 97 | + |
| 98 | + // Dist files |
| 99 | + // For dist files, we don't include any jQuery rules on purpose. |
| 100 | + // We just want to make sure the files are correct ES5. |
| 101 | + { |
| 102 | + files: [ "dist/jquery-ui.js", "dist/jquery-ui.min.js" ], |
| 103 | + languageOptions: { |
| 104 | + ecmaVersion: 5, |
| 105 | + sourceType: "script" |
| 106 | + }, |
| 107 | + linterOptions: { |
| 108 | + reportUnusedDisableDirectives: "off" |
| 109 | + } |
| 110 | + }, |
| 111 | + |
| 112 | + // Build |
| 113 | + { |
| 114 | + files: [ "build/**/*.js" ], |
| 115 | + languageOptions: { |
| 116 | + ecmaVersion: "latest", |
| 117 | + sourceType: "commonjs", |
| 118 | + globals: { |
| 119 | + ...globals.node |
| 120 | + } |
| 121 | + }, |
| 122 | + rules: { |
| 123 | + "no-implicit-globals": "error", |
| 124 | + strict: [ "error", "global" ] |
| 125 | + } |
| 126 | + }, |
| 127 | + |
| 128 | + // Demos |
| 129 | + { |
| 130 | + files: [ "demos/**/*.js" ], |
| 131 | + languageOptions: { |
| 132 | + globals: { |
| 133 | + require: true |
| 134 | + } |
| 135 | + } |
| 136 | + }, |
| 137 | + |
| 138 | + // Tests |
| 139 | + { |
| 140 | + files: [ "tests/**/*.js" ], |
| 141 | + languageOptions: { |
| 142 | + ecmaVersion: 5, |
| 143 | + sourceType: "script", |
| 144 | + globals: { |
| 145 | + ...globals.browser, |
| 146 | + ...globals.jquery, |
| 147 | + define: false, |
| 148 | + Globalize: false, |
| 149 | + QUnit: false, |
| 150 | + require: true, |
| 151 | + requirejs: true |
| 152 | + } |
| 153 | + }, |
| 154 | + "rules": { |
| 155 | + |
| 156 | + // Too many violations: |
| 157 | + "max-len": "off", |
| 158 | + "no-unused-vars": "off", |
| 159 | + strict: "off" // ideally, `[ "error", "function" ]` |
| 160 | + } |
| 161 | + } |
| 162 | +]; |
0 commit comments