2020-02-21 08:34:55 +00:00
|
|
|
'use strict';
|
|
|
|
|
2018-11-08 06:48:01 +00:00
|
|
|
module.exports = {
|
2020-02-21 08:34:55 +00:00
|
|
|
extends: ['ash-nazg/sauron-node'],
|
2018-11-16 07:15:17 +00:00
|
|
|
parserOptions: {
|
2020-02-21 08:34:55 +00:00
|
|
|
sourceType: 'module'
|
2018-11-08 06:48:01 +00:00
|
|
|
},
|
2018-11-16 07:15:17 +00:00
|
|
|
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: [
|
|
|
|
],
|
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
|
|
|
},
|
2020-02-21 08:34:55 +00:00
|
|
|
augmentsExtendsReplacesDocs: true
|
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: {
|
2020-02-21 08:34:55 +00:00
|
|
|
'no-multi-spaces': 'off'
|
2019-05-23 00:55:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
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: [
|
2020-02-21 08:34:55 +00:00
|
|
|
'editor/locale/lang.*.js', 'editor/extensions/ext-locale/**',
|
|
|
|
'docs/tutorials/ExtensionDocs.md'
|
2018-11-08 06:48:01 +00:00
|
|
|
],
|
2018-11-16 07:15:17 +00:00
|
|
|
rules: {
|
2020-02-21 08:34:55 +00:00
|
|
|
'import/no-anonymous-default-export': ['off']
|
2018-11-08 06:48:01 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
// These browser files don't do importing or requiring
|
|
|
|
{
|
2018-11-16 07:15:17 +00:00
|
|
|
files: [
|
2020-02-21 08:34:55 +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',
|
|
|
|
'screencasts/svgopen2010/script.js'
|
2018-11-08 06:48:01 +00:00
|
|
|
],
|
2018-11-16 07:15:17 +00:00
|
|
|
rules: {
|
2020-02-21 08:34:55 +00:00
|
|
|
'import/unambiguous': ['off']
|
2018-11-08 06:48:01 +00:00
|
|
|
}
|
|
|
|
},
|
2019-07-02 04:21:21 +00:00
|
|
|
{
|
2020-01-06 14:51:29 +00:00
|
|
|
files: ['**/*.html', 'screencasts/**'],
|
|
|
|
globals: {
|
2020-02-21 08:34:55 +00:00
|
|
|
root: 'off'
|
2020-01-06 14:51:29 +00:00
|
|
|
},
|
|
|
|
settings: {
|
|
|
|
polyfills: [
|
|
|
|
'document.querySelector',
|
|
|
|
'history.pushState',
|
|
|
|
'history.replaceState'
|
|
|
|
]
|
|
|
|
},
|
2019-07-02 04:21:21 +00:00
|
|
|
rules: {
|
|
|
|
'import/unambiguous': 'off'
|
|
|
|
}
|
|
|
|
},
|
2020-02-21 08:34:55 +00:00
|
|
|
{
|
2020-02-22 03:38:33 +00:00
|
|
|
files: ['.eslintrc.js', '.ncurc.js'],
|
2020-02-21 08:34:55 +00:00
|
|
|
extends: [
|
|
|
|
'plugin:node/recommended-script'
|
|
|
|
],
|
|
|
|
rules: {
|
|
|
|
'import/no-commonjs': 0
|
|
|
|
}
|
|
|
|
},
|
2018-11-08 06:48:01 +00:00
|
|
|
// Our Markdown rules (and used for JSDoc examples as well, by way of
|
2020-01-02 11:52:46 +00:00
|
|
|
// our use of `jsdoc/check-examples` within `ash-nazg`)
|
2018-11-08 06:48:01 +00:00
|
|
|
{
|
2020-02-21 08:34:55 +00:00
|
|
|
files: ['**/*.md'],
|
2020-01-06 14:51:29 +00:00
|
|
|
settings: {
|
|
|
|
polyfills: [
|
|
|
|
// Tutorials
|
|
|
|
'console',
|
|
|
|
'location.href'
|
|
|
|
]
|
|
|
|
},
|
2018-11-16 07:15:17 +00:00
|
|
|
rules: {
|
2020-02-26 06:34:42 +00:00
|
|
|
// Todo: Figure out why this is not enough to disable warning
|
|
|
|
// for examples
|
|
|
|
// Used in examples of assert-close.js plugin
|
|
|
|
'mocha-cleanup/no-assertions-outside-it': 'off',
|
|
|
|
|
2020-02-21 08:34:55 +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'],
|
|
|
|
'node/no-missing-import': ['off'],
|
|
|
|
'no-multi-spaces': 'off',
|
|
|
|
'sonarjs/no-all-duplicated-branches': 'off',
|
2019-11-23 13:02:51 +00:00
|
|
|
'node/no-unpublished-import': ['error', {allowModules: ['@cypress/fiddle']}],
|
2020-02-21 08:34:55 +00:00
|
|
|
'no-alert': 'off',
|
2019-05-22 15:37:27 +00:00
|
|
|
// Disable until may fix https://github.com/gajus/eslint-plugin-jsdoc/issues/211
|
2020-02-21 08:34:55 +00:00
|
|
|
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
|
|
|
{
|
2020-02-21 08:34:55 +00:00
|
|
|
files: ['editor/**'],
|
2019-05-04 15:16:06 +00:00
|
|
|
globals: {
|
2020-02-21 08:34:55 +00:00
|
|
|
root: 'off'
|
2019-05-04 15:16:06 +00:00
|
|
|
},
|
2020-01-06 14:51:29 +00:00
|
|
|
settings: {
|
|
|
|
polyfills: [
|
|
|
|
// These are the primary polyfills needed by regular users if not present,
|
|
|
|
// e.g., with core-js-bundle; also those under extensions
|
|
|
|
'Array.isArray',
|
|
|
|
'Blob',
|
|
|
|
'console',
|
|
|
|
'CustomEvent',
|
|
|
|
'document.body',
|
|
|
|
'document.evaluate',
|
|
|
|
'document.head',
|
|
|
|
'document.importNode',
|
|
|
|
'document.querySelectorAll',
|
|
|
|
'DOMParser',
|
|
|
|
'Error',
|
|
|
|
'FileReader',
|
|
|
|
'JSON',
|
|
|
|
'location.href',
|
|
|
|
'MutationObserver',
|
|
|
|
'Object.assign',
|
|
|
|
'Object.defineProperty',
|
|
|
|
'Object.defineProperties',
|
|
|
|
'Object.entries',
|
|
|
|
'Object.getOwnPropertyDescriptor',
|
|
|
|
'Object.keys',
|
|
|
|
'Object.values',
|
|
|
|
'Promise',
|
|
|
|
'Promise.all',
|
|
|
|
'Set',
|
|
|
|
'Uint8Array',
|
|
|
|
'URL',
|
|
|
|
'URL.createObjectURL',
|
|
|
|
'XMLSerializer',
|
|
|
|
'XMLHttpRequest',
|
|
|
|
'window.getComputedStyle',
|
|
|
|
'window.scrollX',
|
|
|
|
'window.scrollY'
|
|
|
|
]
|
|
|
|
},
|
2018-11-16 07:15:17 +00:00
|
|
|
rules: {
|
2020-02-21 08:34:55 +00:00
|
|
|
'node/no-unsupported-features/node-builtins': 'off'
|
2018-11-08 06:48:01 +00:00
|
|
|
}
|
|
|
|
},
|
2020-01-06 14:51:29 +00:00
|
|
|
// For extensions, `this` is generally assigned to be the more
|
|
|
|
// descriptive `svgEditor`; they also have no need for importing outside
|
|
|
|
// of SVG-Edit
|
|
|
|
{
|
2020-02-21 08:34:55 +00:00
|
|
|
files: ['editor/extensions/**'],
|
2020-01-06 14:51:29 +00:00
|
|
|
settings: {
|
|
|
|
polyfills: [
|
|
|
|
'console',
|
|
|
|
'fetch',
|
|
|
|
'location.origin',
|
|
|
|
'window.postMessage'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
rules: {
|
2020-02-21 08:34:55 +00:00
|
|
|
'consistent-this': ['error', 'svgEditor'],
|
|
|
|
'import/no-anonymous-default-export': ['off']
|
2020-01-06 14:51:29 +00:00
|
|
|
}
|
|
|
|
},
|
2018-11-08 06:48:01 +00:00
|
|
|
{
|
|
|
|
// Node files
|
2018-11-16 07:15:17 +00:00
|
|
|
files: [
|
2020-02-21 08:34:55 +00:00
|
|
|
'docs/jsdoc-config.js',
|
|
|
|
'build/build-html.js',
|
|
|
|
'rollup.config.js', 'rollup-config.config.js'
|
2018-11-08 06:48:01 +00:00
|
|
|
],
|
2018-11-16 07:15:17 +00:00
|
|
|
env: {
|
2020-02-21 08:34:55 +00:00
|
|
|
node: true
|
2018-11-08 06:48:01 +00:00
|
|
|
},
|
2020-01-06 14:51:29 +00:00
|
|
|
settings: {
|
|
|
|
polyfills: [
|
|
|
|
'console',
|
|
|
|
'Promise.resolve'
|
|
|
|
]
|
|
|
|
},
|
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
|
2020-02-21 08:34:55 +00:00
|
|
|
'node/no-unpublished-import': 'off'
|
2018-11-08 06:48:01 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// As consumed by jsdoc, cannot be expressed as ESM
|
2020-02-21 08:34:55 +00:00
|
|
|
files: ['docs/jsdoc-config.js'],
|
2018-11-16 07:15:17 +00:00
|
|
|
parserOptions: {
|
2020-02-21 08:34:55 +00:00
|
|
|
sourceType: 'script'
|
2018-11-08 06:48:01 +00:00
|
|
|
},
|
2019-05-04 15:16:06 +00:00
|
|
|
globals: {
|
2020-02-21 08:34:55 +00:00
|
|
|
module: false
|
2019-05-04 15:16:06 +00:00
|
|
|
},
|
2018-11-16 07:15:17 +00:00
|
|
|
rules: {
|
2020-02-21 08:34:55 +00:00
|
|
|
'import/no-commonjs': 'off',
|
|
|
|
strict: 'off'
|
2018-11-08 06:48:01 +00:00
|
|
|
}
|
2019-11-23 13:02:51 +00:00
|
|
|
},
|
2019-11-25 00:40:37 +00:00
|
|
|
{
|
|
|
|
extends: ['plugin:node/recommended-script'],
|
2019-12-21 07:35:19 +00:00
|
|
|
files: [
|
|
|
|
'cypress/support/build-coverage-badge.js',
|
|
|
|
'build/testing-badge.js'
|
|
|
|
]
|
2019-11-25 00:40:37 +00:00
|
|
|
},
|
2020-01-06 14:51:29 +00:00
|
|
|
{
|
|
|
|
// Should probably have as external, but should still check
|
|
|
|
files: ['canvg/rgbcolor.js'],
|
|
|
|
settings: {
|
|
|
|
polyfills: [
|
|
|
|
'Object.assign',
|
|
|
|
'Object.keys'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2019-11-23 13:02:51 +00:00
|
|
|
{
|
2020-02-21 08:34:55 +00:00
|
|
|
files: ['cypress/plugins/index.js'],
|
|
|
|
extends: [
|
|
|
|
'plugin:node/recommended-script'
|
|
|
|
],
|
|
|
|
rules: {
|
|
|
|
'import/no-commonjs': 0
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: ['cypress/**'],
|
|
|
|
extends: [
|
|
|
|
'plugin:cypress/recommended',
|
|
|
|
'plugin:mocha/recommended',
|
2020-02-26 06:34:42 +00:00
|
|
|
'plugin:mocha-cleanup/recommended-no-limits',
|
|
|
|
'plugin:@fintechstudios/chai-as-promised/recommended',
|
|
|
|
'plugin:chai-expect-keywords/recommended',
|
|
|
|
'plugin:chai-expect/recommended',
|
|
|
|
'plugin:chai-friendly/recommended'
|
2020-02-21 08:34:55 +00:00
|
|
|
],
|
2019-11-23 13:02:51 +00:00
|
|
|
env: {
|
|
|
|
node: true
|
|
|
|
},
|
2020-01-06 14:51:29 +00:00
|
|
|
settings: {
|
|
|
|
polyfills: [
|
|
|
|
'console',
|
|
|
|
'Date.now',
|
|
|
|
'document.body',
|
|
|
|
'document.head',
|
|
|
|
'DOMParser',
|
|
|
|
'Object.keys',
|
|
|
|
'Object.entries',
|
|
|
|
'Promise'
|
|
|
|
]
|
|
|
|
},
|
2019-11-23 13:02:51 +00:00
|
|
|
rules: {
|
2020-02-26 06:34:42 +00:00
|
|
|
'chai-expect-keywords/no-unsupported-keywords': [
|
|
|
|
'error', {
|
|
|
|
allowChaiDOM: true
|
|
|
|
}
|
|
|
|
],
|
2020-02-21 08:34:55 +00:00
|
|
|
// Would be good but seems necessary due to some bugs in Cypress
|
|
|
|
// in detecting visibility
|
|
|
|
// 'cypress/no-force': 0,
|
|
|
|
// Good but would be difficult to enforce (and data-* may not be less
|
|
|
|
// brittle than IDs/classes anyways)
|
|
|
|
// 'cypress/require-data-selectors': 0,
|
|
|
|
'cypress/assertion-before-screenshot': 2,
|
|
|
|
|
2020-02-26 06:34:42 +00:00
|
|
|
// Conflicts with Cypress `should`
|
|
|
|
'mocha-cleanup/invalid-assertions': 0,
|
|
|
|
|
2020-02-28 11:08:16 +00:00
|
|
|
// Might see about working around to avoid the option limitation,
|
|
|
|
// but convenient
|
|
|
|
'mocha-cleanup/no-expressions-in-assertions': ['error', {
|
|
|
|
replacementsOnly: true
|
|
|
|
}],
|
2020-02-26 06:34:42 +00:00
|
|
|
|
2020-02-21 08:34:55 +00:00
|
|
|
// Too oppressive when planning to extend a section
|
|
|
|
'mocha/no-hooks-for-single-case': 0,
|
|
|
|
|
|
|
|
// Would be good to enable but needs some refactoring
|
|
|
|
'mocha/no-setup-in-describe': 0,
|
2020-02-26 06:34:42 +00:00
|
|
|
'mocha-cleanup/no-outside-declaration': 0,
|
2020-02-21 08:34:55 +00:00
|
|
|
|
|
|
|
// Useful to ensure allowing `this.timeout()`, etc., but a little oppressive
|
|
|
|
'mocha/no-mocha-arrows': 0,
|
|
|
|
// Useful if enabling the regular `prefer-arrow-callback`
|
|
|
|
// 'mocha/prefer-arrow-callback': 2
|
|
|
|
|
2020-01-29 04:09:42 +00:00
|
|
|
'jsdoc/require-jsdoc': 0,
|
2019-11-24 03:29:24 +00:00
|
|
|
'no-console': 0,
|
2020-02-21 08:34:55 +00:00
|
|
|
'import/unambiguous': 0
|
2019-11-23 13:02:51 +00:00
|
|
|
}
|
2018-11-08 06:48:01 +00:00
|
|
|
}
|
|
|
|
],
|
2018-11-16 07:15:17 +00:00
|
|
|
rules: {
|
2019-11-30 03:41:01 +00:00
|
|
|
// https://github.com/sindresorhus/eslint-plugin-unicorn/issues/453
|
2020-02-21 08:34:55 +00:00
|
|
|
'unicorn/regex-shorthand': 0,
|
2019-11-16 02:08:38 +00:00
|
|
|
// The Babel transform seems to have a problem converting these
|
2020-02-21 08:34:55 +00:00
|
|
|
'prefer-named-capture-group': 'off',
|
2018-11-08 06:48:01 +00:00
|
|
|
// Override these `ash-nazg/sauron` rules which are difficult for us
|
|
|
|
// to apply at this time
|
2020-02-21 08:34:55 +00:00
|
|
|
'unicorn/prefer-string-slice': 'off',
|
|
|
|
'default-case': 'off',
|
|
|
|
'require-unicode-regexp': 'off',
|
|
|
|
'max-len': ['off', {
|
2018-11-16 07:15:17 +00:00
|
|
|
ignoreUrls: true,
|
|
|
|
ignoreRegExpLiterals: true
|
2019-02-21 11:41:09 +00:00
|
|
|
}],
|
2020-02-21 08:34:55 +00:00
|
|
|
'unicorn/prefer-query-selector': 'off',
|
|
|
|
'unicorn/prefer-node-append': 'off',
|
|
|
|
'unicorn/no-zero-fractions': 'off',
|
|
|
|
'jsdoc/require-file-overview': ['error', {
|
2019-12-31 17:15:16 +00:00
|
|
|
tags: {
|
|
|
|
file: {
|
2020-02-21 08:34:55 +00:00
|
|
|
initialCommentsOnly: true,
|
|
|
|
preventDuplicates: true
|
2019-12-31 17:15:16 +00:00
|
|
|
},
|
|
|
|
license: {
|
2020-02-21 08:34:55 +00:00
|
|
|
initialCommentsOnly: true,
|
|
|
|
preventDuplicates: true
|
2019-12-31 17:15:16 +00:00
|
|
|
},
|
|
|
|
copyright: {
|
2020-02-21 08:34:55 +00:00
|
|
|
initialCommentsOnly: true,
|
|
|
|
preventDuplicates: true
|
2019-12-31 17:15:16 +00:00
|
|
|
},
|
|
|
|
author: {
|
2020-02-21 08:34:55 +00:00
|
|
|
initialCommentsOnly: true,
|
|
|
|
preventDuplicates: true
|
2019-12-31 17:15:16 +00:00
|
|
|
},
|
|
|
|
module: {
|
2020-02-21 08:34:55 +00:00
|
|
|
initialCommentsOnly: true,
|
|
|
|
preventDuplicates: true
|
2019-12-31 17:15:16 +00:00
|
|
|
},
|
|
|
|
exports: {
|
2020-02-21 08:34:55 +00:00
|
|
|
initialCommentsOnly: true,
|
|
|
|
preventDuplicates: true
|
2019-12-31 17:15:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}]
|
2018-11-08 06:48:01 +00:00
|
|
|
}
|
|
|
|
};
|