svgedit/.eslintrc.js

155 lines
4.6 KiB
JavaScript
Raw Normal View History

- Breaking change: `loadSvgString` now returns a `Promise` rather than accepting a callback - Breaking change: Treat callbacks to `editor.ready` as Promises, only resolving after all resolve - Breaking change: Make `editor.runCallbacks` return a `Promise` which resolves upon all callbacks resolving - Breaking change: Require `npx` (used with `babel-node`) to allow Node files for HTML building and JSDoc type checking to be expressed as ESM. - Breaking change: `addExtension` now throws upon a repeated attempt to add an already-added extension - Breaking change (storage preference cookies): Namespace the cookie as "svgeditstore" instead of just "store" - Breaking change (API): Remove `svgCanvas.rasterExport` fourth (callback) argument, collapsing fifth (options) to fourth - Breaking change (API): Remove `svgCanvas.exportPDF` third (callback) argument - Breaking change (API): `editor/contextmenu.js` `add` now throws instead of giving a console error only upon detecting a bad menuitem or preexisting context menu - Breaking change (API): Remove `svgCanvas.embedImage` second (callback) argument - Breaking change (API): Make `getHelpXML` a class instead of instance method of `RGBColor` - Breaking change (internal API): Refactor `dbox` (and `alert`/`confirm`/`process`/`prompt`/`select`) to avoid a callback argument in favor of return a Promise - Fix: Avoid running in extension `langReady` multiple times or serially - Enhancement (API): Add svgCanvas.runExtension to run just one extension and add `nameFilter` callback to `runExtensions` - Enhancement (API): Supply `$` (our wrapped jQuery) to extensions so can use its plugins, e.g., dbox with its `alert` - Enhancement: Use alert dialog in place of `alert` in webappfind - Enhancement: `editor.ready` now returns a Promise resolving when all callbacks have resolved - Enhancement: Allow `noAlert` option as part of second argument to `loadSvgString` (and `loadFromURL` and `loadFromDataURI`) to avoid UI alert (and trigger promise rejection) - Enhancement: Make `dbox` as a separate module for alert, prompt, etc. dialogs - Refactoring: Internal `PaintBox` as class; other misc. tweaks; no bitwise in canvg - Linting (ESLint): Further linting changes (for editor); rename `.eslintrc` -> `.eslintrc.json` per recommendation - Optimization: Recompress images (imageoptim-cli updated) - npm: Update devDeps - npm: Bump to 4.0.0
2018-11-08 06:48:01 +00:00
module.exports = {
"extends": [
"ash-nazg/sauron-node",
"plugin:qunit/recommended", "plugin:testcafe/recommended"
],
"parserOptions": {
"sourceType": "module"
},
// Need to make explicit here for processing by jsdoc/check-examples
"plugins": ["qunit"],
"env": {
"browser": true
},
"settings": {
"polyfills": ["url", "promises", "fetch", "queryselector"],
"jsdoc": {
"additionalTagNames": {
// In case we need to extend
"customTags": []
},
"tagNamePreference": {
"arg": "param",
"return": "returns"
},
"allowOverrideWithoutParam": true,
"allowImplementsWithoutParam": true,
"allowAugmentsExtendsWithoutParam": true,
// For `jsdoc/check-examples` in `ash-nazg`
"matchingFileName": "dummy.md",
"rejectExampleCodeRegex": "^`",
}
},
"overrides": [
// These would otherwise currently break because of these issues:
// 1. `event:` https://github.com/eslint/doctrine/issues/221 and https://github.com/Kuniwak/jsdoctypeparser/pull/49 with https://github.com/Kuniwak/jsdoctypeparser/issues/47
// 1. `@implements`/`@augments`/`@extends`/`@override`: https://github.com/eslint/doctrine/issues/222
{
"files": [
"test/utilities_test.js", "editor/svg-editor.js", "editor/svgcanvas.js",
"editor/coords.js",
"editor/extensions/ext-eyedropper.js", "editor/extensions/ext-webappfind.js"
],
"rules": {
"jsdoc/valid-types": "off",
"valid-jsdoc": "off"
}
},
// Locales have no need for importing outside of SVG-Edit
{
"files": [
"editor/locale/lang.*.js", "editor/extensions/ext-locale/**",
"docs/tutorials/ExtensionDocs.md"
],
"rules": {
"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
{
"files": ["editor/extensions/**/ext-*.js"],
"rules": {
"consistent-this": ["error", "svgEditor"],
"import/no-anonymous-default-export": ["off"]
}
},
// These browser files don't do importing or requiring
{
"files": [
"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"
],
"rules": {
"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`)
{
"files": ["**/*.md"],
"rules": {
"eol-last": ["off"],
"no-console": ["off"],
"no-undef": ["off"],
"no-unused-vars": ["warn"],
"padded-blocks": ["off"],
"import/unambiguous": ["off"],
"import/no-unresolved": ["off"],
"node/no-missing-import": ["off"]
}
},
// Dis-apply Node rules mistakenly giving errors with browser files
{
"files": ["editor/**", "test/**"],
"rules": {
"node/no-unsupported-features/node-builtins": ["off"]
}
},
// We want console in tests!
{
"files": ["test/**"],
"rules": {
"no-console": ["off"]
}
},
{
// Node files
"files": [
"docs/jsdoc-config.js",
"build-html.js", "jsdoc-check-overly-generic-types.js",
"rollup.config.js", "rollup-config.config.js"
],
"env": {
"node": true,
},
"rules": {
"node/no-unpublished-import": ["off"],
"node/no-unsupported-features/es-syntax": ["off"]
}
},
{
// As consumed by jsdoc, cannot be expressed as ESM
"files": ["docs/jsdoc-config.js"],
"parserOptions": {
"sourceType": "script"
},
"rules": {
"import/no-commonjs": "off"
}
}
],
"rules": {
// Override these `ash-nazg/sauron` rules which are difficult for us
// to apply at this time
"capitalized-comments": ["off"],
"complexity": ["off"],
"default-case": ["off"],
"require-unicode-regexp": ["off"],
"no-magic-numbers": ["off"],
"no-warning-comments": ["off"],
"max-len": ["off", {
"ignoreUrls": true,
"ignoreRegExpLiterals": true
}]
}
};