- Linting (ESLint): Check eslintrc file itself
- Linting: Add linting plugins (mocha, chai-expect, chai-friendly, cypress) - Testing: Change cypress plugins file to ESM (so can set up any needed unit testing tasks)
This commit is contained in:
180
.eslintrc.js
180
.eslintrc.js
@@ -1,7 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
extends: ["ash-nazg/sauron-node"],
|
||||
extends: ['ash-nazg/sauron-node'],
|
||||
parserOptions: {
|
||||
sourceType: "module"
|
||||
sourceType: 'module'
|
||||
},
|
||||
env: {
|
||||
browser: true
|
||||
@@ -14,13 +16,13 @@ module.exports = {
|
||||
// In case we need to extend
|
||||
customTags: []
|
||||
},
|
||||
augmentsExtendsReplacesDocs: true,
|
||||
augmentsExtendsReplacesDocs: true
|
||||
// Todo: Figure out why this is not working and why seem to have to
|
||||
// disable for all Markdown:
|
||||
/*
|
||||
baseConfig: {
|
||||
rules: {
|
||||
"no-multi-spaces": "off"
|
||||
'no-multi-spaces': 'off'
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -30,30 +32,30 @@ module.exports = {
|
||||
// Locales have no need for importing outside of SVG-Edit
|
||||
{
|
||||
files: [
|
||||
"editor/locale/lang.*.js", "editor/extensions/ext-locale/**",
|
||||
"docs/tutorials/ExtensionDocs.md"
|
||||
'editor/locale/lang.*.js', 'editor/extensions/ext-locale/**',
|
||||
'docs/tutorials/ExtensionDocs.md'
|
||||
],
|
||||
rules: {
|
||||
"import/no-anonymous-default-export": ["off"]
|
||||
'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",
|
||||
"screencasts/svgopen2010/script.js"
|
||||
'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'
|
||||
],
|
||||
rules: {
|
||||
"import/unambiguous": ["off"]
|
||||
'import/unambiguous': ['off']
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ['**/*.html', 'screencasts/**'],
|
||||
globals: {
|
||||
root: "off"
|
||||
root: 'off'
|
||||
},
|
||||
settings: {
|
||||
polyfills: [
|
||||
@@ -66,10 +68,19 @@ module.exports = {
|
||||
'import/unambiguous': 'off'
|
||||
}
|
||||
},
|
||||
{
|
||||
files: '.eslintrc.js',
|
||||
extends: [
|
||||
'plugin:node/recommended-script'
|
||||
],
|
||||
rules: {
|
||||
'import/no-commonjs': 0
|
||||
}
|
||||
},
|
||||
// Our Markdown rules (and used for JSDoc examples as well, by way of
|
||||
// our use of `jsdoc/check-examples` within `ash-nazg`)
|
||||
{
|
||||
files: ["**/*.md"],
|
||||
files: ['**/*.md'],
|
||||
settings: {
|
||||
polyfills: [
|
||||
// Tutorials
|
||||
@@ -78,28 +89,28 @@ module.exports = {
|
||||
]
|
||||
},
|
||||
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"],
|
||||
"no-multi-spaces": "off",
|
||||
"sonarjs/no-all-duplicated-branches": "off",
|
||||
'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",
|
||||
'no-alert': 'off',
|
||||
// Disable until may fix https://github.com/gajus/eslint-plugin-jsdoc/issues/211
|
||||
"indent": "off"
|
||||
indent: 'off'
|
||||
}
|
||||
},
|
||||
// Dis-apply Node rules mistakenly giving errors with browser files,
|
||||
// and treating Node global `root` as being present for shadowing
|
||||
{
|
||||
files: ["editor/**"],
|
||||
files: ['editor/**'],
|
||||
globals: {
|
||||
root: "off"
|
||||
root: 'off'
|
||||
},
|
||||
settings: {
|
||||
polyfills: [
|
||||
@@ -141,14 +152,14 @@ module.exports = {
|
||||
]
|
||||
},
|
||||
rules: {
|
||||
"node/no-unsupported-features/node-builtins": "off"
|
||||
'node/no-unsupported-features/node-builtins': '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/**"],
|
||||
files: ['editor/extensions/**'],
|
||||
settings: {
|
||||
polyfills: [
|
||||
'console',
|
||||
@@ -158,19 +169,19 @@ module.exports = {
|
||||
]
|
||||
},
|
||||
rules: {
|
||||
"consistent-this": ["error", "svgEditor"],
|
||||
"import/no-anonymous-default-export": ["off"]
|
||||
'consistent-this': ['error', 'svgEditor'],
|
||||
'import/no-anonymous-default-export': ['off']
|
||||
}
|
||||
},
|
||||
{
|
||||
// Node files
|
||||
files: [
|
||||
"docs/jsdoc-config.js",
|
||||
"build/build-html.js",
|
||||
"rollup.config.js", "rollup-config.config.js"
|
||||
'docs/jsdoc-config.js',
|
||||
'build/build-html.js',
|
||||
'rollup.config.js', 'rollup-config.config.js'
|
||||
],
|
||||
env: {
|
||||
node: true,
|
||||
node: true
|
||||
},
|
||||
settings: {
|
||||
polyfills: [
|
||||
@@ -186,21 +197,21 @@ module.exports = {
|
||||
// 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"
|
||||
'node/no-unpublished-import': 'off'
|
||||
}
|
||||
},
|
||||
{
|
||||
// As consumed by jsdoc, cannot be expressed as ESM
|
||||
files: ["docs/jsdoc-config.js"],
|
||||
files: ['docs/jsdoc-config.js'],
|
||||
parserOptions: {
|
||||
sourceType: "script"
|
||||
sourceType: 'script'
|
||||
},
|
||||
globals: {
|
||||
"module": false
|
||||
module: false
|
||||
},
|
||||
rules: {
|
||||
"import/no-commonjs": "off",
|
||||
"strict": "off"
|
||||
'import/no-commonjs': 'off',
|
||||
strict: 'off'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -221,8 +232,22 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ["cypress/**"],
|
||||
extends: ["plugin:cypress/recommended"],
|
||||
files: ['cypress/plugins/index.js'],
|
||||
extends: [
|
||||
'plugin:node/recommended-script'
|
||||
],
|
||||
rules: {
|
||||
'import/no-commonjs': 0
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ['cypress/**'],
|
||||
extends: [
|
||||
'plugin:cypress/recommended',
|
||||
'plugin:mocha/recommended',
|
||||
'plugin:chai-friendly/recommended',
|
||||
'plugin:chai-expect/recommended'
|
||||
],
|
||||
env: {
|
||||
node: true
|
||||
},
|
||||
@@ -239,54 +264,73 @@ module.exports = {
|
||||
]
|
||||
},
|
||||
rules: {
|
||||
// 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,
|
||||
|
||||
// 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,
|
||||
|
||||
// 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,
|
||||
'import/unambiguous': 0
|
||||
}
|
||||
}
|
||||
],
|
||||
rules: {
|
||||
// https://github.com/sindresorhus/eslint-plugin-unicorn/issues/453
|
||||
"unicorn/regex-shorthand": 0,
|
||||
'unicorn/regex-shorthand': 0,
|
||||
// The Babel transform seems to have a problem converting these
|
||||
"prefer-named-capture-group": "off",
|
||||
'prefer-named-capture-group': 'off',
|
||||
// Override these `ash-nazg/sauron` rules which are difficult for us
|
||||
// to apply at this time
|
||||
"unicorn/prefer-string-slice": "off",
|
||||
"default-case": "off",
|
||||
"require-unicode-regexp": "off",
|
||||
"max-len": ["off", {
|
||||
'unicorn/prefer-string-slice': 'off',
|
||||
'default-case': 'off',
|
||||
'require-unicode-regexp': 'off',
|
||||
'max-len': ['off', {
|
||||
ignoreUrls: true,
|
||||
ignoreRegExpLiterals: true
|
||||
}],
|
||||
"unicorn/prefer-query-selector": "off",
|
||||
"unicorn/prefer-node-append": "off",
|
||||
"unicorn/no-zero-fractions": "off",
|
||||
"jsdoc/require-file-overview": ["error", {
|
||||
'unicorn/prefer-query-selector': 'off',
|
||||
'unicorn/prefer-node-append': 'off',
|
||||
'unicorn/no-zero-fractions': 'off',
|
||||
'jsdoc/require-file-overview': ['error', {
|
||||
tags: {
|
||||
file: {
|
||||
"initialCommentsOnly": true,
|
||||
"preventDuplicates": true,
|
||||
initialCommentsOnly: true,
|
||||
preventDuplicates: true
|
||||
},
|
||||
license: {
|
||||
"initialCommentsOnly": true,
|
||||
"preventDuplicates": true,
|
||||
initialCommentsOnly: true,
|
||||
preventDuplicates: true
|
||||
},
|
||||
copyright: {
|
||||
"initialCommentsOnly": true,
|
||||
"preventDuplicates": true,
|
||||
initialCommentsOnly: true,
|
||||
preventDuplicates: true
|
||||
},
|
||||
author: {
|
||||
"initialCommentsOnly": true,
|
||||
"preventDuplicates": true,
|
||||
initialCommentsOnly: true,
|
||||
preventDuplicates: true
|
||||
},
|
||||
module: {
|
||||
"initialCommentsOnly": true,
|
||||
"preventDuplicates": true,
|
||||
initialCommentsOnly: true,
|
||||
preventDuplicates: true
|
||||
},
|
||||
exports: {
|
||||
"initialCommentsOnly": true,
|
||||
"preventDuplicates": true,
|
||||
initialCommentsOnly: true,
|
||||
preventDuplicates: true
|
||||
}
|
||||
}
|
||||
}]
|
||||
|
||||
Reference in New Issue
Block a user