From 7cefeb7515eed41ebf98626aac54a0cb9666a50e Mon Sep 17 00:00:00 2001 From: Ben Mosher Date: Thu, 7 Jul 2016 06:48:55 -0400 Subject: [PATCH] recommended shared config (#402) --- CHANGELOG.md | 6 ++++++ config/react.js | 12 +++++++++++- config/recommended.js | 27 +++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 config/recommended.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 689dcf56a3..47f9a86adb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ This project adheres to [Semantic Versioning](http://semver.org/). This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com). ## [Unreleased] +### Added +- `recommended` shared config. Roughly `errors` and `warnings` mixed together, + with some `parserOptions` in the mix. ([#402]) +- `react` shared config: added `jsx: true` to `parserOptions.ecmaFeatures`. + ### Breaking - [`import/extensions` setting] defaults to `['.js']`. ([#306]) - [`import/ignore` setting] defaults to nothing, and ambiguous modules are ignored natively. This means importing from CommonJS modules will no longer be reported by [`default`], [`named`], or [`namespace`], regardless of `import/ignore`. ([#270]) @@ -280,6 +285,7 @@ for info on changes for earlier releases. [#157]: https://github.com/benmosher/eslint-plugin-import/pull/157 [#314]: https://github.com/benmosher/eslint-plugin-import/pull/314 +[#402]: https://github.com/benmosher/eslint-plugin-import/issues/402 [#386]: https://github.com/benmosher/eslint-plugin-import/issues/386 [#373]: https://github.com/benmosher/eslint-plugin-import/issues/373 [#370]: https://github.com/benmosher/eslint-plugin-import/issues/370 diff --git a/config/react.js b/config/react.js index c8bd7ade91..fe1b5f2ec1 100644 --- a/config/react.js +++ b/config/react.js @@ -1,8 +1,18 @@ /** - * - adds `.jsx` as an extension + * Adds `.jsx` as an extension, and enables JSX parsing. + * + * Even if _you_ aren't using JSX (or .jsx) directly, if your dependencies + * define jsnext:main and have JSX internally, you may run into problems + * if you don't enable these settings at the top level. */ module.exports = { + settings: { 'import/extensions': ['.js', '.jsx'], }, + + parserOptions: { + ecmaFeatures: { jsx: true }, + }, + } diff --git a/config/recommended.js b/config/recommended.js new file mode 100644 index 0000000000..a4f557ef38 --- /dev/null +++ b/config/recommended.js @@ -0,0 +1,27 @@ +/** + * The basics. + * @type {Object} + */ +module.exports = { + rules: { + // analysis/correctness + 'import/no-unresolved': 'error', + 'import/named': 'error', + 'import/namespace': 'error', + 'import/default': 'error', + 'import/export': 'error', + + // red flags (thus, warnings) + 'import/no-named-as-default': 'warn', + 'import/no-named-as-default-member': 'warn', + 'import/no-duplicates': 'warn', + }, + + // need all these for parsing dependencies (even if _your_ code doesn't need + // all of them) + parserOptions: { + sourceType: 'module', + ecmaVersion: 6, + ecmaFeatures: { experimentalObjectRestSpread: true }, + }, +}