Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reboot Lint & format #1173

Merged
merged 11 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module.exports = {
'!tools/tableau',
'!tools/tags',
'!tools/templates',
'!tools/toc'
'!tools/toc',
'tools/aceditor/presentation/javascripts/ext-searchbox.js'
]
}
20 changes: 10 additions & 10 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ In the interest of fostering an open and welcoming environment, we as contributo

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Expand Down
9 changes: 4 additions & 5 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ Interesting in contributing? Awesome!

**Quick Links:**

* [Give your feedback](#give-your-feedback)
* [Write documentation](#write-documentation)
* [Develop](#develop)

- [Give your feedback](#give-your-feedback)
- [Write documentation](#write-documentation)
- [Develop](#develop)

## Give your feedback

Expand Down Expand Up @@ -44,4 +43,4 @@ Then, just go in the browser to start the installation procedure.
### Coding standards

It's a work in progress but we try to follow the [PHP PSR-2 standards](https://www.php-fig.org/psr/psr-2/).
As for Javascript, a linter (like eslint) can be used to check the code.
As for Javascript, a linter (like eslint) can be used to check the code.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/Custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ about: Describe a bug / Remonter un bogue
title: ''
labels: ''
assignees: ''

---

> [!NOTE]
Expand All @@ -19,6 +18,7 @@ assignees: ''
Explain the bug / expliquer le bogue

**Additionnal informations / Informations complémentaires**

- version of YesWiki / version de YesWiki
- url to see the problem or an example / url pour voir le probleme ou un exemple
- screenshot / capture d’écran
Expand Down
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
## Description of pull request / Description de la demande d'ajout

Describe what it does / Expliquer ce que cela fait
Issue references (if exists)/ Demande associée (si elle existe)
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ tools/*
*.iml

# vscode IDE
.vscode
!.vscode
.vscode/settings.json

# Docker
.db
Expand All @@ -125,4 +126,5 @@ docker-compose.local.yml
# Other
.phpintel/
*.old
.php-cs-fixer.cache
TODO
90 changes: 90 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->name('*.php')
->exclude('vendor')
->exclude('cache')
->exclude('node_modules');

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true, // Start with PSR-12 rules
'@Symfony' => true, // Add Symfony rules for more comprehensive formatting
// Additional custom rules
// https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/rules/index.rst
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => [
'default' => 'single_space'
],
'yoda_style' => false,
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'increment_style' => ['style' => 'post'],
'blank_line_before_statement' => [
'statements' => ['return']
],
'cast_spaces' => ['space' => 'none'],
'class_attributes_separation' => [
'elements' => ['method' => 'one']
],
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'function_declaration' => ['closure_function_spacing' => 'one'],
'include' => true,
'indentation_type' => true,
'lowercase_cast' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'new_with_braces' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => [
'tokens' => [
'extra',
'throw',
'use',
'use_trait',
'curly_brace_block',
'parenthesis_brace_block',
'square_brace_block',
'switch',
'case',
'default',
],
],
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => ['use' => 'echo'],
'no_multiline_whitespace_around_double_arrow' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_around_offset' => ['positions' => ['inside', 'outside']],
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unused_imports' => false,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'semicolon_after_instruction' => true,
'short_scalar_cast' => true,
'single_blank_line_at_eof' => true,
'single_class_element_per_statement' => ['elements' => ['property']],
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'space_after_semicolon' => ['remove_in_empty_for_expressions' => true],
'standardize_not_equals' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
])
->setFinder($finder)
->setUsingCache(false); // Adjust cache settings as needed
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/vendor/**
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
4 changes: 0 additions & 4 deletions .stylelintignore

This file was deleted.

3 changes: 0 additions & 3 deletions .stylelintrc.json

This file was deleted.

8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"mhutchie.git-graph",
"junstyle.php-cs-fixer",
"dbaeumer.vscode-eslint"
]
}
23 changes: 23 additions & 0 deletions .vscode/settings.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"php-cs-fixer.executablePath": "/var/www/html/vendor/bin/php-cs-fixer",
"php-cs-fixer.ignorePHPVersion": true,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[php]": {
"editor.defaultFormatter": "junstyle.php-cs-fixer"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always"
},
"[twig]": {
"editor.formatOnSave": false,
"editor.formatOnPaste": false
},
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,14 @@ yarn-install: yarn.lock ## Install npm vendors according to the current yarn.loc
## —— Tests ———————————————
test: ## Launch unit tests
./vendor/bin/phpunit --do-not-cache-result --stderr tests

## —— Linters & Formatters ———————————————
lint: lint-php lint-js lint-other ## run all linters and formatters

lint-php: ## Lint php
PHP_CS_FIXER_IGNORE_ENV=false ./vendor/bin/php-cs-fixer fix
lint-js: ## Lint JS
yarn run lint-js
lint-other: ## Lint other files
yarn run lint-js
yarn run lint-other
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ YesWiki can be installed in about ten minutes on a server which supports **PHP >

We are using [weblate](https://hosted.weblate.org/yeswiki) to translate our software!

## Developers

We recommand an installation through docker.

### Linters & Formatters

Please install relevant extension and enable auto formating on your editor.

Alternatly you can run `make lint`

| Language | Linter/Formatter |
| --------------------------- | ------------------------------------------------------------ |
| Php | `php-cs-fixer` |
| Javascript | `eslint` |
| Twig | no automatic linter. Couldn't find one which is good enough. |
| CSS, Yaml, JSON, Markdown.. | `prettier` |

If you use VS Codium, get yeswiki linting settings with `cp .vscode/settings.example.json .vscode/settings.json`

## History

YesWiki grew out of a French language version of [WakkaWiki](https://en.wikipedia.org/wiki/WakkaWiki) called [Wikini](http://wikini.net), and hence has strong French language support.
Expand All @@ -41,8 +60,8 @@ YesWiki grew out of a French language version of [WakkaWiki](https://en.wikipedi
- 2002, 2003, 2004 David DELON
- 2002, 2003, 2004 Charles NEPOTE
- 2002, 2003, 2004 Patrick PAUL
- 2003 Eric DELORD
- 2003, 2004 Eric FELDSTEIN
- 2003 Eric DELORD
- 2003, 2004 Eric FELDSTEIN
- 2003 Jean-Pascal MILCENT
- 2003 Jéréme DESQUILBET
- 2003 Erus UMBRAE
Expand Down
12 changes: 6 additions & 6 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
The two last major versions of YesWiki are
currently being supported with security updates.

| Version | Supported |
| ------------------- | ------------------ |
| doryphore 4.x | :white_check_mark: |
| cercopitheque 3.x | :white_check_mark: |
| bachibouzouk 2.x | :x: |
| anacoluthe 1.x | :x: |
| Version | Supported |
| ----------------- | ------------------ |
| doryphore 4.x | :white_check_mark: |
| cercopitheque 3.x | :white_check_mark: |
| bachibouzouk 2.x | :x: |
| anacoluthe 1.x | :x: |

## Reporting a Vulnerability

Expand Down
13 changes: 7 additions & 6 deletions actions/AdminBackupsAction.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Admin backups
* Admin backups.
*/
use YesWiki\Core\YesWikiAction;
use YesWiki\Core\Service\ArchiveService;
use YesWiki\Core\YesWikiAction;

class AdminBackupsAction extends YesWikiAction
{
Expand All @@ -12,8 +12,8 @@ public function run()
if (!$this->wiki->UserIsAdmin()) {
return $this->render('@templates/alert-message.twig', [
'type' => 'danger',
'message' => get_class($this)." : " . _t('BAZ_NEED_ADMIN_RIGHTS')
]) ;
'message' => get_class($this) . ' : ' . _t('BAZ_NEED_ADMIN_RIGHTS'),
]);
}
$status = $this->getService(ArchiveService::class)->getArchivingStatus();
if (!$status['canArchive']) {
Expand All @@ -32,12 +32,13 @@ public function run()
} elseif ($status['dB'] == false) {
$message = _t('ADMIN_BACKUPS_MESSAGE_DB_NOT_ARCHIVABLE');
}

return $this->render('@templates/alert-message.twig', [
'type' => 'warning',
'message' => _t('ADMIN_BACKUPS_MESSAGE_ARCHIVE_CANNOT_BE_DONE').' '.$message.'<br /><a href="?doc#/docs/fr/admin?id=résoudre-les-problèmes-de-sauvegarde">'._t('ADMIN_BACKUPS_MESSAGE_SEE_DOC').'</a>.'
'message' => _t('ADMIN_BACKUPS_MESSAGE_ARCHIVE_CANNOT_BE_DONE') . ' ' . $message . '<br /><a href="?doc#/docs/fr/admin?id=résoudre-les-problèmes-de-sauvegarde">' . _t('ADMIN_BACKUPS_MESSAGE_SEE_DOC') . '</a>.',
]);

}

return $this->render('@core/actions/admin-backups.twig', [
]);
}
Expand Down
11 changes: 6 additions & 5 deletions actions/AdminReactionsAction.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* Admin all reactions
* Admin all reactions.
*/
use YesWiki\Core\YesWikiAction;
use YesWiki\Core\Service\ReactionManager;
use YesWiki\Core\YesWikiAction;

class AdminReactionsAction extends YesWikiAction
{
Expand All @@ -12,17 +12,18 @@ public function run()
if ($this->wiki->UserIsAdmin()) {
$allReactions = $this->wiki->services->get(ReactionManager::class)->getReactions();
foreach ($allReactions as $k => $reactions) {
usort($reactions["reactions"], function ($a, $b) { // sort by user
usort($reactions['reactions'], function ($a, $b) { // sort by user
return strnatcasecmp($a['user'], $b['user']);
});
}

return $this->render('@core/admin-reactions-table.twig', [
'reactions' => $allReactions
'reactions' => $allReactions,
]);
} else {
return $this->render('@templates/alert-message.twig', [
'type' => 'info',
'message' => _t('REACTION_CONNECT_AS_ADMIN')
'message' => _t('REACTION_CONNECT_AS_ADMIN'),
]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion actions/CommentsAction.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use YesWiki\Core\YesWikiAction;
use YesWiki\Core\Service\CommentService;
use YesWiki\Core\YesWikiAction;

class CommentsAction extends YesWikiAction
{
Expand Down
Loading
Loading