forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RN: Fix
sort-imports
Lint Configuration (facebook#47104)
Summary: Pull Request resolved: facebook#47104 In facebook#46082, the lint configuration for `lint/sort-imports` was accidentally removed. This has happened on more than one occasion in the past. In order to prevent this from happening again in the future, I'm also adding a Jest integration test to verify that this lint rule is enabled in the `eslintrc.js` configuration. Changelog: [Internal] Reviewed By: robhogan Differential Revision: D64547410 fbshipit-source-id: ec4f14aff140691b644189dfa3116a3d39285f80
- Loading branch information
1 parent
14bbb87
commit 892ce1b
Showing
2 changed files
with
44 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict-local | ||
* @format | ||
*/ | ||
|
||
// $FlowFixMe[untyped-import] - Flow lib is not configured. | ||
import {ESLint} from 'eslint'; | ||
import path from 'path'; | ||
|
||
const REPO_DIR = path.resolve(__dirname, '..', '..', '..'); | ||
|
||
describe('react-native/.eslintrc.js', () => { | ||
describe('lint/sort-imports', () => { | ||
const testDirectories = [ | ||
'.', | ||
'packages/react-native', | ||
'packages/react-native/Libraries', | ||
'packages/virtualized-lists', | ||
'tools', | ||
]; | ||
const testFilenames = ['file.js', 'file.js.flow', 'file.jsx']; | ||
|
||
const testPaths = testDirectories.flatMap(testDirectory => | ||
testFilenames.map(testFilename => path.join(testDirectory, testFilename)), | ||
); | ||
|
||
it.each(testPaths)('checks `%s`', async testPath => { | ||
const eslint = new ESLint({cwd: REPO_DIR}); | ||
const config = await eslint.calculateConfigForFile(testPath); | ||
expect(config).toHaveProperty( | ||
'rules', | ||
expect.objectContaining({ | ||
'lint/sort-imports': expect.arrayContaining([1]), | ||
}), | ||
); | ||
}); | ||
}); | ||
}); |