├── .editorconfig ├── .gitattributes ├── .gitignore ├── .travis.yml ├── README.md ├── eslintrc.json ├── index.js ├── license ├── package.json └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [{package.json,*.yml}] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.psd binary 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: node_js 4 | 5 | node_js: 6 | - 6 7 | - 4 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Airbnb Flow - ESLint Shareable Config 2 | [![travis][travis-image]][travis-url] 3 | [![npm][npm-image]][npm-url] 4 | [![downloads][downloads-image]][downloads-url] 5 | 6 | [travis-image]: https://img.shields.io/travis/johnie/eslint-config-airbnb-flow/master.svg 7 | [travis-url]: https://travis-ci.org/johnie/eslint-config-airbnb-flow 8 | [npm-image]: https://img.shields.io/npm/v/eslint-config-airbnb-flow.svg 9 | [npm-url]: https://npmjs.org/package/eslint-config-airbnb-flow 10 | [downloads-image]: https://img.shields.io/npm/dm/eslint-config-airbnb-flow.svg 11 | [downloads-url]: https://npmjs.org/package/eslint-config-airbnb-flow 12 | 13 | > An ESLint [Shareable Config](http://eslint.org/docs/developer-guide/shareable-configs) for Flow support in [Airbnb JavaScript Style](https://github.com/airbnb/javascript) 14 | 15 | ## Install 16 | 17 | ```bash 18 | npm install eslint-config-airbnb-flow 19 | ``` 20 | 21 | ## Usage 22 | 23 | Shareable configs are designed to work with the `extends` feature of `.eslintrc` files. 24 | You can learn more about [Shareable Configs](http://eslint.org/docs/developer-guide/shareable-configs) on the official ESLint website. 25 | 26 | This Shareable Config adds Flow to the baseline Airbnb JavaScript Style rules provided in `eslint-config-airbnb`. 27 | 28 | Here's how to install everything you need: 29 | 30 | ```bash 31 | npm install eslint-config-airbnb eslint-config-airbnb-flow 32 | ``` 33 | 34 | Then, add this to your .eslintrc file: 35 | 36 | ``` 37 | { 38 | "extends": ["airbnb", "airbnb-flow"] 39 | } 40 | ``` 41 | 42 | *Note: We omitted the `eslint-config-` prefix since it is automatically assumed by ESLint.* 43 | 44 | You can override settings from the shareable config by adding them directly into your `.eslintrc` file. 45 | 46 | ## Learn more 47 | 48 | For the full listing of rules, editor plugins, FAQs, and more, visit the main [Airbnb JavaScript Style repo](https://github.com/airbnb/javascript). 49 | 50 | ## License 51 | 52 | MIT © [Johnie Hjelm](https://johnie.com) 53 | -------------------------------------------------------------------------------- /eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "extends": "airbnb", 4 | "plugins": [ 5 | "flowtype", 6 | "import" 7 | ], 8 | "rules": { 9 | "space-infix-ops": 0, 10 | "no-duplicate-imports": 0, 11 | "import/no-duplicates": 1, 12 | "flowtype/define-flow-type": 1, 13 | "flowtype/space-before-type-colon": [ 14 | 1, 15 | "never" 16 | ], 17 | "flowtype/use-flow-type": 1, 18 | "flowtype/valid-syntax": 1, 19 | "flowtype/type-id-match": [ 20 | 2, 21 | "^([A-Z]+[a-z0-9A-Z]*)$" 22 | ] 23 | }, 24 | "settings": { 25 | "flowtype": { 26 | "onlyFilesWithFlowAnnotation": false 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = Object.assign({}, require('./eslintrc.json'), { 2 | extends: [require.resolve('eslint-config-airbnb')] 3 | }); 4 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Johnie Hjelm (johnie.se) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eslint-config-airbnb-flow", 3 | "version": "1.0.2", 4 | "description": "Airbnb JavaScript Style Flow support - ESLint Shareable Config", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "xo && ava" 8 | }, 9 | "files": [ 10 | "index.js", 11 | "eslintrc.json" 12 | ], 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/johnie/eslint-config-airbnb-flow.git" 16 | }, 17 | "keywords": [ 18 | "Airbnb JavaScript Style", 19 | "check", 20 | "checker", 21 | "code", 22 | "code checker", 23 | "code linter", 24 | "code style", 25 | "enforce", 26 | "eslint", 27 | "eslintconfig", 28 | "hint", 29 | "jscs", 30 | "jshint", 31 | "lint", 32 | "policy", 33 | "quality", 34 | "flow", 35 | "simple", 36 | "airbnb", 37 | "airbnb style", 38 | "style", 39 | "style checker", 40 | "style linter", 41 | "verify" 42 | ], 43 | "author": "Johnie Hjelm (http://johnie.se)", 44 | "license": "MIT", 45 | "bugs": { 46 | "url": "https://github.com/johnie/eslint-config-airbnb-flow/issues" 47 | }, 48 | "homepage": "https://github.com/johnie/eslint-config-airbnb-flow#readme", 49 | "devDependencies": { 50 | "ava": "*", 51 | "xo": "*", 52 | "eslint": "^3.6.0" 53 | }, 54 | "dependencies": { 55 | "babel-eslint": "^6.1.2", 56 | "eslint-config-airbnb": "^12.0.0", 57 | "eslint-plugin-flowtype": "^2.19.0", 58 | "eslint-plugin-flowtype-errors": "^1.1.0", 59 | "eslint-plugin-import": "^1.16.0", 60 | "eslint-plugin-jsx-a11y": "^2.2.2", 61 | "eslint-plugin-promise": "^2.0.1", 62 | "eslint-plugin-react": "^6.3.0" 63 | }, 64 | "xo": { 65 | "esnext": true 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import test from 'ava'; 2 | import {CLIEngine} from 'eslint'; 3 | import config from './'; 4 | 5 | const isObject = obj => typeof obj === 'object' && obj !== null; 6 | const isString = value => typeof value === 'string'; 7 | 8 | const code = ` 9 | const CONVERSION_TABLE = { 10 | m: { 11 | km: m => m / 1000, 12 | mi: m => m * 0.000621371, 13 | }, 14 | }; 15 | 16 | function convertUnit(from: string, to: string, value: number): number { 17 | const transform = CONVERSION_TABLE[from][to]; 18 | 19 | return transform(value); 20 | } 21 | 22 | convertUnit('m', 'km', 1000); 23 | `; 24 | 25 | test('test basic properties of config', t => { 26 | t.is(isString(config.parser), true); 27 | t.is(isObject(config.rules), true); 28 | t.is(Array.isArray(config.plugins), true); 29 | }); 30 | 31 | test('load config in eslint to validate all rule syntax is correct', t => { 32 | const cli = new CLIEngine({ 33 | useEslintrc: false, 34 | configFile: 'eslintrc.json' 35 | }); 36 | 37 | t.is(cli.executeOnText(code).errorCount === 0, true); 38 | }); 39 | --------------------------------------------------------------------------------