-
-
Notifications
You must be signed in to change notification settings - Fork 635
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change adds support for eslint v9. All three example projects have been updated to use the latest eslint, and the root package's dev and peer deps have been updated. In order to make this work with both v9 and older versions, I had to update the parser options helper to adjust the config passed into the `RuleTester`.
- Loading branch information
1 parent
74d5dec
commit deac4fd
Showing
16 changed files
with
180 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import assert from 'assert'; | ||
|
||
export default assert; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import fs from 'fs/promises'; | ||
|
||
export default fs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import fs from 'fs'; | ||
|
||
export default fs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import path from 'path'; | ||
|
||
export default path; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import url from 'url'; | ||
|
||
export default url; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import util from 'util'; | ||
|
||
export default util; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,53 @@ | ||
import { version as eslintVersion } from 'eslint/package.json'; | ||
import semver from 'semver'; | ||
|
||
const usingLegacy = semver.major(eslintVersion) < 9; | ||
|
||
const defaultParserOptions = { | ||
ecmaVersion: 2018, | ||
ecmaFeatures: { | ||
experimentalObjectRestSpread: true, | ||
jsx: true, | ||
}, | ||
}; | ||
|
||
const defaultLegacyParserOptions = { | ||
...defaultParserOptions, | ||
ecmaVersion: 2018, | ||
}; | ||
|
||
const defaultLanguageOptions = { | ||
ecmaVersion: 'latest', | ||
parserOptions: { | ||
...defaultParserOptions, | ||
}, | ||
}; | ||
|
||
export default function parserOptionsMapper({ | ||
code, | ||
errors, | ||
options = [], | ||
parserOptions = {}, | ||
settings, | ||
languageOptions = {}, | ||
settings = {}, | ||
}) { | ||
return { | ||
code, | ||
errors, | ||
options, | ||
parserOptions: { | ||
...defaultParserOptions, | ||
...parserOptions, | ||
}, | ||
settings, | ||
}; | ||
return usingLegacy | ||
? { | ||
code, | ||
errors, | ||
options, | ||
parserOptions: { | ||
...defaultLegacyParserOptions, | ||
...languageOptions, | ||
}, | ||
settings, | ||
} | ||
: { | ||
code, | ||
errors, | ||
options, | ||
languageOptions: { | ||
...defaultLanguageOptions, | ||
...languageOptions, | ||
}, | ||
settings, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,88 @@ | ||
import { version as eslintVersion } from 'eslint/package.json'; | ||
import expect from 'expect'; | ||
import semver from 'semver'; | ||
import parserOptionsMapper from '../../__util__/parserOptionsMapper'; | ||
|
||
const usingLegacy = semver.major(eslintVersion) < 9; | ||
|
||
describe('parserOptionsMapper', () => { | ||
it('should return an test case object', () => { | ||
const testCase = { | ||
code: '<div />', | ||
errors: [], | ||
options: {}, | ||
}; | ||
expect(parserOptionsMapper(testCase)).toEqual({ | ||
code: '<div />', | ||
errors: [], | ||
options: {}, | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
ecmaFeatures: { | ||
experimentalObjectRestSpread: true, | ||
jsx: true, | ||
|
||
const expectedResult = usingLegacy | ||
? { | ||
code: '<div />', | ||
errors: [], | ||
options: {}, | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
ecmaFeatures: { | ||
experimentalObjectRestSpread: true, | ||
jsx: true, | ||
}, | ||
}, | ||
}, | ||
}); | ||
settings: {}, | ||
} | ||
: { | ||
code: '<div />', | ||
errors: [], | ||
options: {}, | ||
languageOptions: { | ||
ecmaVersion: 'latest', | ||
parserOptions: { | ||
ecmaFeatures: { | ||
experimentalObjectRestSpread: true, | ||
jsx: true, | ||
}, | ||
}, | ||
}, | ||
settings: {}, | ||
}; | ||
expect(parserOptionsMapper(testCase)).toEqual(expectedResult); | ||
}); | ||
it('should allow for overriding parserOptions', () => { | ||
const testCase = { | ||
code: '<div />', | ||
errors: [], | ||
options: {}, | ||
parserOptions: { | ||
languageOptions: { | ||
ecmaVersion: 5, | ||
}, | ||
}; | ||
expect(parserOptionsMapper(testCase)).toEqual({ | ||
code: '<div />', | ||
errors: [], | ||
options: {}, | ||
parserOptions: { | ||
ecmaVersion: 5, | ||
ecmaFeatures: { | ||
experimentalObjectRestSpread: true, | ||
jsx: true, | ||
|
||
const expectedResult = usingLegacy | ||
? { | ||
code: '<div />', | ||
errors: [], | ||
options: {}, | ||
parserOptions: { | ||
ecmaVersion: 5, | ||
ecmaFeatures: { | ||
experimentalObjectRestSpread: true, | ||
jsx: true, | ||
}, | ||
}, | ||
}, | ||
}); | ||
settings: {}, | ||
} | ||
: { | ||
code: '<div />', | ||
errors: [], | ||
options: {}, | ||
languageOptions: { | ||
ecmaVersion: 5, | ||
parserOptions: { | ||
ecmaFeatures: { | ||
experimentalObjectRestSpread: true, | ||
jsx: true, | ||
}, | ||
}, | ||
}, | ||
settings: {}, | ||
}; | ||
expect(parserOptionsMapper(testCase)).toEqual(expectedResult); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import 'core-js/stable/structured-clone'; |