Skip to content

Commit

Permalink
default to all extensions valid to avoid breaking change until semver…
Browse files Browse the repository at this point in the history
…-next
  • Loading branch information
benmosher committed May 5, 2016
1 parent 7775f34 commit 0428768
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
- Added an `optionalDependencies` option to [`no-extraneous-dependencies`] to allow/forbid optional dependencies ([#266], thanks [@jfmengels]).
- Added `newlines-between` option to [`order`] rule ([#298], thanks [@singles])
- add [`no-mutable-exports`] rule ([#290], thanks [@josh])
- [`import/extensions` setting]: a whitelist of file extensions to parse as modules
and search for `export`s. If unspecified, all extensions are considered valid (for now).
In v2, this will likely default to `['.js', MODULE_EXT]`,. ([#297], to fix [#267])

### Fixed
- [`extensions`]: fallback to source path for extension enforcement if imported
module is not resolved. Also, never report for builtins (i.e. `path`). ([#296])

### Breaking
- [`import/extensions` setting]: a whitelist of file extensions to parse as modules
and search for `export`s. Defaults to `['.js']`.

## resolvers/webpack/0.2.4 - 2016-04-29
### Changed
- automatically find webpack config with `interpret`-able extensions ([#287], thanks [@taion])
Expand Down Expand Up @@ -203,6 +202,10 @@ for info on changes for earlier releases.
[`no-mutable-exports`]: ./docs/rules/no-mutable-exports.md

[#298]: https://github.com/benmosher/eslint-plugin-import/pull/298
<<<<<<< 7775f344b90aa44c446d596e4e137d6a725bf5e8
=======
[#297]: https://github.com/benmosher/eslint-plugin-import/pull/297
>>>>>>> default to all extensions valid to avoid breaking change until semver-next
[#296]: https://github.com/benmosher/eslint-plugin-import/pull/296
[#290]: https://github.com/benmosher/eslint-plugin-import/pull/290
[#289]: https://github.com/benmosher/eslint-plugin-import/pull/289
Expand All @@ -226,6 +229,7 @@ for info on changes for earlier releases.
[#286]: https://github.com/benmosher/eslint-plugin-import/issues/286
[#281]: https://github.com/benmosher/eslint-plugin-import/issues/281
[#272]: https://github.com/benmosher/eslint-plugin-import/issues/272
[#267]: https://github.com/benmosher/eslint-plugin-import/issues/267
[#266]: https://github.com/benmosher/eslint-plugin-import/issues/266
[#216]: https://github.com/benmosher/eslint-plugin-import/issues/216
[#214]: https://github.com/benmosher/eslint-plugin-import/issues/214
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ You may set the following settings in your `.eslintrc`:
#### `import/extensions`

A whitelist of file extensions that will be parsed as modules and inspected for
`export`s. This defaults to `['.js']`, unless you are using the `react` shared config,
in which case it is specified as `['.js', '.jsx']`.
`export`s.

This will default to `['.js']` in the next major revision of this plugin, unless
you are using the `react` shared config, in which case it is specified as `['.js', '.jsx']`.

Note that this is different from (and likely a subset of) any `import/resolver`
extensions settings, which may include `.json`, `.coffee`, etc. which will still
Expand Down
7 changes: 6 additions & 1 deletion src/core/ignore.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ function validExtensions({ settings }) {

// todo: add 'mjs'?
lastSettings = settings
cachedSet = new Set(settings['import/extensions'] || [ '.js' ])
// breaking: default to '.js'
// cachedSet = new Set(settings['import/extensions'] || [ '.js' ])
cachedSet = 'import/extensions' in settings
? new Set(settings['import/extensions'])
: { has: () => true } // the set of all elements

return cachedSet
}

Expand Down
5 changes: 4 additions & 1 deletion tests/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export const SYNTAX_CASES = [
test({ code: 'export default class x {}' }),

// issue #267: parser whitelist
test({ code: 'import json from "./data.json"' }),
test({
code: 'import json from "./data.json"',
settings: { 'import/extensions': ['.js'] }, // breaking: remove for v2
}),

]

0 comments on commit 0428768

Please sign in to comment.