Skip to content

Commit

Permalink
Merge pull request github#28558 from github/repo-sync
Browse files Browse the repository at this point in the history
Repo sync
  • Loading branch information
docs-bot authored Sep 27, 2023
2 parents 95ebd3e + c9fd21f commit 7cade62
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 58 deletions.
2 changes: 1 addition & 1 deletion data/reusables/apps/oauth-token-limit.md
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 5 additions & 12 deletions src/content-linter/lib/default-markdownlint-options.js
Original file line number Diff line number Diff line change
@@ -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,
}
17 changes: 14 additions & 3 deletions src/content-linter/lib/init-test.js
Original file line number Diff line number Diff line change
@@ -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)
}
11 changes: 5 additions & 6 deletions src/content-linter/scripts/lint-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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: [],
Expand Down
4 changes: 0 additions & 4 deletions src/content-linter/tests/unit/code-fence-line-length.js
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
3 changes: 0 additions & 3 deletions src/content-linter/tests/unit/early-access-references.js
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
4 changes: 0 additions & 4 deletions src/content-linter/tests/unit/image-file-kebab.js
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
4 changes: 0 additions & 4 deletions src/content-linter/tests/unit/internal-links-lang.js
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
4 changes: 0 additions & 4 deletions src/content-linter/tests/unit/internal-links-slash.js
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
4 changes: 0 additions & 4 deletions src/content-linter/tests/unit/link-punctuation.js
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
10 changes: 5 additions & 5 deletions src/content-linter/tests/unit/search-replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 7cade62

Please sign in to comment.