-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into kohheepeace-codeblock-filename
- Loading branch information
Showing
130 changed files
with
2,799 additions
and
627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.DS_Store | ||
.vscode | ||
.idea | ||
*.iml | ||
*.code-workspace | ||
.changelog | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
module.exports = { | ||
plugins: ['stylelint-copyright'], | ||
rules: { | ||
'docusaurus/copyright-header': true, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
const stylelint = require('stylelint'); | ||
|
||
function getOutputCss(output) { | ||
const result = output.results[0]._postcssResult; | ||
return result.root.toString(result.opts.syntax); | ||
} | ||
|
||
global.testStylelintRule = (config, tests) => { | ||
describe(tests.ruleName, () => { | ||
const checkTestCaseContent = testCase => | ||
testCase.description || testCase.code || 'no description'; | ||
|
||
if (tests.accept && tests.accept.length) { | ||
describe('accept cases', () => { | ||
tests.accept.forEach(testCase => { | ||
const spec = testCase.only ? it.only : it; | ||
|
||
spec(checkTestCaseContent(testCase), () => { | ||
const options = { | ||
code: testCase.code, | ||
config, | ||
syntax: tests.syntax, | ||
}; | ||
|
||
return stylelint.lint(options).then(output => { | ||
expect(output.results[0].warnings).toEqual([]); | ||
|
||
if (!tests.fix) { | ||
return null; | ||
} | ||
|
||
// Check the fix. | ||
return stylelint | ||
.lint({...options, fix: true}) | ||
.then(fixedOutput => getOutputCss(fixedOutput)) | ||
.then(fixedCode => expect(fixedCode).toBe(testCase.fixed)); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
if (tests.reject && tests.reject.length) { | ||
describe('reject cases', () => { | ||
tests.reject.forEach(testCase => { | ||
const skip = testCase.skip ? it.skip : it; | ||
const spec = testCase.only ? it.only : skip; | ||
|
||
spec(checkTestCaseContent(testCase), () => { | ||
const options = { | ||
code: testCase.code, | ||
config, | ||
syntax: tests.syntax, | ||
}; | ||
|
||
return stylelint.lint(options).then(output => { | ||
const {warnings} = output.results[0]; | ||
const warning = warnings[0]; | ||
|
||
expect(warnings.length).toBeGreaterThanOrEqual(1); | ||
expect(testCase).toHaveMessage(); | ||
|
||
if (testCase.message != null) { | ||
expect(warning.text).toBe(testCase.message); | ||
} | ||
|
||
if (testCase.line != null) { | ||
expect(warning.line).toBe(testCase.line); | ||
} | ||
|
||
if (testCase.column != null) { | ||
expect(warning.column).toBe(testCase.column); | ||
} | ||
|
||
if (!tests.fix) { | ||
return null; | ||
} | ||
|
||
if (!testCase.fixed) { | ||
throw new Error( | ||
'If using { fix: true } in test tests, all reject cases must have { fixed: .. }', | ||
); | ||
} | ||
|
||
// Check the fix. | ||
return stylelint | ||
.lint({...options, fix: true}) | ||
.then(fixedOutput => getOutputCss(fixedOutput)) | ||
.then(fixedCode => expect(fixedCode).toBe(testCase.fixed)); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
expect.extend({ | ||
toHaveMessage(testCase) { | ||
if (testCase.message == null) { | ||
return { | ||
message: () => | ||
'Expected "reject" test case to have a "message" property', | ||
pass: false, | ||
}; | ||
} | ||
|
||
return { | ||
pass: true, | ||
}; | ||
}, | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.