-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5eb3e96
Showing
7 changed files
with
120 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
vendor/ | ||
composer.lock | ||
.phpcs-cache | ||
.phpunit.result.cache |
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,6 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<xulieta xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="./vendor/codelicia/xulieta/xulieta.xsd"> | ||
<plugin>Codelicia\XulietaJson\Plugin</plugin> | ||
<plugin>Codelicia\XulietaJson\Plugin</plugin> | ||
</xulieta> |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 codelicia | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,29 @@ | ||
🌹 Xulieta - Json | ||
================= | ||
|
||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> | ||
[](#contributors-) | ||
<!-- ALL-CONTRIBUTORS-BADGE:END --> | ||
|
||
This is a plugin to lint Json on Documentation file using [Xulieta](https://github.com/codelicia/xulieta). | ||
|
||
## Contributors ✨ | ||
|
||
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): | ||
|
||
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> | ||
<!-- prettier-ignore-start --> | ||
<!-- markdownlint-disable --> | ||
<table> | ||
<tr> | ||
<td align="center"><a href="http://about:blank"><img src="https://avatars0.githubusercontent.com/u/398034?v=4" width="100px;" alt=""/><br /><sub><b>Alexandre Eher</b></sub></a><br /><a href="#infra-EHER" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-EHER" title="Maintenance">🚧</a> <a href="https://github.com/codelicia/xulieta/commits?author=EHER" title="Code">💻</a></td> | ||
<td align="center"><a href="https://twitter.com/malukenho"><img src="https://avatars2.githubusercontent.com/u/3275172?v=4" width="100px;" alt=""/><br /><sub><b>Jefersson Nathan</b></sub></a><br /><a href="#infra-malukenho" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-malukenho" title="Maintenance">🚧</a> <a href="https://github.com/codelicia/xulieta/commits?author=malukenho" title="Code">💻</a></td> | ||
<td align="center"><a href="https://airton.dev"><img src="https://avatars1.githubusercontent.com/u/6540546?v=4" width="100px;" alt=""/><br /><sub><b>Airton Zanon</b></sub></a><br /> <a href="#infra-airtonzanon" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-airtonzanon" title="Maintenance">🚧</a> <a href="https://github.com/codelicia/xulieta/commits?author=airtonzanon"" title="Code">💻</a></td> | ||
</tr> | ||
</table> | ||
|
||
<!-- markdownlint-enable --> | ||
<!-- prettier-ignore-end --> | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
|
||
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! |
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,7 @@ | ||
{ | ||
"name": "codelicia/xulieta-json", | ||
"autoload": {"psr-4": {"Codelicia\\XulietaJson\\": "src/"}}, | ||
"require-dev": { | ||
"codelicia/xulieta": "^0.1.3" | ||
} | ||
} |
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,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Codelicia\XulietaJson; | ||
|
||
// @TODO rename | ||
use Codelicia\Xulieta\Plugin\Plugin as ICodeliciaPlugin; | ||
use Codelicia\Xulieta\Output\OutputFormatter; | ||
use Codelicia\Xulieta\External\Markinho; | ||
use Codelicia\Xulieta\ValueObject\Violation; | ||
use Symfony\Component\Finder\SplFileInfo; | ||
|
||
final class Plugin implements ICodeliciaPlugin | ||
{ | ||
/** @psalm-return list<non-empty-string> */ | ||
public function supportedExtensions(): array | ||
{ | ||
return ['md', 'rst']; | ||
} | ||
|
||
public function canHandle(SplFileInfo $file): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public function __invoke(SplFileInfo $file, OutputFormatter $output): bool | ||
{ | ||
foreach (Markinho::extractCodeBlocks($file->getPathname(), $file->getContents()) as $codeBlock) { | ||
if ($codeBlock->language() !== 'json') { | ||
continue; | ||
} | ||
|
||
try { | ||
json_decode($codeBlock->code(), true, 512, JSON_THROW_ON_ERROR); | ||
} catch (\Exception $ex) { | ||
$output->addViolation(new Violation($codeBlock, $ex->getMessage(), 0)); | ||
|
||
return false; | ||
} | ||
} | ||
} | ||
} |
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,10 @@ | ||
# File containing json with wrong syntax | ||
|
||
This should fail! :D | ||
|
||
```json | ||
{ | ||
"nosso": "", | ||
"erro": " | ||
} | ||
``` |