Skip to content

Commit

Permalink
Biome migration (#2736)
Browse files Browse the repository at this point in the history
- Fix formatting issues
- Use string templates
- Use for of loops wherever possible instead of for each
- Remove parameter re-assignment
- Prefix "node:" for system imports

---------

Signed-off-by: Zabil Cheriya Maliackal <zabilcm@gmail.com>
  • Loading branch information
zabil committed Aug 23, 2024
1 parent bdcd544 commit 0016486
Show file tree
Hide file tree
Showing 201 changed files with 11,259 additions and 12,275 deletions.
59 changes: 29 additions & 30 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
const tocPlugin = require('eleventy-plugin-toc');
const tocPlugin = require("eleventy-plugin-toc");
const markdownIt = require("markdown-it");
const CleanCSS = require("clean-css");

module.exports = function (eleventyConfig) {

module.exports = (eleventyConfig) => {
eleventyConfig.addPassthroughCopy("docs/assets");
eleventyConfig.addFilter("cssmin", function(code) {
return new CleanCSS({}).minify(code).styles;
});
eleventyConfig.addFilter(
"cssmin",
(code) => new CleanCSS({}).minify(code).styles,
);
// This filter is used for deriving the chapter names
// from data in chapters.json
eleventyConfig.addFilter('heading', function (str) {
return str.replace(/[_;\\/:*?\"<>|&']/g, " ");
});
eleventyConfig.addFilter("heading", (str) =>
str.replace(/[_;\\/:*?\"<>|&']/g, " "),
);

// Filter for linking to section headers
// and displaying chapters in a page
let markdownItAnchor = require("markdown-it-anchor");
let mdIt = markdownIt({
html: true,
linkify: true
})
.use(markdownItAnchor, {
permalink: true,
permalinkBefore: false,
permalinkClass: "direct-link",
permalinkSymbol: "#",
level: [1, 2]
});
eleventyConfig.addFilter("markdown", function(code) {
if(code) {
return mdIt.render(code);
}
const markdownItAnchor = require("markdown-it-anchor");
const mdIt = markdownIt({
html: true,
linkify: true,
}).use(markdownItAnchor, {
permalink: true,
permalinkBefore: false,
permalinkClass: "direct-link",
permalinkSymbol: "#",
level: [1, 2],
});
eleventyConfig.addFilter("markdown", (code) => {
if (code) {
return mdIt.render(code);
}
});
eleventyConfig.setLibrary("md", mdIt);
eleventyConfig.addPlugin(tocPlugin);

return {
dir: {
input: 'docs',
output: 'docs/_site'
}
}
};
input: "docs",
output: "docs/_site",
},
};
};
13 changes: 8 additions & 5 deletions .github/workflows/taiko.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
- name: Setup Biome
uses: biomejs/setup-biome@v2
with:
version: latest
- name: install
run: npm install
- name: install browser dependencies
Expand All @@ -41,7 +45,7 @@ jobs:
libasound-dev
- name: unit-tests
run: |
npm run lint:check
biome ci
npm test
functional-tests:
Expand Down Expand Up @@ -139,7 +143,7 @@ jobs:

docs-tests:
needs: unit-tests
name: Docs tests - ${{ matrix.os }}
name: Docs tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -150,7 +154,6 @@ jobs:
- name: install
run: npm install
- name: install browser dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y \
Expand All @@ -171,11 +174,11 @@ jobs:
uses: actions/upload-artifact@v1
if: failure()
with:
name: docs-tests-reports-${{ matrix.os }}
name: docs-tests-reports
path: test/docs-tests/gauge/reports/html-report
- name: Upload logs
uses: actions/upload-artifact@v1
if: failure()
with:
name: docs-tests-logs-${{ matrix.os }}
name: docs-tests-logs
path: test/docs-tests/gauge/logs
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ test-script.js
test/docs-tests/tmp/
test/docs-tests/lib/
test/docs-tests/gauge/.vscode
test/docs-tests/gauge/package-lock.json
test/docs-tests/gauge/reports/
test/docs-tests/gauge/.gauge/
test/package-lock.json
38 changes: 22 additions & 16 deletions bin/runFile.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const path = require('path');
const util = require('util');
const recorder = require('../recorder');
const path = require("node:path");
const util = require("node:util");
const recorder = require("../recorder");

const { removeQuotes } = require('../lib/util');
const { removeQuotes } = require("../lib/util");
module.exports = async (taiko, file, observe, observeTime, continueRepl) => {
const realFuncs = {};
for (let func in taiko) {
for (const func in taiko) {
realFuncs[func] = taiko[func];
if (realFuncs[func].constructor.name === 'AsyncFunction') {
if (realFuncs[func].constructor.name === "AsyncFunction") {
global[func] = async function () {
let res,
args = arguments;
if (func === 'openBrowser' && (observe || continueRepl)) {
if (args['0']) {
args['0'].headless = !observe;
// biome-ignore lint/style/noArguments: Cannot use rest paramaters
let args = arguments;
if (func === "openBrowser" && (observe || continueRepl)) {
if (args["0"]) {
args["0"].headless = !observe;
args[0].observe = observe;
args['0'].observeTime = observeTime;
args["0"].observeTime = observeTime;
} else if (continueRepl) {
args = [
{
Expand All @@ -35,11 +35,12 @@ module.exports = async (taiko, file, observe, observeTime, continueRepl) => {
}
}

res = await realFuncs[func].apply(this, args);
const res = await realFuncs[func].apply(this, args);
return res;
};
} else if (realFuncs[func].constructor.name === 'Function') {
} else if (realFuncs[func].constructor.name === "Function") {
global[func] = function () {
// biome-ignore lint/style/noArguments: Cannot use rest paramaters
return realFuncs[func].apply(this, arguments);
};
} else {
Expand All @@ -48,15 +49,20 @@ module.exports = async (taiko, file, observe, observeTime, continueRepl) => {
if (continueRepl) {
recorder.repl = async () => {
console.log(
removeQuotes(util.inspect('Starting REPL..', { colors: true }), 'Starting REPL..'),
removeQuotes(
util.inspect("Starting REPL..", { colors: true }),
"Starting REPL..",
),
);
await continueRepl(file);
};
}
require.cache[path.join(__dirname, 'taiko.js')].exports[func] = global[func];
require.cache[path.join(__dirname, "taiko.js")].exports[func] =
global[func];
}
const oldNodeModulesPaths = module.constructor._nodeModulePaths;
module.constructor._nodeModulePaths = function () {
// biome-ignore lint/style/noArguments: Cannot use rest paramaters
const ret = oldNodeModulesPaths.apply(this, arguments);
ret.push(__dirname);
ret.push(path.dirname(path.dirname(__dirname)));
Expand Down
Loading

0 comments on commit 0016486

Please sign in to comment.