|
| 1 | +import domenicConfig from "@domenic/eslint-config"; |
| 2 | +import globals from "globals"; |
| 3 | +import html from "eslint-plugin-html"; |
| 4 | +import jsdomInternal from "./scripts/eslint-plugin/index.mjs"; |
| 5 | + |
| 6 | +export default [ |
| 7 | + { |
| 8 | + ignores: [ |
| 9 | + "benchmark/selectors/sizzle-speed/**", |
| 10 | + "lib/jsdom/browser/default-stylesheet.js", |
| 11 | + "lib/jsdom/level3/xpath.js", |
| 12 | + "lib/jsdom/living/generated/**", |
| 13 | + "test/api/fixtures/**", |
| 14 | + "test/jquery-fixtures/**", |
| 15 | + "test/to-port-to-wpts/files/**", |
| 16 | + "test/to-port-to-wpts/frame.js", |
| 17 | + "test/to-port-to-wpts/level1/**", |
| 18 | + "test/to-port-to-wpts/level2/**", |
| 19 | + "test/to-port-to-wpts/level3/**", |
| 20 | + "test/to-port-to-wpts/script.js", |
| 21 | + "test/web-platform-tests/tests/**", |
| 22 | + "test/web-platform-tests/to-upstream/dom/nodes/Document-createComment-createTextNode.js", |
| 23 | + "test/web-platform-tests/to-upstream/svg/element-svg.html", |
| 24 | + "test/web-platform-tests/to-upstream/svg/svgstringlist.html", |
| 25 | + "test/web-platform-tests/to-upstream/**/*dont-upstream*" |
| 26 | + ] |
| 27 | + }, |
| 28 | + { |
| 29 | + files: ["**/*.js"], |
| 30 | + languageOptions: { |
| 31 | + sourceType: "commonjs", |
| 32 | + globals: globals.node |
| 33 | + } |
| 34 | + }, |
| 35 | + ...domenicConfig, |
| 36 | + { |
| 37 | + plugins: { |
| 38 | + "jsdom-internal": jsdomInternal |
| 39 | + }, |
| 40 | + rules: { |
| 41 | + // Overrides for jsdom |
| 42 | + "array-element-newline": "off", |
| 43 | + "no-implied-eval": "off", |
| 44 | + "no-invalid-this": "off", |
| 45 | + "require-unicode-regexp": "off", |
| 46 | + "prefer-template": "off", |
| 47 | + "new-cap": ["error", { capIsNewExceptions: ["ByteString", "USVString", "DOMString"] }], |
| 48 | + |
| 49 | + // Custom rules |
| 50 | + "jsdom-internal/hook-super-invocation": [ |
| 51 | + "error", |
| 52 | + { ancestor: "NodeImpl", hook: "_attach" }, |
| 53 | + { ancestor: "NodeImpl", hook: "_detach" }, |
| 54 | + { ancestor: "NodeImpl", hook: "_descendantAdded" }, |
| 55 | + { ancestor: "NodeImpl", hook: "_descendantRemoved" }, |
| 56 | + { ancestor: "NodeImpl", hook: "_childTextContentChangeSteps" }, |
| 57 | + { ancestor: "ElementImpl", hook: "_attrModified" } |
| 58 | + ] |
| 59 | + } |
| 60 | + }, |
| 61 | + { |
| 62 | + files: ["lib/**"], |
| 63 | + rules: { |
| 64 | + "no-restricted-properties": [ |
| 65 | + "error", |
| 66 | + { |
| 67 | + property: "getAttribute", |
| 68 | + message: "Use 'getAttributeNS' with null as the namespace to access attributes within jsdom" |
| 69 | + }, |
| 70 | + { |
| 71 | + property: "setAttribute", |
| 72 | + message: "Use 'setAttributeNS' with null as the namespace to access attributes within jsdom" |
| 73 | + }, |
| 74 | + { |
| 75 | + property: "hasAttribute", |
| 76 | + message: "Use 'hasAttributeNS' with null as the namespace to access attributes within jsdom" |
| 77 | + }, |
| 78 | + { |
| 79 | + property: "removeAttribute", |
| 80 | + message: "Use 'removeAttributeNS' with null as the namespace to access attributes within jsdom" |
| 81 | + }, |
| 82 | + { |
| 83 | + property: "toggleAttribute", |
| 84 | + message: "Use 'setAttributeNS' and 'removeAttributeNS' with null as the namespace to access attributes " + |
| 85 | + "within jsdom" |
| 86 | + } |
| 87 | + ] |
| 88 | + } |
| 89 | + }, |
| 90 | + { |
| 91 | + files: ["test/api/**"], |
| 92 | + rules: { |
| 93 | + "no-loop-func": "off" |
| 94 | + } |
| 95 | + }, |
| 96 | + { |
| 97 | + files: ["test/web-platform-tests/to-upstream/**/*.{js,mjs,html}"], |
| 98 | + plugins: { html }, |
| 99 | + languageOptions: { |
| 100 | + sourceType: "script", |
| 101 | + globals: { |
| 102 | + ...globals.browser, |
| 103 | + |
| 104 | + /* eslint-disable camelcase */ |
| 105 | + EventWatcher: "readonly", |
| 106 | + test: "readonly", |
| 107 | + async_test: "readonly", |
| 108 | + promise_test: "readonly", |
| 109 | + promise_rejects: "readonly", |
| 110 | + generate_tests: "readonly", |
| 111 | + setup: "readonly", |
| 112 | + done: "readonly", |
| 113 | + on_event: "readonly", |
| 114 | + step_timeout: "readonly", |
| 115 | + format_value: "readonly", |
| 116 | + assert_true: "readonly", |
| 117 | + assert_false: "readonly", |
| 118 | + assert_equals: "readonly", |
| 119 | + assert_not_equals: "readonly", |
| 120 | + assert_in_array: "readonly", |
| 121 | + assert_object_equals: "readonly", |
| 122 | + assert_array_equals: "readonly", |
| 123 | + assert_approx_equals: "readonly", |
| 124 | + assert_less_than: "readonly", |
| 125 | + assert_greater_than: "readonly", |
| 126 | + assert_between_exclusive: "readonly", |
| 127 | + assert_less_than_equal: "readonly", |
| 128 | + assert_greater_than_equal: "readonly", |
| 129 | + assert_between_inclusive: "readonly", |
| 130 | + assert_regexp_match: "readonly", |
| 131 | + assert_class_string: "readonly", |
| 132 | + assert_exists: "readonly", |
| 133 | + assert_own_property: "readonly", |
| 134 | + assert_not_exists: "readonly", |
| 135 | + assert_inherits: "readonly", |
| 136 | + assert_idl_attribute: "readonly", |
| 137 | + assert_readonly: "readonly", |
| 138 | + assert_throws_dom: "readonly", |
| 139 | + assert_throws_js: "readonly", |
| 140 | + assert_unreached: "readonly", |
| 141 | + assert_any: "readonly", |
| 142 | + fetch_tests_from_worker: "readonly", |
| 143 | + timeout: "readonly", |
| 144 | + add_start_callback: "readonly", |
| 145 | + add_test_state_callback: "readonly", |
| 146 | + add_result_callback: "readonly", |
| 147 | + add_completion_callback: "readonly" |
| 148 | + /* eslint-enable camelcase */ |
| 149 | + } |
| 150 | + }, |
| 151 | + rules: { |
| 152 | + "padded-blocks": "off", // we like to add spaces around the main test block |
| 153 | + "camelcase": "off", // setting options like allow_uncaught_exception requires this |
| 154 | + "no-implicit-globals": "off", // it doesn't much matter if we use top-level function declarations here |
| 155 | + "new-cap": [ |
| 156 | + "error", { |
| 157 | + // window.external |
| 158 | + capIsNewExceptions: ["AddSearchProvider", "IsSearchProviderInstalled"] |
| 159 | + } |
| 160 | + ] |
| 161 | + } |
| 162 | + } |
| 163 | +]; |
0 commit comments