Enable eslint import checks and fixed the reported errors (#878)
Summary: Pull Request resolved: https://github.com/facebook/flipper/pull/878 1) Enabled eslint error reporting for unresolved imports and fixed all the errors 2) Enabled eslint for typings (d.ts) and fixed all the errors Reviewed By: passy Differential Revision: D20335151 fbshipit-source-id: 7b142281a406b32df0f02a5cd0d7d05eba941acd
This commit is contained in:
committed by
Facebook GitHub Bot
parent
85c13bb1f3
commit
beb5c85e69
@@ -1,4 +1,3 @@
|
|||||||
*.d.ts
|
|
||||||
*.bundle.js
|
*.bundle.js
|
||||||
src/fb/plugins/relaydevtools/relay-devtools/*
|
src/fb/plugins/relaydevtools/relay-devtools/*
|
||||||
latest
|
latest
|
||||||
@@ -12,3 +11,4 @@ dist
|
|||||||
website/build
|
website/build
|
||||||
react-native/ReactNativeFlipperExample
|
react-native/ReactNativeFlipperExample
|
||||||
scripts/generate-changelog.js
|
scripts/generate-changelog.js
|
||||||
|
static/index.js
|
||||||
|
|||||||
@@ -25,7 +25,13 @@ module.exports = {
|
|||||||
parser: 'babel-eslint',
|
parser: 'babel-eslint',
|
||||||
root: true,
|
root: true,
|
||||||
extends: 'fbjs',
|
extends: 'fbjs',
|
||||||
plugins: [...fbjs.plugins, 'header', 'prettier', '@typescript-eslint'],
|
plugins: [
|
||||||
|
...fbjs.plugins,
|
||||||
|
'header',
|
||||||
|
'prettier',
|
||||||
|
'@typescript-eslint',
|
||||||
|
'import',
|
||||||
|
],
|
||||||
rules: {
|
rules: {
|
||||||
// disable rules from eslint-config-fbjs
|
// disable rules from eslint-config-fbjs
|
||||||
'react/react-in-jsx-scope': 0, // not needed with our metro implementation
|
'react/react-in-jsx-scope': 0, // not needed with our metro implementation
|
||||||
@@ -53,6 +59,16 @@ module.exports = {
|
|||||||
'header/header': [2, 'block', {pattern}],
|
'header/header': [2, 'block', {pattern}],
|
||||||
'prettier/prettier': [2, prettierConfig],
|
'prettier/prettier': [2, prettierConfig],
|
||||||
'flowtype/object-type-delimiter': [0],
|
'flowtype/object-type-delimiter': [0],
|
||||||
|
|
||||||
|
// import
|
||||||
|
'import/no-unresolved': [2, {commonjs: true, amd: true}],
|
||||||
|
},
|
||||||
|
settings: {
|
||||||
|
'import/resolver': {
|
||||||
|
typescript: {
|
||||||
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -122,6 +122,7 @@
|
|||||||
"electron-builder": "^22.3.2",
|
"electron-builder": "^22.3.2",
|
||||||
"eslint": "^6.7.0",
|
"eslint": "^6.7.0",
|
||||||
"eslint-config-fbjs": "^3.1.1",
|
"eslint-config-fbjs": "^3.1.1",
|
||||||
|
"eslint-import-resolver-typescript": "^2.0.0",
|
||||||
"eslint-plugin-babel": "^5.3.0",
|
"eslint-plugin-babel": "^5.3.0",
|
||||||
"eslint-plugin-flowtype": "^4.3.0",
|
"eslint-plugin-flowtype": "^4.3.0",
|
||||||
"eslint-plugin-header": "^3.0.0",
|
"eslint-plugin-header": "^3.0.0",
|
||||||
@@ -134,6 +135,8 @@
|
|||||||
"glob": "^7.1.2",
|
"glob": "^7.1.2",
|
||||||
"jest": "^25.1.0",
|
"jest": "^25.1.0",
|
||||||
"jest-fetch-mock": "^3.0.0",
|
"jest-fetch-mock": "^3.0.0",
|
||||||
|
"metro": "^0.58.0",
|
||||||
|
"metro-resolver": "^0.58.0",
|
||||||
"prettier": "^1.19.1",
|
"prettier": "^1.19.1",
|
||||||
"react-async": "^10.0.0",
|
"react-async": "^10.0.0",
|
||||||
"recursive-readdir": "^2.2.2",
|
"recursive-readdir": "^2.2.2",
|
||||||
@@ -250,7 +253,9 @@
|
|||||||
"test-electron": "jest --testPathPattern=\"electron\\.(js|tsx)$\" --testEnvironment=@jest-runner/electron/environment --runner=@jest-runner/electron --no-cache",
|
"test-electron": "jest --testPathPattern=\"electron\\.(js|tsx)$\" --testEnvironment=@jest-runner/electron/environment --runner=@jest-runner/electron --no-cache",
|
||||||
"test-with-device": "USE_ELECTRON_STUBS=1 jest --testPathPattern=\"device\\.(js|tsx)$\" --detectOpenHandles --no-cache",
|
"test-with-device": "USE_ELECTRON_STUBS=1 jest --testPathPattern=\"device\\.(js|tsx)$\" --detectOpenHandles --no-cache",
|
||||||
"tsc": "tsc --noemit",
|
"tsc": "tsc --noemit",
|
||||||
"lint": "eslint . --ext .js,.ts,.tsx && flow check && yarn tsc",
|
"eslint": "eslint . --ext .js,.ts,.tsx",
|
||||||
|
"flow": "flow check",
|
||||||
|
"lint": "yarn eslint && yarn flow && yarn tsc",
|
||||||
"everything": "yarn reset && yarn install && yarn lint && yarn test && yarn test-electron && yarn build --mac --win --linux && yarn build-headless --mac --linux && yarn start"
|
"everything": "yarn reset && yarn install && yarn lint && yarn test && yarn test-electron && yarn build --mac --win --linux && yarn build-headless --mac --linux && yarn start"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
|
|||||||
10
desktop/pkg/src/types/metro.d.ts
vendored
Normal file
10
desktop/pkg/src/types/metro.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare module 'metro';
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Metro = require('metro'); // no typings :(
|
import Metro from 'metro';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
function hash(string: string) {
|
function hash(string: string) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Metro = require('../static/node_modules/metro');
|
import Metro from 'metro';
|
||||||
import compilePlugins from '../static/compilePlugins';
|
import compilePlugins from '../static/compilePlugins';
|
||||||
import util from 'util';
|
import util from 'util';
|
||||||
import tmp from 'tmp';
|
import tmp from 'tmp';
|
||||||
@@ -16,6 +16,8 @@ import fs from 'fs-extra';
|
|||||||
import {spawn} from 'promisify-child-process';
|
import {spawn} from 'promisify-child-process';
|
||||||
import recursiveReaddir from 'recursive-readdir';
|
import recursiveReaddir from 'recursive-readdir';
|
||||||
|
|
||||||
|
const projectRoot = path.join(__dirname, '..');
|
||||||
|
|
||||||
async function mostRecentlyChanged(
|
async function mostRecentlyChanged(
|
||||||
dir: string,
|
dir: string,
|
||||||
ignores: string[],
|
ignores: string[],
|
||||||
@@ -64,12 +66,11 @@ export function compileDefaultPlugins(
|
|||||||
|
|
||||||
export function compile(buildFolder: string, entry: string) {
|
export function compile(buildFolder: string, entry: string) {
|
||||||
console.log(`⚙️ Compiling renderer bundle...`);
|
console.log(`⚙️ Compiling renderer bundle...`);
|
||||||
const projectRoots = path.join(__dirname, '..');
|
|
||||||
return Metro.runBuild(
|
return Metro.runBuild(
|
||||||
{
|
{
|
||||||
reporter: {update: () => {}},
|
reporter: {update: () => {}},
|
||||||
projectRoot: projectRoots,
|
projectRoot: projectRoot,
|
||||||
watchFolders: [projectRoots],
|
watchFolders: [projectRoot],
|
||||||
serializer: {},
|
serializer: {},
|
||||||
transformer: {
|
transformer: {
|
||||||
babelTransformerPath: path.join(
|
babelTransformerPath: path.join(
|
||||||
@@ -98,7 +99,7 @@ export function compile(buildFolder: string, entry: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function compileMain({dev}: {dev: boolean}) {
|
export async function compileMain({dev}: {dev: boolean}) {
|
||||||
const staticDir = path.resolve(__dirname, '..', 'static');
|
const staticDir = path.resolve(projectRoot, 'static');
|
||||||
const out = path.join(staticDir, 'main.bundle.js');
|
const out = path.join(staticDir, 'main.bundle.js');
|
||||||
// check if main needs to be compiled
|
// check if main needs to be compiled
|
||||||
if (await fs.pathExists(out)) {
|
if (await fs.pathExists(out)) {
|
||||||
@@ -114,7 +115,7 @@ export async function compileMain({dev}: {dev: boolean}) {
|
|||||||
const config = Object.assign({}, await Metro.loadConfig(), {
|
const config = Object.assign({}, await Metro.loadConfig(), {
|
||||||
reporter: {update: () => {}},
|
reporter: {update: () => {}},
|
||||||
projectRoot: staticDir,
|
projectRoot: staticDir,
|
||||||
watchFolders: [staticDir],
|
watchFolders: [projectRoot],
|
||||||
transformer: {
|
transformer: {
|
||||||
babelTransformerPath: path.join(
|
babelTransformerPath: path.join(
|
||||||
__dirname,
|
__dirname,
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*
|
|
||||||
* @format
|
|
||||||
*/
|
|
||||||
|
|
||||||
const generate = require('babel-generator').default;
|
|
||||||
const babylon = require('babylon');
|
|
||||||
const babel = require('babel-core');
|
|
||||||
const metro = require('metro');
|
|
||||||
|
|
||||||
exports.transform = function({
|
|
||||||
filename,
|
|
||||||
options,
|
|
||||||
src,
|
|
||||||
plugins: defaultPlugins,
|
|
||||||
}) {
|
|
||||||
const presets = [];
|
|
||||||
|
|
||||||
let ast = babylon.parse(src, {
|
|
||||||
filename,
|
|
||||||
plugins: ['jsx', 'flow', 'classProperties', 'objectRestSpread'],
|
|
||||||
sourceType: filename.includes('node_modules') ? 'script' : 'module',
|
|
||||||
});
|
|
||||||
|
|
||||||
// run babel
|
|
||||||
const plugins = [
|
|
||||||
...defaultPlugins,
|
|
||||||
require('./babel-plugins/electron-requires.js'),
|
|
||||||
require('./babel-plugins/dynamic-requires.js'),
|
|
||||||
];
|
|
||||||
if (!filename.includes('node_modules')) {
|
|
||||||
plugins.unshift(require('babel-plugin-transform-es2015-modules-commonjs'));
|
|
||||||
}
|
|
||||||
ast = babel.transformFromAst(ast, src, {
|
|
||||||
babelrc: !filename.includes('node_modules'),
|
|
||||||
code: false,
|
|
||||||
comments: false,
|
|
||||||
compact: false,
|
|
||||||
filename,
|
|
||||||
plugins,
|
|
||||||
presets,
|
|
||||||
sourceMaps: true,
|
|
||||||
}).ast;
|
|
||||||
|
|
||||||
const result = generate(
|
|
||||||
ast,
|
|
||||||
{
|
|
||||||
filename,
|
|
||||||
sourceFileName: filename,
|
|
||||||
sourceMaps: true,
|
|
||||||
},
|
|
||||||
src,
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
ast,
|
|
||||||
code: result.code,
|
|
||||||
filename,
|
|
||||||
map: result.rawMappings.map(metro.sourceMaps.compactMapping),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -20,8 +20,8 @@ import path from 'path';
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import {compileMain} from './build-utils';
|
import {compileMain} from './build-utils';
|
||||||
import Watchman from '../static/watchman';
|
import Watchman from '../static/watchman';
|
||||||
const Metro = require('../static/node_modules/metro');
|
import Metro from 'metro';
|
||||||
const MetroResolver = require('../static/node_modules/metro-resolver');
|
import MetroResolver from 'metro-resolver';
|
||||||
|
|
||||||
const ansiToHtmlConverter = new AnsiToHtmlConverter();
|
const ansiToHtmlConverter = new AnsiToHtmlConverter();
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ const exec = util.promisify(execImport);
|
|||||||
const PACKAGES = [
|
const PACKAGES = [
|
||||||
'headless-tests',
|
'headless-tests',
|
||||||
'static',
|
'static',
|
||||||
|
'doctor',
|
||||||
|
'pkg',
|
||||||
'src/plugins/*',
|
'src/plugins/*',
|
||||||
'src/fb/plugins/*',
|
'src/fb/plugins/*',
|
||||||
'src/fb/plugins/layout/*',
|
'src/fb/plugins/layout/*',
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
import {FlipperPlugin, FlipperDevicePlugin} from './plugin';
|
import {FlipperPlugin, FlipperDevicePlugin} from './plugin';
|
||||||
import BaseDevice, {OS} from './devices/BaseDevice';
|
import BaseDevice, {OS} from './devices/BaseDevice';
|
||||||
import {App} from './App.js';
|
import {App} from './App';
|
||||||
import {Logger} from './fb-interfaces/Logger';
|
import {Logger} from './fb-interfaces/Logger';
|
||||||
import {Store} from './reducers/index';
|
import {Store} from './reducers/index';
|
||||||
import {setPluginState} from './reducers/pluginStates';
|
import {setPluginState} from './reducers/pluginStates';
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
import {createTablePlugin} from '../createTablePlugin';
|
import {createTablePlugin} from '../createTablePlugin';
|
||||||
import {FlipperPlugin} from '../plugin';
|
import {FlipperPlugin} from '../plugin';
|
||||||
import {List, Map as ImmutableMap} from 'immutable';
|
import {List, Map as ImmutableMap} from 'immutable';
|
||||||
import {TableRows_immutable} from '../ui/components/table/types.js';
|
import {TableRows_immutable} from '../ui/components/table/types';
|
||||||
|
|
||||||
const PROPS = {
|
const PROPS = {
|
||||||
method: 'method',
|
method: 'method',
|
||||||
|
|||||||
@@ -107,10 +107,8 @@ test('checkGK for failing plugin', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('requirePlugin returns null for invalid requires', () => {
|
test('requirePlugin returns null for invalid requires', () => {
|
||||||
const plugin = requirePlugin(
|
const requireFn = requirePlugin([], require);
|
||||||
[],
|
const plugin = requireFn({
|
||||||
require,
|
|
||||||
)({
|
|
||||||
name: 'pluginID',
|
name: 'pluginID',
|
||||||
out: 'this/path/does not/exist',
|
out: 'this/path/does not/exist',
|
||||||
});
|
});
|
||||||
@@ -121,10 +119,8 @@ test('requirePlugin returns null for invalid requires', () => {
|
|||||||
test('requirePlugin loads plugin', () => {
|
test('requirePlugin loads plugin', () => {
|
||||||
const name = 'pluginID';
|
const name = 'pluginID';
|
||||||
const homepage = 'https://fb.workplace.com/groups/flippersupport/';
|
const homepage = 'https://fb.workplace.com/groups/flippersupport/';
|
||||||
const plugin = requirePlugin(
|
const requireFn = requirePlugin([], require);
|
||||||
[],
|
const plugin = requireFn({
|
||||||
require,
|
|
||||||
)({
|
|
||||||
name,
|
name,
|
||||||
homepage,
|
homepage,
|
||||||
out: path.join(__dirname, 'TestPlugin.js'),
|
out: path.join(__dirname, 'TestPlugin.js'),
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
GRAPHQL_IOS_GROUP,
|
GRAPHQL_IOS_GROUP,
|
||||||
LITHO_GROUP,
|
LITHO_GROUP,
|
||||||
} from '../reducers/supportForm';
|
} from '../reducers/supportForm';
|
||||||
import {Store} from '../reducers/index.js';
|
import {Store} from '../reducers/index';
|
||||||
import {Logger} from '../fb-interfaces/Logger';
|
import {Logger} from '../fb-interfaces/Logger';
|
||||||
import {parseFlipperPorts} from '../utils/environmentVariables';
|
import {parseFlipperPorts} from '../utils/environmentVariables';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import Server from '../server';
|
|||||||
|
|
||||||
import {Store} from '../reducers/index';
|
import {Store} from '../reducers/index';
|
||||||
import {Logger} from '../fb-interfaces/Logger';
|
import {Logger} from '../fb-interfaces/Logger';
|
||||||
import Client from '../Client.js';
|
import Client from '../Client';
|
||||||
import {UninitializedClient} from '../UninitializedClient';
|
import {UninitializedClient} from '../UninitializedClient';
|
||||||
|
|
||||||
export default (store: Store, logger: Logger) => {
|
export default (store: Store, logger: Logger) => {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Store} from '../reducers/index.js';
|
import {Store} from '../reducers/index';
|
||||||
import {Logger} from '../fb-interfaces/Logger';
|
import {Logger} from '../fb-interfaces/Logger';
|
||||||
|
|
||||||
export type Dispatcher = (
|
export type Dispatcher = (
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {ImageId, ImageData} from './api.js';
|
import {ImageId, ImageData} from './api';
|
||||||
|
|
||||||
export type ImagesMap = {[imageId in ImageId]: ImageData};
|
export type ImagesMap = {[imageId in ImageId]: ImageData};
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import {colors} from '../colors';
|
|||||||
import {clipboard} from 'electron';
|
import {clipboard} from 'electron';
|
||||||
import deepEqual from 'deep-equal';
|
import deepEqual from 'deep-equal';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {TooltipOptions} from '../TooltipProvider.js';
|
import {TooltipOptions} from '../TooltipProvider';
|
||||||
|
|
||||||
export {DataValueExtractor} from './DataPreview';
|
export {DataValueExtractor} from './DataPreview';
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Filter} from './types.js';
|
import {Filter} from './types';
|
||||||
import React, {PureComponent} from 'react';
|
import React, {PureComponent} from 'react';
|
||||||
import ContextMenu from '../ContextMenu';
|
import ContextMenu from '../ContextMenu';
|
||||||
import textContent from '../../../utils/textContent';
|
import textContent from '../../../utils/textContent';
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
const Metro = require('metro');
|
import Metro from 'metro';
|
||||||
import util from 'util';
|
import util from 'util';
|
||||||
import recursiveReaddir from 'recursive-readdir';
|
import recursiveReaddir from 'recursive-readdir';
|
||||||
import expandTilde from 'expand-tilde';
|
import expandTilde from 'expand-tilde';
|
||||||
|
|||||||
7
desktop/types/line-replace.d.ts
vendored
7
desktop/types/line-replace.d.ts
vendored
@@ -13,6 +13,11 @@ declare module 'line-replace' {
|
|||||||
line: number;
|
line: number;
|
||||||
text: string;
|
text: string;
|
||||||
addNewLine: boolean;
|
addNewLine: boolean;
|
||||||
callback: (args: {file: string; line: number; replacedText: string; text: string}) => void;
|
callback: (args: {
|
||||||
|
file: string;
|
||||||
|
line: number;
|
||||||
|
replacedText: string;
|
||||||
|
text: string;
|
||||||
|
}) => void;
|
||||||
}): void;
|
}): void;
|
||||||
}
|
}
|
||||||
|
|||||||
10
desktop/types/metro-resolver.d.tsx
Normal file
10
desktop/types/metro-resolver.d.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare module 'metro-resolver';
|
||||||
10
desktop/types/metro.d.ts
vendored
Normal file
10
desktop/types/metro.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare module 'metro';
|
||||||
2
desktop/types/npm-api.d.ts
vendored
2
desktop/types/npm-api.d.ts
vendored
@@ -23,7 +23,6 @@ declare module 'npm-api' {
|
|||||||
use(...args: any[]): any;
|
use(...args: any[]): any;
|
||||||
|
|
||||||
view(...args: any[]): any;
|
view(...args: any[]): any;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Repository {
|
export class Repository {
|
||||||
@@ -34,5 +33,4 @@ declare module 'npm-api' {
|
|||||||
name: string;
|
name: string;
|
||||||
version: string;
|
version: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
1143
desktop/yarn.lock
1143
desktop/yarn.lock
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user