Bug 1945566 - Add eslint and vscode module resolvers for moz-src, r=firefox-desktop-core-reviewers ,frontend-codestyle-reviewers,mconley,Standard8
Differential Revision: https://phabricator.services.mozilla.com/D236570
This commit is contained in:
@@ -50,6 +50,10 @@ const httpTestingPaths = [
|
||||
module.exports = {
|
||||
settings: {
|
||||
"import/extensions": [".mjs"],
|
||||
"import/resolver": {
|
||||
[path.resolve(__dirname, "srcdir-resolver.js")]: {},
|
||||
node: {},
|
||||
},
|
||||
},
|
||||
ignorePatterns,
|
||||
// Ignore eslint configurations in parent directories.
|
||||
@@ -108,6 +112,8 @@ module.exports = {
|
||||
// *.config.js files are generally assumed to be configuration files
|
||||
// based for node.
|
||||
"*.config.?(m)js",
|
||||
// The resolver for moz-src for eslint, vscode etc.
|
||||
"srcdir-resolver.js",
|
||||
],
|
||||
env: {
|
||||
node: true,
|
||||
|
||||
@@ -35,7 +35,7 @@ with Files("docs/**"):
|
||||
with Files("mach*"):
|
||||
BUG_COMPONENT = ("Firefox Build System", "Mach Core")
|
||||
|
||||
with Files("pyproject.toml"):
|
||||
with Files("pyproject.toml", "srcdir-resolver.js"):
|
||||
BUG_COMPONENT = ("Developer Infrastructure", "Lint and Formatting")
|
||||
|
||||
with Files("*moz*"):
|
||||
|
||||
@@ -204,10 +204,11 @@ class TestJarMaker(unittest.TestCase):
|
||||
for attr in ("topsourcedir", "sourcedirs"):
|
||||
if attr in kwargs:
|
||||
setattr(jm, attr, kwargs[attr])
|
||||
jm.makeJar(infile, self.builddir)
|
||||
cwd = os.getcwd()
|
||||
os.chdir(self.builddir)
|
||||
try:
|
||||
jm.makeJar(infile, self.builddir)
|
||||
|
||||
# expand build to stage
|
||||
for path, dirs, files in os.walk("."):
|
||||
stagedir = os.path.join(self.stagedir, path)
|
||||
|
||||
29
srcdir-resolver.js
Normal file
29
srcdir-resolver.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
|
||||
const PREFIX = "moz-src:///";
|
||||
|
||||
exports.interfaceVersion = 2;
|
||||
exports.resolve = source => {
|
||||
if (!source.startsWith(PREFIX)) {
|
||||
return { found: false };
|
||||
}
|
||||
|
||||
let result = path.resolve(
|
||||
__dirname,
|
||||
...source.substring(PREFIX.length).split("/")
|
||||
);
|
||||
let stats = fs.statSync(result, { throwIfNoEntry: false });
|
||||
if (!stats || !stats.isFile()) {
|
||||
return { found: false };
|
||||
}
|
||||
|
||||
return {
|
||||
found: true,
|
||||
path: result,
|
||||
};
|
||||
};
|
||||
@@ -2,6 +2,10 @@
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
"target": "es2024",
|
||||
"types": ["gecko"]
|
||||
"types": ["gecko"],
|
||||
"baseUrl": "../../",
|
||||
"paths": {
|
||||
"moz-src:///*": ["./*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user