title: Integration of prettier with Intellij Idea and NPM
body: <p><strong>What I wanna achieve</strong></p>
  
  <ol>
  <li>Intellij - show error via red underline</li>
  <li>Validate formating via NPM</li>
  <li>Autoformating via save</li>
  <li>Override printWidth to 140</li>
  <li>Integrate with stylelint and tslint and file watcher</li>
  </ol>
  
  <p><strong>What I have done</strong></p>
  
  <p>stylelint.config.js</p>
  
  <pre><code>const regex = {
    pascal: "[A-Z][a-z]+[a-zA-Z]*",
    camel: "[a-z]+[a-zA-Z]*"
  };
  
  const componentElementModifier = `\\.${regex.pascal}(__${regex.camel}(_${regex.camel})?)?`;
  const componentModifier = `\\.${regex.pascal}_${regex.camel}`;
  const bemMix = `\\.${regex.pascal}__${regex.pascal}`;
  
  module.exports = {
    plugins: ["stylelint-prettier", "stylelint-selector-bem-pattern"],
    extends: ["stylelint-prettier/recommended"],
    rules: {
      "prettier/prettier": true,
      "plugin/selector-bem-pattern": {
        componentName: regex.pascal,
        implicitComponents: true,
        componentSelectors: {
          initial: `^(${componentElementModifier})$|^(${bemMix})$|^(${componentModifier})$`
        }
      }
    }
  };
  </code></pre>
  
  <p>tslint.json</p>
  
  <pre><code>{
    "extends": [
      "tslint:latest",
      "tslint-react",
      "tslint-plugin-prettier",
      "tslint-config-prettier"
    ],
    "rules": {
      "object-literal-sort-keys": false,
      "prettier": true,
      "no-default-export": true
    },
    "linterOptions": {
      "exclude": ["**/*.less.d.ts"]
    }
  }
  </code></pre>
  
  <p>Intellij Idea - File Watcher configuration</p>
  
  <p><a href="https://i.stack.imgur.com/V3GDf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V3GDf.png" alt="enter image description here"></a></p>
  
  <p>Intellij Idea - TSlint configuration
  <a href="https://i.stack.imgur.com/vCnXM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vCnXM.png" alt="enter image description here"></a></p>
  
  <p>Intellij Idea - Typescript configuration
  <a href="https://i.stack.imgur.com/d1uCn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d1uCn.png" alt="enter image description here"></a></p>
  
  <p>packge.json - stylelint config + runners</p>
  
  <p><a href="https://i.stack.imgur.com/F7K8p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F7K8p.png" alt="enter image description here"></a></p>
  
  <p><strong>What my questions</strong></p>
  
  <ol>
  <li>How to add printWidth 140 to all configs?</li>
  <li>How to share prittier config into tslint and stylelint?</li>
  <li>How to make it works with runners in package.json and file watcher</li>
  </ol>