restore all eslint rules

master
JFH 2020-08-01 01:23:28 +02:00
parent 137516caba
commit 92635ba721
13 changed files with 224 additions and 15 deletions

View File

@ -3,7 +3,7 @@
module.exports = {
extends: ['ash-nazg/sauron-node'],
parserOptions: {
"ecmaVersion": 2020,
ecmaVersion: 2020,
sourceType: 'module'
},
env: {
@ -51,7 +51,7 @@ module.exports = {
'Promise.all',
// 'Set',
'Uint8Array',
'URL',
'URL'
// 'URL.createObjectURL',
// 'XMLSerializer',
// 'XMLHttpRequest',
@ -107,7 +107,11 @@ module.exports = {
'unicorn/prefer-string-slice': 'off',
'default-case': 'off',
'require-unicode-regexp': 'off',
'max-len': ['warn', { 'ignoreComments': true, 'code': 130 }], // 130 is too much but too many occurences
'max-len':
[
'warn',
{ignoreComments: true, code: 130}
], // 130 is too much but too many occurences
'unicorn/prefer-query-selector': 'off',
'unicorn/no-fn-reference-in-iterator': 'off',
'unicorn/prefer-node-append': 'off',
@ -117,8 +121,8 @@ module.exports = {
'compat/compat': 'error',
'consistent-this': 'off',
'import/no-anonymous-default-export': 'off',
'node/no-unsupported-features/node-builtins': 'warn',
'prefer-exponentiation-operator': 'warn'
'node/no-unsupported-features/node-builtins': 'warn',
'prefer-exponentiation-operator': 'warn'
},
overrides: [
// Locales have no need for importing outside of SVG-Edit
@ -132,6 +136,206 @@ module.exports = {
'import/no-anonymous-default-export': 'off',
'max-len': 'off'
}
},
// These browser files don't do importing or requiring
{
files: [
'src/editor/svgpathseg.js',
'src/editor/touch.js',
'src/editor/typedefs.js',
'src/editor/redirect-on-no-module-support.js',
'src/editor/extensions/imagelib/index.js',
'src/external/dom-polyfill/dom-polyfill.js',
'screencasts/svgopen2010/script.js'
],
rules: {
'import/unambiguous': ['off']
}
},
{
files: ['**/*.html', 'screencasts/**'],
globals: {
root: 'off'
},
settings: {
polyfills: [
'document.querySelector',
'history',
'history.pushState',
'history.replaceState',
'location.hash',
'navigator',
'Number.parseFloat',
'Number.parseInt',
'Number.isNaN'
]
},
rules: {
'import/unambiguous': 'off'
}
},
{
files: ['.eslintrc.js', '.ncurc.js', 'tools/mochawesome-cli.js'],
extends: [
'ash-nazg/sauron-node-script'
]
},
// Our Markdown rules (and used for JSDoc examples as well, by way of
// our use of `jsdoc/check-examples` within `ash-nazg`)
{
files: ['**/*.md'],
settings: {
polyfills: [
// Tutorials
'console',
'location.href'
]
},
rules: {
// Todo: Figure out why this is not enough to disable warning
// for examples in my environment (but it is in others')
// Used in examples of assert-close.js plugin
'mocha-cleanup/no-assertions-outside-it': 'off',
'eslint-comments/no-unused-disable': 'warn',
'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',
'node/no-unpublished-import': ['error', {
allowModules: ['@cypress/fiddle']
}],
'no-alert': 'off',
// Disable until may fix https://github.com/gajus/eslint-plugin-jsdoc/issues/211
indent: 'off'
}
},
{
// As consumed by jsdoc, cannot be expressed as ESM
files: ['docs/jsdoc-config.js'],
parserOptions: {
sourceType: 'script'
},
globals: {
module: false
},
rules: {
'import/no-commonjs': 'off',
strict: 'off'
}
},
{
files: ['cypress/plugins/index.js'],
extends: [
'ash-nazg/sauron-node-script'
]
},
{
files: ['cypress/**'],
extends: [
'plugin:cypress/recommended',
'plugin:mocha/recommended',
'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'
],
env: {
node: true
},
settings: {
polyfills: [
'console',
'Date.now',
'document.body',
'document.createElementNS',
'document.head',
'DOMParser',
'Number.isNaN',
'Object.keys',
'Object.entries',
'Promise'
]
},
rules: {
// These errors are caused in Cypress files if user has not
// yet instrumented code; need to reinvestigate why we had to
// instrument separately from nyc mocha
'import/no-unresolved': ['error', {ignore: ['/instrumented/']}],
'node/no-missing-import': 'off',
'jsdoc/check-examples': 'off',
'chai-expect-keywords/no-unsupported-keywords': [
'error', {
allowChaiDOM: true
}
],
// 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,
// Conflicts with Cypress `should`
'mocha-cleanup/invalid-assertions': 0,
// Might see about working around to avoid the option limitation,
// but convenient
'mocha-cleanup/no-expressions-in-assertions': ['error', {
replacementsOnly: true
}],
// 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,
'mocha-cleanup/no-outside-declaration': 0,
// 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
'jsdoc/require-jsdoc': 0,
'no-console': 0,
'import/unambiguous': 0
}
},
{
// Node files
files: [
'docs/jsdoc-config.js',
'build/build-html.js',
'rollup.config.js', 'rollup-config.config.js'
],
env: {
node: true
},
settings: {
polyfills: [
'console',
'Promise.resolve'
]
},
globals: {
require: true
},
rules: {
// 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'
}
}
]
};

View File

@ -29,11 +29,12 @@ describe('UI - Accessibility', function () {
{},
{
rules: {
'label-title-only': { enabled: false },
'page-has-heading-one': { enabled: false },
'region': { enabled: false },
'scrollable-region-focusable': { enabled: false },
'label-title-only': {enabled: false},
'page-has-heading-one': {enabled: false},
region: {enabled: false},
'scrollable-region-focusable': {enabled: false}
}
});
}
);
});
});

