Further test and settings updates (#739)

This commit is contained in:
Elizabeth Craig 2024-04-23 16:55:52 -07:00 коммит произвёл GitHub
Родитель 7453924a5a
Коммит c6b1be01ff
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
9 изменённых файлов: 31 добавлений и 34 удалений

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

@ -4,5 +4,5 @@ module.exports = {
parserOptions: { parserOptions: {
project: "./scripts/config/tsconfig.eslint.json", project: "./scripts/config/tsconfig.eslint.json",
}, },
ignorePatterns: ["**/*.js", "**/__fixtures__", "**/hasher/src/__tests__", "docs"], ignorePatterns: ["**/*.js", "**/__fixtures__", "**/hasher/src/__tests__", "docs", "packages/*/scripts"],
}; };

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

@ -1,3 +1,6 @@
# Not formatted
.*ignore
# Generated or imported files # Generated or imported files
change/*.json change/*.json
CHANGELOG.* CHANGELOG.*

5
.vscode/settings.json поставляемый
Просмотреть файл

@ -4,5 +4,10 @@
"typescript.tsdk": "node_modules/typescript/lib", "typescript.tsdk": "node_modules/typescript/lib",
"files.associations": { "files.associations": {
"*.json5": "jsonc" "*.json5": "jsonc"
},
"search.exclude": {
"**/lib": true,
"**/node_modules": true,
"**/*.code-search": true
} }
} }

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

@ -58,14 +58,21 @@ module.exports = {
}, },
npmClient: "yarn", npmClient: "yarn",
cacheOptions: { cacheOptions: {
// These are relative to the git root, and affect the hash of the cache.
// Changes to any of these files will invalidate the cache.
environmentGlob: [ environmentGlob: [
// Folder globs MUST end with **/* to include all files!
"!node_modules/**/*",
"!**/node_modules/**/*",
".github/workflows/*",
"beachball.config.js", "beachball.config.js",
"lage.config.js", "lage.config.js",
"package.json", "package.json",
"renovate.json5",
".github/**",
"packages/tsconfig.lage2.json", "packages/tsconfig.lage2.json",
"patches", "patches/**/*",
"yarn.lock",
], ],
// Subset of files in package directories that will be saved into the cache.
outputGlob: ["lib/**/*", "dist/**/*", ".docusaurus/**/*", "build/**/*"],
}, },
}; };

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

@ -15,9 +15,5 @@
"noUnusedLocals": false, "noUnusedLocals": false,
"sourceMap": true, "sourceMap": true,
"typeRoots": ["../node_modules/@types", "../types", "node_modules/@types"] "typeRoots": ["../node_modules/@types", "../types", "node_modules/@types"]
},
"ts-node": {
"swc": true,
"transpileOnly": true
} }
} }

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

@ -2,6 +2,7 @@ module.exports = {
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"], extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser", parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "file-extension-in-import-ts"], plugins: ["@typescript-eslint", "file-extension-in-import-ts"],
reportUnusedDisableDirectives: true,
rules: { rules: {
"@typescript-eslint/consistent-type-imports": "error", "@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/consistent-type-exports": "error", "@typescript-eslint/consistent-type-exports": "error",

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

@ -1,9 +1,10 @@
// @ts-check // @ts-check
const { findProjectRoot, getPackageInfos } = require("workspace-tools"); const { findProjectRoot, getPackageInfos } = require("workspace-tools");
const fs = require("fs");
const path = require("path"); const path = require("path");
const swcOptions = require("./swc");
const root = findProjectRoot(process.cwd()) ?? process.cwd(); const root = findProjectRoot(process.cwd()) ?? process.cwd();
const swcOptions = JSON.parse(fs.readFileSync(path.join(root, ".swcrc"), "utf8"));
const packages = getPackageInfos(root); const packages = getPackageInfos(root);
const moduleNameMapper = Object.values(packages).reduce((acc, { packageJsonPath, name }) => { const moduleNameMapper = Object.values(packages).reduce((acc, { packageJsonPath, name }) => {
const packagePath = path.dirname(packageJsonPath); const packagePath = path.dirname(packageJsonPath);

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

@ -1,20 +0,0 @@
// @ts-check
/**
* Options passed to swc.transformFile
* @type {import("@swc/core").Options}
*/
const options = {
jsc: {
parser: {
syntax: "typescript",
tsx: false,
dynamicImport: true,
},
target: "es2020",
},
module: {
type: "commonjs",
ignoreDynamic: true,
},
};
module.exports = options;

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

@ -1,8 +1,12 @@
// @ts-check // @ts-check
const path = require("path"); const path = require("path");
const fs = require("fs/promises"); const fs = require("fs");
const fsPromises = require("fs/promises");
const swc = require("@swc/core"); const swc = require("@swc/core");
const swcOptions = require("../config/swc"); const { findProjectRoot } = require("workspace-tools");
const root = findProjectRoot(process.cwd()) ?? process.cwd();
const swcOptions = JSON.parse(fs.readFileSync(path.join(root, ".swcrc"), "utf8"));
module.exports = async function transpile(data) { module.exports = async function transpile(data) {
const { target } = data; const { target } = data;
@ -16,7 +20,7 @@ module.exports = async function transpile(data) {
while (queue.length > 0) { while (queue.length > 0) {
const dir = queue.shift(); const dir = queue.shift();
let entries = await fs.readdir(dir, { withFileTypes: true }); let entries = await fsPromises.readdir(dir, { withFileTypes: true });
for (let entry of entries) { for (let entry of entries) {
const fullPath = path.join(dir, entry.name); const fullPath = path.join(dir, entry.name);
@ -29,8 +33,8 @@ module.exports = async function transpile(data) {
.replace(/([/\\])src/, "$1lib") .replace(/([/\\])src/, "$1lib")
.replace(".tsx", ".js") .replace(".tsx", ".js")
.replace(".ts", ".js"); .replace(".ts", ".js");
await fs.mkdir(path.dirname(dest), { recursive: true }); await fsPromises.mkdir(path.dirname(dest), { recursive: true });
await fs.writeFile(dest, swcOutput.code); await fsPromises.writeFile(dest, swcOutput.code);
} }
} }
} }