Skip to content

Commit 211f295

Browse files
committedJan 1, 2021
Improve ESM compatibility
Fixes #386
1 parent d801095 commit 211f295

File tree

6 files changed

+21
-23
lines changed

6 files changed

+21
-23
lines changed
 

Diff for: ‎config/plugins.js

+13-18
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ module.exports = {
152152
}
153153
],
154154

155+
// TODO: Remove this when https://github.com/sindresorhus/eslint-plugin-unicorn/pull/977 is out.
156+
'unicorn/import-index': 'off',
157+
155158
// TODO: Disabled for now as I don't have time to deal with the backslash that might come from this. Try to enable this rule in 2021.
156159
'unicorn/no-null': 'off',
157160

@@ -179,20 +182,17 @@ module.exports = {
179182
'import/export': 'error',
180183
'import/extensions': [
181184
'error',
185+
'always',
182186
{
183-
js: 'never',
184-
jsx: 'never',
185-
json: 'always',
186-
svg: 'always',
187-
css: 'always'
187+
ignorePackages: true
188188
}
189189
],
190190

191-
// Disabled as it causes problems with TypeScript when you use mixed ESM and CommonJS
192-
// TODO: Enable again when I target only ESM
191+
// Disabled as it causes problems with TypeScript when you use mixed ESM and CommonJS.
192+
// TODO: Enable again when I target only ESM.
193193
// 'import/first': 'error',
194194

195-
// Disabled as it doesn't work with TypeScript
195+
// Disabled as it doesn't work with TypeScript.
196196
// This issue and some others: https://github.com/benmosher/eslint-plugin-import/issues/1341
197197
// 'import/named': 'error',
Has comments. Original line has comments.
198198

@@ -211,12 +211,7 @@ module.exports = {
211211
// Enable this sometime in the future when Node.js has ES2015 module support
212212
// 'import/no-cycle': 'error'
213213

214-
'import/no-useless-path-segments': [
215-
'error',
216-
{
217-
noUselessIndex: true
218-
}
219-
],
214+
'import/no-useless-path-segments': 'error',
220215

221216
// Disabled as it doesn't work with TypeScript
222217
// 'import/newline-after-import': 'error',
@@ -242,7 +237,7 @@ module.exports = {
242237
// 'import/no-unresolved': [
243238
// 'error',
244239
// {
245-
// commonjs: true
240+
// commonjs: false
246241
// }
247242
// ],
248243

@@ -264,11 +259,11 @@ module.exports = {
264259
}
265260
],
266261

267-
// Redundant with import/no-extraneous-dependencies
262+
// Redundant with `import/no-extraneous-dependencies`.
268263
// 'node/no-extraneous-import': 'error',
269264
// 'node/no-extraneous-require': 'error',
270265

271-
// Redundant with import/no-unresolved
266+
// Redundant with `import/no-unresolved`.
272267
// 'node/no-missing-import': 'error',
273268
// 'node/no-missing-require': 'error',
274269

@@ -357,7 +352,7 @@ module.exports = {
357352
'eslint-comments/no-aggregating-enable': 'error',
358353
'eslint-comments/no-duplicate-disable': 'error',
359354

360-
// Disabled as it's already covered by the `unicorn/no-abusive-eslint-disable` rule
355+
// Disabled as it's already covered by the `unicorn/no-abusive-eslint-disable` rule.
361356
// 'eslint-comments/no-unlimited-disable': 'error',
362357

363358
'eslint-comments/no-unused-disable': 'error',

Diff for: ‎package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@
109109
"webpack": "^5.10.0"
110110
},
111111
"eslintConfig": {
112-
"extends": "eslint-config-xo"
112+
"extends": "eslint-config-xo",
113+
"rules": {
114+
"unicorn/import-index": "off"
115+
}
113116
},
114117
"eslintIgnore": [
115118
"test/fixtures"

Diff for: ‎test/fixtures/overrides/test/bar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava'
2-
import fn from '..'
2+
import fn from '../index.js'
33

44
test('main', t => {
55
t.is(fn('foo'), fn('foobar'))

Diff for: ‎test/fixtures/overrides/test/foo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava'
2-
import fn from '..'
2+
import fn from '../index.js'
33

44
test('main', t => {
55
t.is(fn('foo'), fn('foobar'))

Diff for: ‎test/fixtures/webpack/no-config/file3.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import _ from '!./file2'; // eslint-disable-line no-unused-vars
1+
import _ from '!./file2.js'; // eslint-disable-line no-unused-vars

Diff for: ‎test/lint-files.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ test('webpack import resolver is used if {webpack: true}', async t => {
260260
}
261261
});
262262

263-
t.is(results[0].errorCount, 0);
263+
t.is(results[0].errorCount, 0, JSON.stringify(results[0]));
264264
});
265265

266266
async function configType(t, {dir}) {

0 commit comments

Comments
 (0)
Please sign in to comment.