Bug 1831588 - Teach ESLint to ignore paths from ThirdPartyPaths.txt. r=aleca

Copy code from m-c's .eslintrc.js that reads ThirdPartyPaths.txt (and Generated.txt)
and adds the contents to ignorePatterns.
Since those files are prefixed with "comm/", ESLint needs to drop the prefix
because `commlint -l eslint` always runs from ``$topsrcdir/comm` so that the
correct .eslintignore and .prettierignore files are found.

Differential Revision: https://phabricator.services.mozilla.com/D177274

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Rob Lemley 2023-05-06 09:40:40 +00:00
Родитель a63ee964d6
Коммит abcec1eac4
4 изменённых файлов: 26 добавлений и 8 удалений

Просмотреть файл

@ -7,6 +7,10 @@
# lint eslint config files which are excluded by default
!**/.eslintrc.js
# For now, skip all json files for ESLint, these will still be run through
# Prettier.
**/*.json
# Exclude expected objdirs.
obj*/**
@ -15,7 +19,6 @@ mozilla/**
# These directories don't contain any js and are not meant to
config/**
db/**
other-licenses/**
testing/**
@ -27,14 +30,9 @@ suite/**
# calendar/ exclusions
calendar/base/calendar.js
calendar/base/modules/Ical.jsm
# chat exclusions
chat/chat-prefs.js
# third-party code
chat/protocols/matrix/lib/**
chat/protocols/xmpp/lib/**
third_party
# preprocessed files
chat/content/imtooltip.xml
@ -45,7 +43,6 @@ mailnews/extensions/mdn/mdn.js
# mail exclusions
mail/app/profile/all-thunderbird.js
mail/app/profile/channel-prefs.js
mail/base/content/protovis-r2.6-modded.js
mail/branding/nightly/pref/thunderbird-branding.js
mail/branding/thunderbird/pref/thunderbird-branding.js
# This file is split into two in order to keep it as a valid json file
@ -55,5 +52,4 @@ mail/components/enterprisepolicies/schemas/schema.sys.mjs
mail/components/im/all-im.js
mail/extensions/am-e2e/prefs/e2e-prefs.js
mail/locales/en-US/all-l10n.js
mail/components/compose/texzilla/**
mail/components/compose/composer.js

Просмотреть файл

@ -8,6 +8,7 @@ const path = require("path");
const xpcshellTestConfig = require("eslint-plugin-mozilla/lib/configs/xpcshell-test.js");
const browserTestConfig = require("eslint-plugin-mozilla/lib/configs/browser-test.js");
const fs = require("fs");
/**
* Some configurations have overrides, which can't be specified within overrides,
@ -19,6 +20,19 @@ function removeOverrides(config) {
return config;
}
function readFile(path) {
return fs
.readFileSync(path, { encoding: "utf-8" })
.split("\n")
.filter(p => p && !p.startsWith("#"))
.map(p => p.replace(/^comm\//, ""));
}
const ignorePatterns = [
...readFile(path.join(__dirname, "tools", "lint", "ThirdPartyPaths.txt")),
...readFile(path.join(__dirname, "tools", "lint", "Generated.txt")),
];
const xpcshellTestPaths = [
"**/test*/unit*/",
"**/test*/xpcshell/",
@ -50,6 +64,8 @@ module.exports = {
// Ignore eslint configurations in parent directories.
root: true,
ignorePatterns,
// We would like the same base rules as provided by
// mozilla/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
extends: ["plugin:mozilla/recommended"],

3
tools/lint/Generated.txt Normal file
Просмотреть файл

@ -0,0 +1,3 @@
comm/mailnews/extensions/newsblog/test/unit/resources/feeds-missing-timestamp/feeds.json
comm/mailnews/extensions/newsblog/test/unit/resources/feeds-simple/feeditems.json
comm/mailnews/extensions/newsblog/test/unit/resources/feeds-simple/feeds.json

Просмотреть файл

@ -1,5 +1,8 @@
comm/calendar/base/modules/Ical.jsm
comm/chat/protocols/matrix/lib
comm/chat/protocols/xmpp/lib
comm/mail/base/content/protovis-r2.6-modded.js
comm/mail/components/compose/texzilla/TeXZilla.js
comm/mail/components/storybook/storybook-static
comm/mailnews/mapi/include
comm/third_party/asn1js