The coding standards in the LIN3S way.
This package is created to centralize all the checks style of LIN3S projects, in an easy way to install all the tools and improving the maintainability. It is a flexible and customizable solution to automatize all related with coding standards. This library is focused to PHP, Javascript and Sass projects.
This library is very focused to use as pre-commit hook so, this is the reason of Git PHP class exists. The checkers only validate the files that they are going to commit.
LIN3S's CS is a PHP console application so, it requires PHP itself. Apart of it, this library has the following requirements:
The recommended and the most suitable way to install is through Composer. Be sure that the tool is installed in your system and execute the following command:
$ composer require lin3s/cs --dev
Then you have to update the composer.json
with the following code:
"scripts": {
"lin3scs-scripts": [
"LIN3S\\CS\\Composer\\Hooks::buildDistFile",
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"LIN3S\\CS\\Composer\\Hooks::addHooks",
"LIN3S\\CS\\Composer\\Hooks::addFiles"
]
},
"extra": {
"incenteev-parameters": {
"file": ".lin3s_cs.yml",
"dist-file": ".lin3s_cs.yml.dist"
},
"scripts-dev": {
"post-install-cmd": [
"@lin3scs-scripts"
],
"post-update-cmd": [
"@lin3scs-scripts"
]
}
}
REMEMBER: The
.lin3s_cs.yml
file is generated dynamically with Composer. The best practices recommend that only track the.dist
file ignoring the.lin3s_cs.yml
inside.gitignore
. In the same way, we recommend that, also, dynamically generated.phpspec_cs
,.php_cs
,.stylelintrc.js
,.eslintrc.js
and.editorconfig
files, it should be ignored.
In LIN3S are building a lot of projects with React.js so, keeping in mind the simplicity of the configuration process the following lin3s are our requirements to standardize the JS code inside this environment.
# .lin3s_cs.yml
parameters:
# ...
eslint_rules:
plugins:
# ...
- react
rules:
react/display-name: off
react/forbid-prop-types: off
react/jsx-boolean-value: off
react/jsx-closing-bracket-location: off
react/jsx-curly-spacing: off
react/jsx-indent-props: off
react/jsx-max-props-per-line: off
react/jsx-no-duplicate-props: error
react/jsx-no-literals: off
react/jsx-no-undef: error
jsx-quotes: error
react/jsx-sort-props: error
react/jsx-uses-react: error
react/jsx-uses-vars: error
react/no-danger: error
react/no-did-mount-set-state: error
react/no-did-update-set-state: error
react/no-direct-mutation-state: error
react/no-set-state: off
react/no-unknown-property: error
react/prop-types: off
react/react-in-jsx-scope: off
react/require-extension: off
react/self-closing-comp: off
react/sort-comp: off
react/sort-prop-types: error
react/wrap-multilines: off