Skip to content

Commit

Permalink
Merge pull request #6 from atk4/csfixer
Browse files Browse the repository at this point in the history
Code fixer and linter
  • Loading branch information
ibelar authored Sep 21, 2021
2 parents b73a4f5 + bf0654d commit 682a75f
Show file tree
Hide file tree
Showing 16 changed files with 3,596 additions and 459 deletions.
70 changes: 70 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in([__DIR__])
->exclude([
'cache',
'build',
'vendor',
]);

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'@PHP74Migration:risky' => true,
'@PHP74Migration' => true,

// required by PSR-12
'concat_space' => [
'spacing' => 'one',
],

// disable some too strict rules
'phpdoc_types' => [
// keep enabled, but without "alias" group to not fix
// "Callback" to "callback" in phpdoc
'groups' => ['simple', 'meta']
],
'phpdoc_types_order' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'none',
],
'single_line_throw' => false,
'yoda_style' => [
'equal' => false,
'identical' => false,
],
'native_constant_invocation' => true,
'native_function_invocation' => false,
'void_return' => false,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'exit'],
],
'combine_consecutive_issets' => false,
'combine_consecutive_unsets' => false,
'multiline_whitespace_before_semicolons' => false,
'no_superfluous_elseif' => false,
'ordered_class_elements' => false,
'php_unit_internal_class' => false,
'php_unit_test_case_static_method_calls' => [
'call_type' => 'this',
],
'php_unit_test_class_requires_covers' => false,
'phpdoc_add_missing_param_annotation' => false,
'return_assignment' => false,
'comment_to_phpdoc' => false,
'general_phpdoc_annotation_remove' => [
'annotations' => ['author', 'copyright', 'throws'],
],
'nullable_type_declaration_for_default_null_value' => [
'use_nullable_type_declaration' => false,
],

// fn => without curly brackets is less readable,
// also prevent bounding of unwanted variables for GC
'use_arrow_functions' => false,
])
->setFinder($finder)
->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer.' . md5(__DIR__) . '.cache');
4 changes: 2 additions & 2 deletions demos/google-address-componnent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
declare(strict_types=1);

use Atk4\GoogleAddress\Form\Control\AddressLookup;
use Atk4\GoogleAddress\Utils\Type;
use Atk4\GoogleAddress\Utils\JsLoader;
use Atk4\GoogleAddress\Utils\Type;
use Atk4\Ui\Form;

/** @var \Atk4\Ui\App $app */
// @var \Atk4\Ui\App $app

// Set Google developer key.
JsLoader::setGoogleApiKey('');
Expand Down
5 changes: 2 additions & 3 deletions demos/google-address-mapped.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
/** @var \Atk4\Ui\App $app */

use Atk4\GoogleAddress\Form\Control\AddressLookup;
use Atk4\GoogleAddress\Utils\Value;
use Atk4\GoogleAddress\Utils\Type;
use Atk4\GoogleAddress\Utils\Build;
use Atk4\GoogleAddress\Utils\JsLoader;
use Atk4\GoogleAddress\Utils\Type;
use Atk4\GoogleAddress\Utils\Value;
use Atk4\Ui\Form;

// Set Google developer key.
Expand All @@ -20,7 +20,6 @@

$latLngValue = Build::with(Value::of(Type::LAT))->concat(Value::of(Type::LNG))->glueWith(':');


$form = Form::addTo($app);

/** @var AddressLookup $ga */
Expand Down
20 changes: 20 additions & 0 deletions js/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true
},
extends: 'standard',
parserOptions: {
ecmaVersion: '2020',
sourceType: 'module'
},
globals: {
atk: true,
$: true,
google: true
},
rules: {
semi: ['error', 'always']
}
};
8 changes: 4 additions & 4 deletions js/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ const presets = [
{
targets: '> 1% , not dead',
corejs: { version: '3.6', proposals: true },
useBuiltIns: 'usage',
},
useBuiltIns: 'usage'
}
],
{
plugins: ['@babel/plugin-transform-runtime'],
},
plugins: ['@babel/plugin-transform-runtime']
}
];

module.exports = { presets: presets };
Loading

0 comments on commit 682a75f

Please sign in to comment.