Skip to content

Commit

Permalink
Merge branch 'main' into cacheModuleResolution
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Aug 23, 2022
2 parents bf27ad6 + f88117d commit 120fc41
Show file tree
Hide file tree
Showing 77 changed files with 3,062 additions and 1,547 deletions.
12 changes: 12 additions & 0 deletions .eslintplugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const fs = require("fs");
const path = require("path");

const rulesDir = path.join(__dirname, "scripts", "eslint", "rules");
const ext = ".js";
const ruleFiles = fs.readdirSync(rulesDir).filter((p) => p.endsWith(ext));

module.exports = {
rules: Object.fromEntries(ruleFiles.map((p) => {
return [p.slice(0, -ext.length), require(path.join(rulesDir, p))];
})),
}
24 changes: 12 additions & 12 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"es6": true
},
"plugins": [
"@typescript-eslint", "jsdoc", "no-null", "import"
"@typescript-eslint", "jsdoc", "no-null", "import", "eslint-plugin-local"
],
"overrides": [
// By default, the ESLint CLI only looks at .js files. But, it will also look at
Expand Down Expand Up @@ -81,20 +81,20 @@
"@typescript-eslint/unified-signatures": "error",

// scripts/eslint/rules
"object-literal-surrounding-space": "error",
"no-type-assertion-whitespace": "error",
"type-operator-spacing": "error",
"only-arrow-functions": ["error", {
"local/object-literal-surrounding-space": "error",
"local/no-type-assertion-whitespace": "error",
"local/type-operator-spacing": "error",
"local/only-arrow-functions": ["error", {
"allowNamedFunctions": true ,
"allowDeclarations": true
}],
"no-double-space": "error",
"boolean-trivia": "error",
"no-in-operator": "error",
"simple-indent": "error",
"debug-assert": "error",
"no-keywords": "error",
"one-namespace-per-file": "error",
"local/no-double-space": "error",
"local/boolean-trivia": "error",
"local/no-in-operator": "error",
"local/simple-indent": "error",
"local/debug-assert": "error",
"local/no-keywords": "error",
"local/one-namespace-per-file": "error",

// eslint-plugin-import
"import/no-extraneous-dependencies": ["error", { "optionalDependencies": false }],
Expand Down
33 changes: 26 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- release-*

jobs:
build:
test:
runs-on: ubuntu-latest

strategy:
Expand All @@ -24,27 +24,46 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 5
- name: Use node version ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
check-latest: true
- run: npm ci

# Re: https://github.com/actions/setup-node/pull/125
- name: Register Problem Matcher for TSC
run: echo "##[add-matcher].github/tsc.json"

- name: Tests
run: npm test -- --no-lint

lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "*"
check-latest: true
- run: npm ci

- name: Linter
run: npm run lint:ci

browser-integration:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "*"
check-latest: true
- run: npm ci

- name: Adding playwright
run: npm install --no-save --no-package-lock playwright

- name: Build local
run: gulp local

- name: Validate the browser can import TypeScript
run: gulp test-browser-integration
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ Dockerfile
.eslintrc.json
.yarnrc
tmp
.eslintplugin.js
.eslintcache
6 changes: 0 additions & 6 deletions .vscode/settings.template.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
// Rename this file 'settings.json' or merge its
// contents into your existing settings.
{
"eslint.validate": [
"typescript"
],
"eslint.options": {
"rulePaths": ["./scripts/eslint/built/rules/"],
},
// To use the last-known-good (LKG) compiler version:
// "typescript.tsdk": "lib"

Expand Down
12 changes: 4 additions & 8 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const del = require("del");
const rename = require("gulp-rename");
const concat = require("gulp-concat");
const merge2 = require("merge2");
const mkdirp = require("mkdirp");
const { src, dest, task, parallel, series, watch } = require("gulp");
const { append, transform } = require("gulp-insert");
const { prependFile } = require("./scripts/build/prepend");
Expand All @@ -27,9 +26,10 @@ task("scripts").description = "Builds files in the 'scripts' folder.";
const cleanScripts = () => cleanProject("scripts");
cleanTasks.push(cleanScripts);

/** @type {{ libs: string[]; paths: Record<string, string | undefined>; }} */
const libraries = readJson("./src/lib/libs.json");
const libs = libraries.libs.map(lib => {
const relativeSources = ["header.d.ts"].concat(libraries.sources && libraries.sources[lib] || [lib + ".d.ts"]);
const relativeSources = ["header.d.ts", lib + ".d.ts"];
const relativeTarget = libraries.paths && libraries.paths[lib] || ("lib." + lib + ".d.ts");
const sources = relativeSources.map(s => path.posix.join("src/lib", s));
const target = `built/local/${relativeTarget}`;
Expand Down Expand Up @@ -356,7 +356,6 @@ const eslint = (folder) => async () => {
"--cache",
"--cache-location", `${folder}/.eslintcache`,
"--format", formatter,
"--rulesdir", "scripts/eslint/built/rules",
];

if (cmdLineOptions.fix) {
Expand All @@ -369,10 +368,7 @@ const eslint = (folder) => async () => {
return exec(process.execPath, args);
};

const lintRoot = eslint(".");
lintRoot.displayName = "lint";

const lint = series([buildEslintRules, lintRoot]);
const lint = eslint(".");
lint.displayName = "lint";
task("lint", lint);
task("lint").description = "Runs eslint on the compiler and scripts sources.";
Expand Down Expand Up @@ -431,7 +427,7 @@ task("watch-local").flags = {
const preTest = parallel(buildTsc, buildTests, buildServices, buildLssl);
preTest.displayName = "preTest";

const postTest = (done) => cmdLineOptions.lint ? lint(done) : done();
const postTest = (done) => cmdLineOptions.lint ? lint() : done();

const runTests = () => runConsoleTests("built/local/run.js", "mocha-fivemat-progress-reporter", /*runInParallel*/ false, /*watchMode*/ false);
task("runtests", series(preBuild, preTest, runTests, postTest));
Expand Down
Loading

0 comments on commit 120fc41

Please sign in to comment.