2018-11-08 06:48:01 +00:00
|
|
|
module.exports = {
|
2018-11-16 07:15:17 +00:00
|
|
|
extends: [
|
2018-11-08 06:48:01 +00:00
|
|
|
"ash-nazg/sauron-node",
|
|
|
|
"plugin:qunit/recommended", "plugin:testcafe/recommended"
|
|
|
|
],
|
2018-11-16 07:15:17 +00:00
|
|
|
parserOptions: {
|
|
|
|
sourceType: "module"
|
2018-11-08 06:48:01 +00:00
|
|
|
},
|
|
|
|
// Need to make explicit here for processing by jsdoc/check-examples
|
2018-11-16 07:15:17 +00:00
|
|
|
plugins: ["qunit"],
|
|
|
|
env: {
|
|
|
|
browser: true
|
2018-11-08 06:48:01 +00:00
|
|
|
},
|
2018-11-16 07:15:17 +00:00
|
|
|
settings: {
|
2019-03-31 09:39:19 +00:00
|
|
|
polyfills: [
|
|
|
|
"Array.isArray",
|
|
|
|
"Blob",
|
|
|
|
"console",
|
|
|
|
"Date.now",
|
|
|
|
"document.body",
|
|
|
|
"document.evaluate",
|
|
|
|
"document.head",
|
|
|
|
"document.importNode",
|
|
|
|
"document.querySelector", "document.querySelectorAll",
|
|
|
|
"DOMParser",
|
|
|
|
"Error",
|
|
|
|
"fetch",
|
|
|
|
"FileReader",
|
|
|
|
"history.pushState",
|
|
|
|
"history.replaceState",
|
|
|
|
"JSON",
|
|
|
|
"location.href",
|
|
|
|
"location.origin",
|
|
|
|
"MutationObserver",
|
|
|
|
"Object.assign", "Object.defineProperty", "Object.defineProperties",
|
|
|
|
"Object.getOwnPropertyDescriptor",
|
|
|
|
"Object.entries", "Object.keys", "Object.values",
|
|
|
|
"Promise",
|
|
|
|
"Set",
|
|
|
|
"Uint8Array",
|
|
|
|
"URL",
|
|
|
|
"window.getComputedStyle",
|
|
|
|
"window.postMessage",
|
|
|
|
"window.scrollX", "window.scrollY",
|
|
|
|
"XMLHttpRequest",
|
|
|
|
"XMLSerializer"
|
|
|
|
],
|
2018-11-16 07:15:17 +00:00
|
|
|
jsdoc: {
|
|
|
|
additionalTagNames: {
|
2018-11-08 06:48:01 +00:00
|
|
|
// In case we need to extend
|
2018-11-16 07:15:17 +00:00
|
|
|
customTags: []
|
2018-11-08 06:48:01 +00:00
|
|
|
},
|
2018-11-16 07:15:17 +00:00
|
|
|
allowOverrideWithoutParam: true,
|
|
|
|
allowImplementsWithoutParam: true,
|
|
|
|
allowAugmentsExtendsWithoutParam: true,
|
2018-11-08 06:48:01 +00:00
|
|
|
// For `jsdoc/check-examples` in `ash-nazg`
|
2018-11-16 07:15:17 +00:00
|
|
|
matchingFileName: "dummy.md",
|
|
|
|
rejectExampleCodeRegex: "^`",
|
2019-05-23 00:55:52 +00:00
|
|
|
// Todo: Figure out why this is not working and why seem to have to
|
|
|
|
// disable for all Markdown:
|
|
|
|
/*
|
|
|
|
baseConfig: {
|
|
|
|
rules: {
|
|
|
|
"no-multi-spaces": "off"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2019-05-24 06:44:57 +00:00
|
|
|
forceRequireReturn: true,
|
|
|
|
// Todo: Once PR to eslint-plugin-jsdoc may be merged, fix its "reenable later" to-dos for `jsdoc/check-types` in canvg.js file
|
|
|
|
preferredTypes: {
|
|
|
|
"*": {
|
|
|
|
message: "Use a more precise type or if necessary use `{{preferredType}}` or `ArbitraryCallbackResult`",
|
|
|
|
replacement: "Any"
|
|
|
|
},
|
|
|
|
any: {
|
|
|
|
message: "Use a more precise type or if necessary use `{{preferredType}}` or `ArbitraryCallbackResult`",
|
|
|
|
replacement: "Any"
|
|
|
|
},
|
|
|
|
number: {
|
|
|
|
message: "Use `Integer` or `Float`"
|
|
|
|
},
|
|
|
|
Function: {
|
|
|
|
message: "Point to a `@callback` namepath or `GenericCallback` if truly arbitrary in form"
|
|
|
|
},
|
|
|
|
'object<>': {
|
|
|
|
message: "Use the specific object type or `{{preferredType}}` (or `ArbitraryObject` or `ArbitraryModule`) if truly arbitrary",
|
|
|
|
replacement: "PlainObject"
|
|
|
|
},
|
|
|
|
'Array<>': {
|
|
|
|
message: "Use `{{preferredType}}` (or `ArgumentsArray`) if it is truly arbitrary.",
|
|
|
|
replacement: "GenericArray"
|
|
|
|
}
|
|
|
|
}
|
2018-11-08 06:48:01 +00:00
|
|
|
}
|
|
|
|
},
|
2018-11-16 07:15:17 +00:00
|
|
|
overrides: [
|
2018-11-08 06:48:01 +00:00
|
|
|
// Locales have no need for importing outside of SVG-Edit
|
|
|
|
{
|
2018-11-16 07:15:17 +00:00
|
|
|
files: [
|
2018-11-08 06:48:01 +00:00
|
|
|
"editor/locale/lang.*.js", "editor/extensions/ext-locale/**",
|
|
|
|
"docs/tutorials/ExtensionDocs.md"
|
|
|
|
],
|
2018-11-16 07:15:17 +00:00
|
|
|
rules: {
|
2018-11-08 06:48:01 +00:00
|
|
|
"import/no-anonymous-default-export": ["off"]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// For extensions, `this` is generally assigned to be the more
|
|
|
|
// descriptive `svgEditor`; they also have no need for importing outside
|
|
|
|
// of SVG-Edit
|
|
|
|
{
|
2018-11-16 07:15:17 +00:00
|
|
|
files: ["editor/extensions/**/ext-*.js"],
|
|
|
|
rules: {
|
2018-11-08 06:48:01 +00:00
|
|
|
"consistent-this": ["error", "svgEditor"],
|
|
|
|
"import/no-anonymous-default-export": ["off"]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// These browser files don't do importing or requiring
|
|
|
|
{
|
2018-11-16 07:15:17 +00:00
|
|
|
files: [
|
2018-11-08 06:48:01 +00:00
|
|
|
"editor/svgpathseg.js", "editor/touch.js", "editor/typedefs.js",
|
|
|
|
"editor/redirect-on-no-module-support.js",
|
|
|
|
"editor/extensions/imagelib/index.js",
|
|
|
|
"editor/external/dom-polyfill/dom-polyfill.js",
|
|
|
|
"test/all_tests.js", "screencasts/svgopen2010/script.js",
|
|
|
|
"opera-widget/handlers.js",
|
|
|
|
"firefox-extension/handlers.js",
|
|
|
|
"firefox-extension/content/svg-edit-overlay.js"
|
|
|
|
],
|
2018-11-16 07:15:17 +00:00
|
|
|
rules: {
|
2018-11-08 06:48:01 +00:00
|
|
|
"import/unambiguous": ["off"]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// Our Markdown rules (and used for JSDoc examples as well, by way of
|
|
|
|
// our use of `matchingFileName` in conjunction with
|
|
|
|
// `jsdoc/check-examples` within `ash-nazg`)
|
|
|
|
{
|
2018-11-16 07:15:17 +00:00
|
|
|
files: ["**/*.md"],
|
|
|
|
rules: {
|
2018-11-08 06:48:01 +00:00
|
|
|
"eol-last": ["off"],
|
|
|
|
"no-console": ["off"],
|
|
|
|
"no-undef": ["off"],
|
|
|
|
"no-unused-vars": ["warn"],
|
|
|
|
"padded-blocks": ["off"],
|
|
|
|
"import/unambiguous": ["off"],
|
|
|
|
"import/no-unresolved": ["off"],
|
2019-05-22 15:37:27 +00:00
|
|
|
"node/no-missing-import": ["off"],
|
|
|
|
"no-multi-spaces": "off",
|
|
|
|
// Disable until may fix https://github.com/gajus/eslint-plugin-jsdoc/issues/211
|
|
|
|
"indent": "off"
|
2018-11-08 06:48:01 +00:00
|
|
|
}
|
|
|
|
},
|
2019-05-04 15:16:06 +00:00
|
|
|
// Dis-apply Node rules mistakenly giving errors with browser files,
|
|
|
|
// and treating Node global `root` as being present for shadowing
|
2018-11-08 06:48:01 +00:00
|
|
|
{
|
2019-05-04 15:16:06 +00:00
|
|
|
files: ["editor/**", "test/**", "screencasts/**"],
|
|
|
|
globals: {
|
|
|
|
root: "off"
|
|
|
|
},
|
2018-11-16 07:15:17 +00:00
|
|
|
rules: {
|
2019-05-04 15:16:06 +00:00
|
|
|
"node/no-unsupported-features/node-builtins": "off"
|
2018-11-08 06:48:01 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
// We want console in tests!
|
|
|
|
{
|
2018-11-16 07:15:17 +00:00
|
|
|
files: ["test/**"],
|
|
|
|
rules: {
|
2018-11-08 06:48:01 +00:00
|
|
|
"no-console": ["off"]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Node files
|
2018-11-16 07:15:17 +00:00
|
|
|
files: [
|
2018-11-08 06:48:01 +00:00
|
|
|
"docs/jsdoc-config.js",
|
|
|
|
"build-html.js", "jsdoc-check-overly-generic-types.js",
|
|
|
|
"rollup.config.js", "rollup-config.config.js"
|
|
|
|
],
|
2018-11-16 07:15:17 +00:00
|
|
|
env: {
|
|
|
|
node: true,
|
2018-11-08 06:48:01 +00:00
|
|
|
},
|
2019-05-04 15:16:06 +00:00
|
|
|
globals: {
|
|
|
|
require: true
|
|
|
|
},
|
2018-11-16 07:15:17 +00:00
|
|
|
rules: {
|
2019-05-04 15:16:06 +00:00
|
|
|
// We can't put Rollup in npmignore or user can't get access,
|
|
|
|
// and we have too many modules to add to `peerDependencies`
|
|
|
|
// so this rule can know them to be available, so we instead
|
|
|
|
// disable
|
|
|
|
"node/no-unpublished-import": "off"
|
2018-11-08 06:48:01 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// As consumed by jsdoc, cannot be expressed as ESM
|
2018-11-16 07:15:17 +00:00
|
|
|
files: ["docs/jsdoc-config.js"],
|
|
|
|
parserOptions: {
|
|
|
|
sourceType: "script"
|
2018-11-08 06:48:01 +00:00
|
|
|
},
|
2019-05-04 15:16:06 +00:00
|
|
|
globals: {
|
|
|
|
"module": false
|
|
|
|
},
|
2018-11-16 07:15:17 +00:00
|
|
|
rules: {
|
2019-05-04 15:16:06 +00:00
|
|
|
"import/no-commonjs": "off",
|
|
|
|
"strict": "off"
|
2018-11-08 06:48:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
2018-11-16 07:15:17 +00:00
|
|
|
rules: {
|
2018-11-08 06:48:01 +00:00
|
|
|
// Override these `ash-nazg/sauron` rules which are difficult for us
|
|
|
|
// to apply at this time
|
2019-03-31 09:39:19 +00:00
|
|
|
"default-case": "off",
|
|
|
|
"require-unicode-regexp": "off",
|
2018-11-08 06:48:01 +00:00
|
|
|
"max-len": ["off", {
|
2018-11-16 07:15:17 +00:00
|
|
|
ignoreUrls: true,
|
|
|
|
ignoreRegExpLiterals: true
|
2019-02-21 11:41:09 +00:00
|
|
|
}],
|
2019-03-31 09:39:19 +00:00
|
|
|
"unicorn/prefer-query-selector": "off",
|
|
|
|
"unicorn/prefer-node-append": "off",
|
2019-05-22 15:37:27 +00:00
|
|
|
"unicorn/no-zero-fractions": "off",
|
2019-05-24 06:44:57 +00:00
|
|
|
|
2019-05-24 06:51:57 +00:00
|
|
|
// Todo: Remove when ash-nazg removes
|
2019-05-24 06:44:57 +00:00
|
|
|
"valid-jsdoc": "off",
|
2019-05-24 06:51:57 +00:00
|
|
|
// Todo: Remove when ash-nazg adds (then also remove
|
|
|
|
// jsdoc-check-overly-generic-types.js file and npm script)
|
2019-05-24 06:44:57 +00:00
|
|
|
"jsdoc/require-returns-check": ["error"],
|
|
|
|
"jsdoc/match-description": ["error"],
|
2018-11-08 06:48:01 +00:00
|
|
|
}
|
|
|
|
};
|