-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RN: Move
no-haste-imports
ESLint Rule into Repository
Summary: Moves the `no-haste-imports` ESLint rule into the React Native repository because it was only intended to be used for internal development of React Native. This will change `react-native/eslint-plugin` to no longer provide the `no-haste-imports` rule. Changelog: [General][Removed] - `react-native/eslint-plugin` no longer provides the `no-haste-imports` rule. Reviewed By: lunaleaps Differential Revision: D39858883 fbshipit-source-id: b8d91ce5996b615341cf60c6f839afac1e26dac9
- Loading branch information
1 parent
49b14cc
commit 1ec69b1
Showing
5 changed files
with
137 additions
and
35 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
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,99 @@ | ||
/** | ||
* 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. | ||
* | ||
* @format | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const rule = require('../no-haste-imports.js'); | ||
const {RuleTester} = require('eslint'); | ||
|
||
const ruleTester = new RuleTester({ | ||
parser: require.resolve('hermes-eslint'), | ||
parserOptions: { | ||
ecmaVersion: 6, | ||
sourceType: 'module', | ||
}, | ||
}); | ||
|
||
ruleTester.run('require(...)', rule, { | ||
valid: [ | ||
{ | ||
code: `const X = require('x');`, | ||
}, | ||
{ | ||
code: `const X = require('./X');`, | ||
}, | ||
{ | ||
code: `const Y = require('X/Y');`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `const X = require('X');`, | ||
errors: [{messageId: 'hasteImport', data: {importPath: 'X'}}], | ||
output: null, // Expect no autofix to be suggested. | ||
}, | ||
{ | ||
code: `const useX = require('useX');`, | ||
errors: [{messageId: 'hasteImport', data: {importPath: 'useX'}}], | ||
output: null, // Expect no autofix to be suggested. | ||
}, | ||
], | ||
}); | ||
|
||
ruleTester.run('import(...)', rule, { | ||
valid: [ | ||
{ | ||
code: `import('x');`, | ||
}, | ||
{ | ||
code: `import('./X');`, | ||
}, | ||
{ | ||
code: `import('X/Y');`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import('X');`, | ||
errors: [{messageId: 'hasteImport', data: {importPath: 'X'}}], | ||
output: null, // Expect no autofix to be suggested. | ||
}, | ||
{ | ||
code: `import('useX');`, | ||
errors: [{messageId: 'hasteImport', data: {importPath: 'useX'}}], | ||
output: null, // Expect no autofix to be suggested. | ||
}, | ||
], | ||
}); | ||
|
||
ruleTester.run("import ... from '...'", rule, { | ||
valid: [ | ||
{ | ||
code: `import X from 'x';`, | ||
}, | ||
{ | ||
code: `import X from './X';`, | ||
}, | ||
{ | ||
code: `import Y from 'X/Y';`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import X from 'X';`, | ||
errors: [{messageId: 'hasteImport', data: {importPath: 'X'}}], | ||
output: null, // Expect no autofix to be suggested. | ||
}, | ||
{ | ||
code: `import useX from 'useX';`, | ||
errors: [{messageId: 'hasteImport', data: {importPath: 'useX'}}], | ||
output: null, // Expect no autofix to be suggested. | ||
}, | ||
], | ||
}); |
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