From 1519004997cda72939be617b40da6829ac1424b8 Mon Sep 17 00:00:00 2001 From: Aaron Carlino Date: Mon, 6 Nov 2017 16:25:54 +1300 Subject: [PATCH] Initial commit --- .eslintrc.js | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++ index.js | 3 ++ package.json | 41 +++++++++++++++++ 3 files changed, 169 insertions(+) create mode 100644 .eslintrc.js create mode 100644 index.js create mode 100644 package.json diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..234ac0b --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,125 @@ +// turn these back on progressively +const todo = { + 'react/jsx-filename-extension': [ + // most disruptive with the file renames + 'off' + ], + 'react/require-default-props': [ + // very useful for future development and generating test/storybook mocks + 'off' + ], + 'react/prop-types': [ + // useful for getting a clear indication of a component's signature + 'off', + { + // shouldn't need to define children, also ineffective to use `PropTypes.node` as it still fails for stateless components + ignore: ['children'] + } + ], + 'comma-dangle': [ + 'off' + ], + 'arrow-parens': [ + 'off' + ], + 'indent': [ + 'off' + ], + 'react/no-find-dom-node': [ + // can use refs instead + 'off', + ], +}; + +module.exports = { + 'extends': 'airbnb', + 'env': { + 'jasmine': true + }, + 'rules': Object.assign({}, + todo, + { + // turned off because the PHP side returns dangling properties which trigger this... + // could revise later and add exceptions for PHP data + 'no-underscore-dangle': [ + 'off', + { + 'allow': [ + '_t' + ], + 'allowAfterThis': true + } + ], + 'no-unused-vars': [ + 'error', + { + 'vars': 'local' + } + ], + // increased to error because it's strongly discouraged + 'react/no-danger': [ + 'error' + ], + 'no-plusplus': [ + 'error', + { + 'allowForLoopAfterthoughts': true + } + ], + 'react/no-unused-prop-types': [ + // we want to capture prop types that aren't used + 'error' + ], + // May revise this when as we get more cleanup done + 'react/forbid-prop-types': [ + 'off' + ], + 'import/prefer-default-export': [ + 'off' + ], + 'import/first': [ + 'off' + ], + 'class-methods-use-this': [ + 'off' + ], + // this one makes no sense in some regex contexts + 'no-useless-escape': [ + 'off' + ], + // these accessibility rules will be a detriment to existing code/styles, + // perhaps in the future + 'jsx-a11y/href-no-hash': [ + 'off' + ], + 'jsx-a11y/iframe-has-title': [ + 'off' + ], + 'jsx-a11y/anchor-has-content': [ + 'off' + ], + }), + 'settings': { + 'import/extensions': [ + '.js', + '.jsx' + ], + 'import/resolver': { + 'node': { + 'extensions': [ + '.js', + '.jsx' + ], + 'moduleDirectory': [ + '.', + 'client/src', + '../admin/client/src', + '../admin/node_modules', + 'vendor/silverstripe/admin/client/src', + 'vendor/silverstripe/admin/node_modules', + 'node_modules' + ] + } + } + } +}; \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..af65f49 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +const config = require('./.eslintrc'); + +export default config; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..50f84a9 --- /dev/null +++ b/package.json @@ -0,0 +1,41 @@ +{ + "name": "@silverstripe/eslint-config", + "version": "0.0.1", + "description": "SilverStripe config files for eslint", + "engines": { + "node": ">= 6.x" + }, + "bin": { + "eslint": "./node_modules/.bin/eslint" + }, + "main": "index.js", + "repository": { + "type": "git", + "url": "git://github.com/silverstripe/eslint-config.git" + }, + "keywords": [ + "silverstripe", + "eslint", + "config", + "modules", + "react" + ], + "author": "SilverStripe Ltd", + "license": "BSD-3-Clause", + "bugs": { + "url": "https://github.com/silverstripe/eslint-config/issues" + }, + "homepage": "https://github.com/silverstripe/eslint-config", + "dependencies": { + "eslint": "^4.6.1", + "eslint-config-airbnb": "^15.1.0", + "eslint-config-airbnb-base": "^12.0.0", + "eslint-loader": "^1.7.1", + "eslint-plugin-import": "^2.7.0", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-react": "^7.3.0" + }, + "resolutions": { + "eslint": "^4.6.1" + } +}