2017 © Pedro Peláez
 

library cs

The coding standards in the LIN3S way

image

lin3s/cs

The coding standards in the LIN3S way

  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 28 Versions
  • 3 % Grown

The README.md

LIN3S CS

The coding standards in the LIN3S way., (*1)

SensioLabsInsight Build Status Scrutinizer Code Quality Total Downloads      Latest Stable Version Latest Unstable Version, (*2)

WHY?

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., (*3)

  • Checks if Composer json has changes, the lock must be committed too.
  • Fixes the PHP code with fully customizable PHP-CS-Fixer.
  • Lints the Twig files with [TwigCS][12].
  • Checks mess detections with [PHPMD][10].
  • Checks the Sass best practices with Stylelint.
  • Checks the code quality of Javascript files with ESLint.

This library is very focused to use as pre-commit hook so, this is the reason of [Git][11] PHP class exists. The checkers only validate the files that they are going to commit., (*4)

Prerequisites

LIN3S's CS is a PHP console application so, it requires PHP itself. Apart of it, this library has the following requirements:, (*5)

  1. Composer
$ curl -sS https://getcomposer.org/installer | php
  1. Node.js
$ npm install -g stylelint

```bash $ npm install -g eslint # >= v4.0.0 $ npm install -g eslint-plugin-class-property eslint-plugin-react eslint-plugin-babel babel-eslint, (*6)


## Getting started The recommended and the most suitable way to install is through [Composer][3]. Be sure that the tool is installed in your system and execute the following command:

$ composer require lin3s/cs --dev, (*7)

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" ] } }, (*8)


> 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. ## Use ESLint in a React.js environment 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. ```yml # .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

Licensing Options

License, (*9)

The Versions