From f08f2a9ee3a061db8fddcc48fff5b2022db08279 Mon Sep 17 00:00:00 2001 From: Tim <103634854+sn2b@users.noreply.github.com> Date: Wed, 27 Sep 2023 18:52:58 +0200 Subject: [PATCH 1/2] Add information about OAuth token creation rate limit (#43257) Co-authored-by: Mark Tareshawty Co-authored-by: Sarita Iyer <66540150+saritai@users.noreply.github.com> --- data/reusables/apps/oauth-token-limit.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/reusables/apps/oauth-token-limit.md b/data/reusables/apps/oauth-token-limit.md index 64dd1ae1370b..8e724da194a9 100644 --- a/data/reusables/apps/oauth-token-limit.md +++ b/data/reusables/apps/oauth-token-limit.md @@ -1 +1 @@ -There is a limit of ten tokens that are issued per user/application/scope combination. If an application creates more than 10 tokens for the same user and the same scopes, the oldest tokens with the same user/application/scope combination will be revoked. +There is a limit of ten tokens that are issued per user/application/scope combination, with a maximum rate limit of ten tokens created per hour. If an application creates more than ten tokens for the same user and the same scopes, the oldest tokens with the same user/application/scope combination are revoked. However, hitting the hourly rate limit will not revoke your oldest token. After the hour has passed, you will be able to create a token again, and by doing so your oldest token will be revoked. From c9fd21fb6973327075516a0e275fa76068ea0e88 Mon Sep 17 00:00:00 2001 From: Rachael Sewell Date: Wed, 27 Sep 2023 10:04:45 -0700 Subject: [PATCH 2/2] Refactor Markdownlint config and jest timeouts (#43358) --- .../lib/default-markdownlint-options.js | 17 +++++------------ src/content-linter/lib/init-test.js | 17 ++++++++++++++--- src/content-linter/scripts/lint-content.js | 11 +++++------ .../tests/unit/code-fence-line-length.js | 4 ---- .../tests/unit/early-access-references.js | 3 --- .../unit/image-alt-text-end-punctuation.js | 4 ---- .../unit/image-alt-text-exclude-start-words.js | 4 ---- .../tests/unit/image-file-kebab.js | 4 ---- .../tests/unit/internal-links-lang.js | 4 ---- .../tests/unit/internal-links-slash.js | 4 ---- .../tests/unit/link-punctuation.js | 4 ---- src/content-linter/tests/unit/search-replace.js | 10 +++++----- 12 files changed, 29 insertions(+), 57 deletions(-) diff --git a/src/content-linter/lib/default-markdownlint-options.js b/src/content-linter/lib/default-markdownlint-options.js index 9655eda82782..e1c10c532d45 100644 --- a/src/content-linter/lib/default-markdownlint-options.js +++ b/src/content-linter/lib/default-markdownlint-options.js @@ -1,14 +1,7 @@ -export function testOptions(rule, module, { strings, files, testConfig }) { - const config = { - default: false, - [rule]: testConfig || true, - } +export const defaultOptions = { + // frontMatter: null will be set soon +} - const options = { - customRules: [module], - config, - } - if (strings) options.strings = strings - if (files) options.files = files - return options +export const defaultConfig = { + default: false, } diff --git a/src/content-linter/lib/init-test.js b/src/content-linter/lib/init-test.js index 610d099f43fe..6eb0430903fe 100644 --- a/src/content-linter/lib/init-test.js +++ b/src/content-linter/lib/init-test.js @@ -1,11 +1,22 @@ import markdownlint from 'markdownlint' -import { testOptions } from './default-markdownlint-options.js' +import { defaultOptions, defaultConfig } from './default-markdownlint-options.js' -export async function runRule(module, { strings, files, testConfig }) { +export async function runRule(module, { strings, files, ruleConfig }) { if ((!strings && !files) || (strings && files)) throw new Error('Must provide either Markdown strings or files to run a rule') - const options = testOptions(module.names[0], module, { strings, files, testConfig }) + const testConfig = { + [module.names[0]]: ruleConfig || true, + } + + const testOptions = { + customRules: [module], + config: { ...defaultConfig, ...testConfig }, + } + if (strings) testOptions.strings = strings + if (files) testOptions.files = files + + const options = { ...defaultOptions, ...testOptions } return await markdownlint.promises.markdownlint(options) } diff --git a/src/content-linter/scripts/lint-content.js b/src/content-linter/scripts/lint-content.js index c3d5b3932bab..85f1bb50082d 100755 --- a/src/content-linter/scripts/lint-content.js +++ b/src/content-linter/scripts/lint-content.js @@ -10,6 +10,7 @@ import { execSync } from 'child_process' import walkFiles from '../../../script/helpers/walk-files.js' import { allConfig, allRules, customRules } from '../lib/helpers/get-rules.js' import { customConfig } from '../style/github-docs.js' +import { defaultOptions, defaultConfig } from '../lib/default-markdownlint-options.js' program .description('Run GitHub Docs Markdownlint rules.') @@ -75,12 +76,14 @@ async function main() { // Run Markdownlint for content directory const resultContent = await markdownlint.promises.markdownlint({ + ...defaultOptions, files: files.content, config: config.content, customRules: configuredRules.content, }) // Run Markdownlint for data directory const resultData = await markdownlint.promises.markdownlint({ + ...defaultOptions, files: files.data, config: config.data, customRules: configuredRules.data, @@ -312,12 +315,8 @@ function listRules() { */ function getMarkdownLintConfig(errorsOnly, runRules) { const config = { - content: { - default: false, // By default, don't turn on all markdownlint rules - }, - data: { - default: false, // By default, don't turn on all markdownlint rules - }, + content: defaultConfig, + data: defaultConfig, } const configuredRules = { content: [], diff --git a/src/content-linter/tests/unit/code-fence-line-length.js b/src/content-linter/tests/unit/code-fence-line-length.js index 373b7b01fca0..f923d7e259c9 100644 --- a/src/content-linter/tests/unit/code-fence-line-length.js +++ b/src/content-linter/tests/unit/code-fence-line-length.js @@ -1,10 +1,6 @@ -import { jest } from '@jest/globals' - import { runRule } from '../../lib/init-test.js' import { codeFenceLineLength } from '../../lib/linting-rules/code-fence-line-length.js' -jest.setTimeout(60 * 1000) - describe(codeFenceLineLength.names.join(' - '), () => { test('line length of max + 1 fails', async () => { const markdown = [ diff --git a/src/content-linter/tests/unit/early-access-references.js b/src/content-linter/tests/unit/early-access-references.js index 0484af66c29e..582294778ea2 100644 --- a/src/content-linter/tests/unit/early-access-references.js +++ b/src/content-linter/tests/unit/early-access-references.js @@ -1,11 +1,8 @@ -import { expect, jest } from '@jest/globals' - import { runRule } from '../../lib/init-test.js' import { earlyAccessReferences } from '../../lib/linting-rules/early-access-references.js' const FIXTURE_FILEPATH_NON_EA = 'src/content-linter/tests/fixtures/not-secret.md' const FIXTURE_FILEPATH_EA = 'src/content-linter/tests/fixtures/early-access/secret.md' -jest.setTimeout(20 * 1000) describe(earlyAccessReferences.names.join(' - '), () => { test('non-early access file with early access references fails', async () => { diff --git a/src/content-linter/tests/unit/image-alt-text-end-punctuation.js b/src/content-linter/tests/unit/image-alt-text-end-punctuation.js index a46978879b9b..955eac2397e3 100644 --- a/src/content-linter/tests/unit/image-alt-text-end-punctuation.js +++ b/src/content-linter/tests/unit/image-alt-text-end-punctuation.js @@ -1,10 +1,6 @@ -import { jest } from '@jest/globals' - import { runRule } from '../../lib/init-test.js' import { imageAltTextEndPunctuation } from '../../lib/linting-rules/image-alt-text-end-punctuation.js' -jest.setTimeout(60 * 1000) - describe(imageAltTextEndPunctuation.names.join(' - '), () => { test('image alt text without end punctutation errors', async () => { const markdown = [ diff --git a/src/content-linter/tests/unit/image-alt-text-exclude-start-words.js b/src/content-linter/tests/unit/image-alt-text-exclude-start-words.js index 90386dfd60fb..460498d04dcb 100644 --- a/src/content-linter/tests/unit/image-alt-text-exclude-start-words.js +++ b/src/content-linter/tests/unit/image-alt-text-exclude-start-words.js @@ -1,10 +1,6 @@ -import { jest } from '@jest/globals' - import { runRule } from '../../lib/init-test.js' import { imageAltTextExcludeStartWords } from '../../lib/linting-rules/image-alt-text-exclude-start-words.js' -jest.setTimeout(60 * 1000) - describe(imageAltTextExcludeStartWords.names.join(' - '), () => { test('image alt text that starts with exclude words fails', async () => { const markdown = [ diff --git a/src/content-linter/tests/unit/image-file-kebab.js b/src/content-linter/tests/unit/image-file-kebab.js index 0d45ef06ec13..44e3a98e3839 100644 --- a/src/content-linter/tests/unit/image-file-kebab.js +++ b/src/content-linter/tests/unit/image-file-kebab.js @@ -1,10 +1,6 @@ -import { jest } from '@jest/globals' - import { runRule } from '../../lib/init-test.js' import { imageFileKebab } from '../../lib/linting-rules/image-file-kebab' -jest.setTimeout(20 * 1000) - describe(imageFileKebab.names.join(' - '), () => { test('image file not using lowercase kebab case fails', async () => { const markdown = [ diff --git a/src/content-linter/tests/unit/internal-links-lang.js b/src/content-linter/tests/unit/internal-links-lang.js index 02d3eb848ef6..f9fb6f664559 100644 --- a/src/content-linter/tests/unit/internal-links-lang.js +++ b/src/content-linter/tests/unit/internal-links-lang.js @@ -1,10 +1,6 @@ -import { jest } from '@jest/globals' - import { runRule } from '../../lib/init-test.js' import { internalLinksLang } from '../../lib/linting-rules/internal-links-lang.js' -jest.setTimeout(30 * 1000) - describe(internalLinksLang.names.join(' - '), () => { test('internal links with hardcoded language codes fail', async () => { const markdown = [ diff --git a/src/content-linter/tests/unit/internal-links-slash.js b/src/content-linter/tests/unit/internal-links-slash.js index 122f0b94b11b..9947da9477da 100755 --- a/src/content-linter/tests/unit/internal-links-slash.js +++ b/src/content-linter/tests/unit/internal-links-slash.js @@ -1,10 +1,6 @@ -import { jest } from '@jest/globals' - import { runRule } from '../../lib/init-test.js' import { internalLinksSlash } from '../../lib/linting-rules/internal-links-slash.js' -jest.setTimeout(60 * 1000) - describe(internalLinksSlash.names.join(' - '), () => { test('relative links that do not start with / fail', async () => { const markdown = [ diff --git a/src/content-linter/tests/unit/link-punctuation.js b/src/content-linter/tests/unit/link-punctuation.js index 381c24911b36..3184d66cacf4 100644 --- a/src/content-linter/tests/unit/link-punctuation.js +++ b/src/content-linter/tests/unit/link-punctuation.js @@ -1,10 +1,6 @@ -import { jest } from '@jest/globals' - import { runRule } from '../../lib/init-test.js' import { linkPunctuation } from '../../lib/linting-rules/link-punctuation.js' -jest.setTimeout(60 * 1000) - describe(linkPunctuation.names.join(' - '), () => { test('inline links without quotes or a period should not error', async () => { const markdown = [ diff --git a/src/content-linter/tests/unit/search-replace.js b/src/content-linter/tests/unit/search-replace.js index 337c01d9b989..afcdc5de9962 100644 --- a/src/content-linter/tests/unit/search-replace.js +++ b/src/content-linter/tests/unit/search-replace.js @@ -14,7 +14,7 @@ describe(searchReplace.names.join(' - '), () => { ].join('\n') const result = await runRule(searchReplace, { strings: { markdown }, - testConfig: searchReplaceConfig['search-replace'], + ruleConfig: searchReplaceConfig['search-replace'], }) const errors = result.markdown expect(errors.length).toBe(7) @@ -40,7 +40,7 @@ describe(searchReplace.names.join(' - '), () => { ].join('\n') const result = await runRule(searchReplace, { strings: { markdown }, - testConfig: searchReplaceConfig['search-replace'], + ruleConfig: searchReplaceConfig['search-replace'], }) const errors = result.markdown expect(errors.length).toBe(10) @@ -55,7 +55,7 @@ describe(searchReplace.names.join(' - '), () => { ].join('\n') const result = await runRule(searchReplace, { strings: { markdown }, - testConfig: searchReplaceConfig['search-replace'], + ruleConfig: searchReplaceConfig['search-replace'], }) const errors = result.markdown expect(errors.length).toBe(4) @@ -70,7 +70,7 @@ describe(searchReplace.names.join(' - '), () => { ].join('\n') const result = await runRule(searchReplace, { strings: { markdown }, - testConfig: searchReplaceConfig['search-replace'], + ruleConfig: searchReplaceConfig['search-replace'], }) const errors = result.markdown expect(errors.length).toBe(3) @@ -86,7 +86,7 @@ describe(searchReplace.names.join(' - '), () => { ].join('\n') const result = await runRule(searchReplace, { strings: { markdown }, - testConfig: searchReplaceConfig['search-replace'], + ruleConfig: searchReplaceConfig['search-replace'], }) const errors = result.markdown expect(errors.length).toBe(5)