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 f7195ec commit b622e19
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
- [`newline-after-import`], new rule. ([#245], thanks [@singles])
- 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])
- [`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 @@ -200,6 +199,8 @@ for info on changes for earlier releases.
[`named`]: ./docs/rules/named.md
[`newline-after-import`]: ./docs/rules/newline-after-import.md

[#298]: https://github.com/benmosher/eslint-plugin-import/pull/298
[#297]: https://github.com/benmosher/eslint-plugin-import/pull/297
[#296]: https://github.com/benmosher/eslint-plugin-import/pull/296
[#289]: https://github.com/benmosher/eslint-plugin-import/pull/289
[#288]: https://github.com/benmosher/eslint-plugin-import/pull/288
Expand All @@ -222,6 +223,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 @@ -149,8 +149,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 b622e19

Please sign in to comment.