Provide custom messages for the no-restricted-globals ESLint rule, and refactor the .eslintrc files (PR 9868 follow-up)

Without providing useful (custom) error messages for the `no-restricted-globals` rule, see https://eslint.org/docs/rules/no-restricted-globals, it's quite likely that the rule will be incorrectly disabled rather than the required globals being imported as intended.

To reduced duplication of the `no-restricted-globals` rule in multiple `.eslintrc` files, it's instead moved to the top-level `.eslintrc` file and disabled as needed on a folder/file basis outside of `/src` and `/web`.
This commit is contained in:
Jonas Jenwald 2018-07-22 16:15:36 +02:00
parent 1aaeaf3338
commit 36b683ca55
7 changed files with 29 additions and 23 deletions

View File

@ -100,7 +100,20 @@
"no-catch-shadow": "error", "no-catch-shadow": "error",
"no-delete-var": "error", "no-delete-var": "error",
"no-label-var": "error", "no-label-var": "error",
"no-restricted-globals": "off", "no-restricted-globals": ["error",
{
"name": "ReadableStream",
"message": "Import it from `src/shared/util.js` or `pdfjsLib` instead; outside of the `/src` and `/web` folders, the rule may be disabled as needed. ",
},
{
"name": "URL",
"message": "Import it from `src/shared/util.js` or `pdfjsLib` instead; outside of the `/src` and `/web` folders, the rule may be disabled as needed. ",
},
{
"name": "WritableStream",
"message": "Import it from `src/shared/util.js` or `pdfjsLib` instead; outside of the `/src` and `/web` folders, the rule may be disabled as needed. ",
},
],
"no-shadow-restricted-names": "error", "no-shadow-restricted-names": "error",
"no-shadow": "off", "no-shadow": "off",
"no-undef-init": "error", "no-undef-init": "error",

9
extensions/.eslintrc Normal file
View File

@ -0,0 +1,9 @@
{
"extends": [
../.eslintrc
],
"rules": {
"no-restricted-globals": "off",
},
}

2
external/.eslintrc vendored
View File

@ -9,7 +9,7 @@
"rules": { "rules": {
"mozilla/use-includes-instead-of-indexOf": "off", "mozilla/use-includes-instead-of-indexOf": "off",
"object-shorthand": "off", "object-shorthand": "off",
"no-restricted-globals": "off",
}, },
} }

View File

@ -1,14 +0,0 @@
{
"extends": [
../.eslintrc
],
"rules": {
// Variables
"no-restricted-globals": ["error",
"ReadableStream",
"URL",
"WritableStream",
],
},
}

View File

@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable no-restricted-globals */
'use strict'; 'use strict';

View File

@ -7,4 +7,8 @@
"node": true, "node": true,
"jasmine": true, "jasmine": true,
}, },
"rules": {
"no-restricted-globals": "off",
},
} }

View File

@ -4,13 +4,6 @@
], ],
"rules": { "rules": {
// Variables
"no-restricted-globals": ["error",
"ReadableStream",
"URL",
"WritableStream",
],
// ECMAScript 6 // ECMAScript 6
"no-var": "error", "no-var": "error",
}, },