From 3b04261e4f19601d919c0bdbcc0ce0a4d0188acc Mon Sep 17 00:00:00 2001 From: oleiade Date: Tue, 14 Nov 2023 10:51:05 +0100 Subject: [PATCH 1/4] Add ESLint config to docs/sources --- .eslintignore | 3 +-- docs/sources/.eslintrc.js | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 docs/sources/.eslintrc.js diff --git a/.eslintignore b/.eslintignore index 10ad6661e0..0574c50b3a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,12 +1,11 @@ .cache/ public/ node_modules/ -docs/sources/ docs/sources/get-started/run-cloud-tests-from-the-CLI.md docs/sources/get-started/run-your-first-tests.md CONTRIBUTING_FILE_FORMAT.md src/data/markdown/docs/40 xk6-disruptor/01 Get started/01 First steps.md -src/data/markdown/docs/40 xk6-disruptor/01 Get started/04 Expose Your Application.md +src/data/markdown/docs/40 xk6-disruptor/01 Get started/04 Expose Your Application.md src/data/markdown/docs/40 xk6-disruptor/04 Examples/01 Inject Grpc faults into Service.md src/data/markdown/docs/40 xk6-disruptor/04 Examples/02 Inject HTTP faults into Pod.md src/data/markdown/docs/05 Examples/02 Tutorials/01 Get started with k6/100 Test-for-functional-behavior.md diff --git a/docs/sources/.eslintrc.js b/docs/sources/.eslintrc.js new file mode 100644 index 0000000000..a5ab855e0e --- /dev/null +++ b/docs/sources/.eslintrc.js @@ -0,0 +1,44 @@ +module.exports = { + root: true, + env: { + es2017: true, + commonjs: true, + }, + parserOptions: { + ecmaVersion: '2017', + sourceType: 'module', + }, + extends: ['plugin:mdx/recommended', 'plugin:prettier/recommended'], + plugins: ['markdown'], + overrides: [ + { + // Enable the Markdown processor for all .md files. + files: ['**/*.md'], + processor: 'markdown/markdown', + }, + { + // Customize the configuration ESLint uses for ```js, ```javascript + files: ['**/*.md/*.js', '**/*.md/*.javascript'], + rules: { + 'no-undef': 'error', + 'no-else-return': 'error', + 'no-extra-boolean-cast': 'error', + 'no-duplicate-case': 'error', + 'no-const-assign': 'error', + 'no-dupe-args': 'error', + 'no-dupe-else-if': 'error', + 'no-var': 'error', + 'use-isnan': 'error', + 'func-style': ['error', 'declaration', { allowArrowFunctions: true }], + 'prefer-const': 'error', + }, + }, + ], + globals: { + console: 'readonly', + __VU: 'readonly', + __ENV: 'readonly', + __ITER: 'readonly', + open: 'readonly', + }, +}; From be98a2b4c828cc78448d538aaf9e99b52e617a88 Mon Sep 17 00:00:00 2001 From: oleiade Date: Tue, 14 Nov 2023 10:41:22 +0100 Subject: [PATCH 2/4] Add Prettier config to docs/sources --- docs/sources/.prettierrc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 docs/sources/.prettierrc diff --git a/docs/sources/.prettierrc b/docs/sources/.prettierrc new file mode 100644 index 0000000000..8dc922102b --- /dev/null +++ b/docs/sources/.prettierrc @@ -0,0 +1,14 @@ +{ + "singleQuote": true, + "quoteProps": "consistent", + "trailingComma": "es5", + "printWidth": 100, + "overrides": [ + { + "files": ["**/*.md"], + "options": { + "parser": "babel" + } + } + ] +} From 377ad1dd03d9777b131709b62659df0d12269299 Mon Sep 17 00:00:00 2001 From: oleiade Date: Tue, 14 Nov 2023 09:59:29 +0100 Subject: [PATCH 3/4] Update .lintstagedrc configuration for new repo structure In this commit we add a rule to the lint-staged configuration file at the root of the repository to ensure that all the markdown files contained in the docs/sources folder are formatted using our prettier config. Although not absolutely necessary, we enforce prettier to use the markdown parser, and have it write the result directly to staged files. --- .lintstagedrc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.lintstagedrc b/.lintstagedrc index c8ab9a890d..f0221cceda 100644 --- a/.lintstagedrc +++ b/.lintstagedrc @@ -1,5 +1,9 @@ { + "docs/sources/**/*.md": [ + "prettier --parser markdown --write", + "eslint -c ./docs/sources/.eslintrc.js --fix" + ], "*.{js,jsx,css,scss}": "prettier --write", "*.{js,jsx}": "eslint --fix", - "*.{md,mdx}": "eslint -c ./src/data/markdown/.eslintrc.js --fix" + "src/data/markdown/**/*.{md,mdx}": "eslint -c ./src/data/markdown/.eslintrc.js --fix" } From 29d27875972c274e43b24738d3a137568247d370 Mon Sep 17 00:00:00 2001 From: oleiade Date: Tue, 14 Nov 2023 11:11:46 +0100 Subject: [PATCH 4/4] Address existing linting issues --- .../01 Get started/04 Expose Your Application.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/data/markdown/docs/40 xk6-disruptor/01 Get started/04 Expose Your Application.md b/src/data/markdown/docs/40 xk6-disruptor/01 Get started/04 Expose Your Application.md index fb7073c9cf..e69183c680 100644 --- a/src/data/markdown/docs/40 xk6-disruptor/01 Get started/04 Expose Your Application.md +++ b/src/data/markdown/docs/40 xk6-disruptor/01 Get started/04 Expose Your Application.md @@ -29,7 +29,10 @@ Until this issue is solved in `kubectl`, tests using port forwarding to access a The simplest way to accomplish this is to ensure the scenario that executes the load (#2) starts after the scenario that injects the faults (#1): + + ```javascript +export const options = { scenarios: { disrupt: { // #1 inject faults executor: 'shared-iterations', @@ -47,8 +50,11 @@ The simplest way to accomplish this is to ensure the scenario that executes the startTime: '20s', // give time for the agents to be installed duration: "30s", } - } - ``` + } +} +``` + + ## As a LoadBalancer service