Skip to content

Commit

Permalink
no-duplicates: Disable autofix for ESLint <= 3
Browse files Browse the repository at this point in the history
  • Loading branch information
lydell committed Mar 31, 2019
1 parent 9ac41f3 commit 71a64c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/rules/no-duplicates.js
Expand Up @@ -26,6 +26,11 @@ function checkImports(imported, context) {
}

function getFix(first, rest, sourceCode) {
// Sorry ESLint <= 3 users, no autofix for you.
if (typeof sourceCode.getCommentsBefore !== 'function') {
return undefined
}

const defaultImportNames = new Set(
[first, ...rest].map(getDefaultImportName).filter(Boolean)
)
Expand Down
6 changes: 5 additions & 1 deletion tests/src/rules/no-duplicates.js
@@ -1,11 +1,15 @@
import * as path from 'path'
import { test } from '../utils'
import { test as testUtil } from '../utils'

import { RuleTester } from 'eslint'

const ruleTester = new RuleTester()
, rule = require('rules/no-duplicates')

const test = process.env.ESLINT_VERSION === '3' || process.env.ESLINT_VERSION === '2'
? t => testUtil(Object.assign({}, t, {output: t.code}))
: testUtil

ruleTester.run('no-duplicates', rule, {
valid: [
test({ code: 'import "./malformed.js"' }),
Expand Down

0 comments on commit 71a64c6

Please sign in to comment.