View File

@ -20,6 +20,7 @@ describe('draw.Drawing', function () {
const PATH_ATTR = {
// clone will convert relative to absolute, so the test for equality fails.
// d: 'm7.38867,57.38867c0,-27.62431 22.37569,-50 50,-50c27.62431,0 50,22.37569 50,50c0,27.62431 -22.37569,50 -50,50c-27.62431,0 -50,-22.37569 -50,-50z',
// eslint-disable-next-line max-len
d: 'M7.389,57.389C7.389,29.764 29.764,7.389 57.389,7.389C85.013,7.389 107.389,29.764 107.389,57.389C107.389,85.013 85.013,107.389 57.389,107.389C29.764,107.389 7.389,85.013 7.389,57.389z',
transform: 'rotate(45 57.388671875000036,57.388671874999986) ',
'stroke-width': '5',

View File

@ -1,3 +1,4 @@
/* eslint-disable max-len */
import '../../../instrumented/editor/jquery.min.js';
import '../../../instrumented/editor/jquery-ui/jquery-ui-1.8.17.custom.min.js';

View File

@ -1,3 +1,4 @@
/* eslint-disable max-len */
import '../../../instrumented/editor/jquery.min.js';
import '../../../instrumented/common/svgpathseg.js';

View File

@ -1,3 +1,4 @@
/* eslint-disable max-len */
import '../../../instrumented/editor/jquery.min.js';
import '../../../instrumented/common/svgpathseg.js';

View File

@ -1,3 +1,4 @@
/* eslint-disable max-len */
import '../../../instrumented/editor/jquery.min.js';
import * as browser from '../../../instrumented/common/browser.js';

View File

@ -3,7 +3,6 @@
import codeCoverageTask from '@cypress/code-coverage/task.js';
// eslint-disable-next-line import/no-anonymous-default-export
export default (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config

View File

@ -1,3 +1,4 @@
/* eslint-disable max-len */
import assertionWrapper from './assertion-wrapper.js';
/**

View File

@ -65,6 +65,7 @@ module.exports = {
'screencasts',
'test'
],
// eslint-disable-next-line max-len
excludePattern: 'svgedit-config-*|build-html.js|rollup*|external/babel-polyfill|extensions/mathjax|imagelib/jquery.min.js|jspdf/jspdf.min.js|jspdf/underscore-min.js|jquery-ui|jquery.min.js|js-hotkeys'
},
sourceType: 'module',

View File

@ -50,7 +50,7 @@
"remark": "remark -q -f .",
"build-html": "babel-node --plugins @babel/plugin-transform-modules-commonjs build/build-html.js",
"eslint-fix": "eslint --fix --ext js,md,html src",
"eslint": "eslint --ext js,html src",
"eslint": "eslint --ext js,html,md .",
"rollup": "rollup -c",
"build-by-config": "rollup -c rollup-config.config.js",
"prep-no-core-rollup": "run-s eslint build-html build-by-config",

View File

@ -34,7 +34,6 @@ window.svgEditor.modules = false;
})
];
/* eslint-disable import/no-anonymous-default-export */
export default [
{
input: 'svgedit-config-es.js',
@ -53,4 +52,3 @@ export default [
plugins
}
];
/* eslint-enable import/no-anonymous-default-export */

View File

@ -49,7 +49,7 @@ This will return the icon (as jQuery object) with a given ID.
// events for each icon
$.each(icons, function (id, icon) {
icon.click(function () {
alert('You clicked on the icon with id ' + id); // eslint-disable-line no-alert
alert('You clicked on the icon with id ' + id);
});
});
}