Linter checks for extraneous dependencies

Summary: Added eslint rule "no-extraneous-imports" which disallow using modules which are not listed as dependencies in the corresponding package.json. Fixed a bunch of reported errors after the rule applied.

Reviewed By: passy

Differential Revision: D21186848

fbshipit-source-id: 0af9ac4b3fffdfd0ab7c23ae4ff12a3f5989d5e9
This commit is contained in:
Anton Nikolaev
2020-04-23 05:30:29 -07:00
committed by Facebook GitHub Bot
parent 17ccdeaf6f
commit ec07272c78
18 changed files with 278 additions and 180 deletions

View File

@@ -12,6 +12,16 @@ const fbjs = require('eslint-config-fbjs');
// enforces copyright header and @format directive to be present in every file
const pattern = /^\*\r?\n[\S\s]*Facebook[\S\s]* \* @format\r?\n/;
const builtInModules = [
'flipper',
'react',
'react-dom',
'electron',
'adbkit',
'immer',
'@emotion/styled',
];
const prettierConfig = {
// arrowParens=always is the default for Prettier 2.0, but other configs
// at Facebook appear to be leaking into this file, which is still on
@@ -35,6 +45,7 @@ module.exports = {
'prettier',
'@typescript-eslint',
'import',
'node',
],
rules: {
// disable rules from eslint-config-fbjs
@@ -61,9 +72,9 @@ module.exports = {
'header/header': [2, 'block', {pattern}],
'prettier/prettier': [2, prettierConfig],
'flowtype/object-type-delimiter': [0],
// import
'import/no-unresolved': [2, {commonjs: true, amd: true}],
'node/no-extraneous-import': [2, {allowModules: builtInModules}],
'node/no-extraneous-require': [2, {allowModules: builtInModules}],
},
settings: {
'import/resolver': {