Skip to content

Commit

Permalink
refactor(ordered imports): require ordered imports (#1843)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartosz Leoniak authored and simondel committed Nov 13, 2019
1 parent 4f81550 commit e896c18
Show file tree
Hide file tree
Showing 353 changed files with 708 additions and 184 deletions.
5 changes: 3 additions & 2 deletions .eslintrc.js
@@ -1,4 +1,3 @@

module.exports = {
env: {
node: true
Expand All @@ -9,8 +8,10 @@ module.exports = {
},
parser: '@typescript-eslint/parser',
extends: ['prettier', 'eslint:recommended'],
plugins: ['@typescript-eslint', 'prettier'],
plugins: ['@typescript-eslint', 'prettier', 'import'],
rules: {
'import/newline-after-import': 1,
'import/order': ["error", {"newlines-between": "always"}],
'prettier/prettier': ['error'],
'sort-imports': 'off', // No auto-fix!
'no-case-declarations': 'off',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -25,7 +25,7 @@
"eslint": "~6.6.0",
"eslint-config-prettier": "~6.5.0",
"eslint-plugin-import": "~2.18.2",
"eslint-plugin-prettier": "~3.1.0",
"eslint-plugin-prettier": "~3.1.1",
"execa": "^3.2.0",
"glob": "^7.1.1",
"if-node-version": "^1.1.1",
Expand Down
1 change: 1 addition & 0 deletions packages/api/report.ts
@@ -1,4 +1,5 @@
import * as mutationTestReportSchema from 'mutation-testing-report-schema/dist/src/api';

export { default as Reporter } from './src/report/Reporter';
export { default as MutantResult } from './src/report/MutantResult';
export { default as MutantStatus } from './src/report/MutantStatus';
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/mutant/Mutator.ts
@@ -1,4 +1,5 @@
import { File } from '../../core';

import Mutant from './Mutant';

export default interface Mutator {
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/plugin/Contexts.ts
@@ -1,5 +1,6 @@
import { MutatorDescriptor, StrykerOptions } from '../../core';
import { Logger, LoggerFactoryMethod } from '../../logging';

import { PluginKind } from './PluginKind';
import { PluginResolver } from './Plugins';
import { commonTokens } from './tokens';
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/plugin/Plugins.ts
@@ -1,10 +1,12 @@
import { InjectableClass, InjectableFunction, InjectionToken } from 'typed-inject';

import { ConfigEditor } from '../../config';
import { Mutator } from '../../mutant';
import { Reporter } from '../../report';
import { TestFramework } from '../../test_framework';
import { TestRunner } from '../../test_runner';
import { Transpiler } from '../../transpile';

import { PluginContexts } from './Contexts';
import { PluginKind } from './PluginKind';

Expand Down
1 change: 1 addition & 0 deletions packages/api/src/report/MutantResult.ts
@@ -1,4 +1,5 @@
import { Location, Range } from '../../core';

import MutantStatus from './MutantStatus';

interface MutantResult {
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/report/Reporter.ts
@@ -1,4 +1,5 @@
import { MutationTestResult } from 'mutation-testing-report-schema';

import MatchedMutant from './MatchedMutant';
import MutantResult from './MutantResult';
import ScoreResult from './ScoreResult';
Expand Down
@@ -1,7 +1,8 @@
import { expect } from 'chai';
import { exec } from 'child_process';
import * as path from 'path';

import { expect } from 'chai';

describe('we have a module using stryker', () => {
const modulePath = path.resolve(__dirname, '../../../testResources/module');

Expand Down
1 change: 1 addition & 0 deletions packages/api/test/unit/config/Config.spec.ts
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import * as minimatch from 'minimatch';

import { Config } from '../../../config';

describe('Config', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/api/test/unit/core/File.spec.ts
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { deserialize, serialize } from 'surrial';

import { File } from '../../../core';

describe('File', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/api/test/unit/core/LogLevel.spec.ts
@@ -1,4 +1,5 @@
import { expect } from 'chai';

import LogLevel from '../../../src/core/LogLevel';

describe('LogLevel', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/api/test/unit/plugin/tokens.spec.ts
@@ -1,4 +1,5 @@
import { expect } from 'chai';

import { commonTokens, tokens } from '../../../plugin';

describe('tokens', () => {
Expand Down
6 changes: 4 additions & 2 deletions packages/babel-transpiler/src/BabelConfigReader.ts
@@ -1,8 +1,10 @@
import * as fs from 'fs';
import * as path from 'path';

import { StrykerOptions } from '@stryker-mutator/api/core';
import { Logger } from '@stryker-mutator/api/logging';
import { commonTokens, tokens } from '@stryker-mutator/api/plugin';
import * as fs from 'fs';
import * as path from 'path';

import * as babel from './helpers/babelWrapper';

export interface StrykerBabelConfig {
Expand Down
4 changes: 3 additions & 1 deletion packages/babel-transpiler/src/BabelTranspiler.ts
@@ -1,8 +1,10 @@
import * as path from 'path';

import { File, StrykerOptions } from '@stryker-mutator/api/core';
import { commonTokens, Injector, tokens, TranspilerPluginContext } from '@stryker-mutator/api/plugin';
import { Transpiler } from '@stryker-mutator/api/transpile';
import { StrykerError } from '@stryker-mutator/util';
import * as path from 'path';

import { BabelConfigReader, StrykerBabelConfig } from './BabelConfigReader';
import * as babel from './helpers/babelWrapper';
import { toJSFileName } from './helpers/helpers';
Expand Down
1 change: 1 addition & 0 deletions packages/babel-transpiler/src/index.ts
@@ -1,4 +1,5 @@
import { declareFactoryPlugin, PluginKind } from '@stryker-mutator/api/plugin';

import { babelTranspilerFactory } from './BabelTranspiler';

export const strykerPlugins = [declareFactoryPlugin(PluginKind.Transpiler, 'babel', babelTranspilerFactory)];
5 changes: 3 additions & 2 deletions packages/babel-transpiler/test/helpers/projectLoader.ts
@@ -1,8 +1,9 @@
import { File } from '@stryker-mutator/api/core';
import * as fs from 'fs';
import * as glob from 'glob';
import * as path from 'path';

import { File } from '@stryker-mutator/api/core';
import * as glob from 'glob';

const CARRIAGE_RETURN = '\r'.charCodeAt(0);

function readFile(fileName: string) {
Expand Down
@@ -1,9 +1,11 @@
import * as path from 'path';

import { ConfigAPI } from '@babel/core';
import { File } from '@stryker-mutator/api/core';
import { commonTokens } from '@stryker-mutator/api/plugin';
import { testInjector } from '@stryker-mutator/test-helpers';
import { expect } from 'chai';
import * as path from 'path';

import { CONFIG_KEY, StrykerBabelConfig } from '../../src/BabelConfigReader';
import { BabelTranspiler, babelTranspilerFactory } from '../../src/BabelTranspiler';
import { ProjectLoader } from '../helpers/projectLoader';
Expand Down
6 changes: 4 additions & 2 deletions packages/babel-transpiler/test/unit/BabelConfigReader.spec.ts
@@ -1,8 +1,10 @@
import { factory, testInjector } from '@stryker-mutator/test-helpers';
import { expect } from 'chai';
import * as fs from 'fs';
import * as path from 'path';

import { factory, testInjector } from '@stryker-mutator/test-helpers';
import { expect } from 'chai';
import * as sinon from 'sinon';

import { BabelConfigReader, StrykerBabelConfig } from '../../src/BabelConfigReader';

describe(BabelConfigReader.name, () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/babel-transpiler/test/unit/BabelTranspiler.spec.ts
@@ -1,9 +1,11 @@
import * as path from 'path';

import { File, StrykerOptions } from '@stryker-mutator/api/core';
import { commonTokens } from '@stryker-mutator/api/plugin';
import { factory, testInjector } from '@stryker-mutator/test-helpers';
import { expect } from 'chai';
import * as path from 'path';
import * as sinon from 'sinon';

import { BabelConfigReader, StrykerBabelConfig } from '../../src/BabelConfigReader';
import { BabelTranspiler } from '../../src/BabelTranspiler';
import * as babel from '../../src/helpers/babelWrapper';
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/Sandbox.ts
@@ -1,3 +1,5 @@
import * as path from 'path';

import { StrykerOptions } from '@stryker-mutator/api/core';
import { File } from '@stryker-mutator/api/core';
import { MutantResult, MutantStatus } from '@stryker-mutator/api/report';
Expand All @@ -6,7 +8,7 @@ import { RunResult, RunStatus, TestRunner, TestStatus } from '@stryker-mutator/a
import { normalizeWhitespaces } from '@stryker-mutator/util';
import { getLogger } from 'log4js';
import * as mkdirp from 'mkdirp';
import * as path from 'path';

import LoggingClientContext from './logging/LoggingClientContext';
import ResilientTestRunnerFactory from './test-runner/ResilientTestRunnerFactory';
import TestableMutant, { TestSelectionResult } from './TestableMutant';
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/SandboxPool.ts
@@ -1,12 +1,14 @@
import * as os from 'os';

import { File, StrykerOptions } from '@stryker-mutator/api/core';
import { Logger } from '@stryker-mutator/api/logging';
import { commonTokens, tokens } from '@stryker-mutator/api/plugin';
import { MutantResult } from '@stryker-mutator/api/report';
import { TestFramework } from '@stryker-mutator/api/test_framework';
import * as os from 'os';
import { Observable, range, Subject } from 'rxjs';
import { filter, flatMap, map, merge, tap, zip } from 'rxjs/operators';
import { Disposable } from 'typed-inject';

import { coreTokens } from './di';
import LoggingClientContext from './logging/LoggingClientContext';
import { InitialTestRunResult } from './process/InitialTestExecutor';
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/ScoreResultCalculator.ts
@@ -1,10 +1,13 @@
import * as path from 'path';

import { MutationScoreThresholds } from '@stryker-mutator/api/core';
import { Logger } from '@stryker-mutator/api/logging';
import { commonTokens, tokens } from '@stryker-mutator/api/plugin';
import { MutantResult, MutantStatus, ScoreResult } from '@stryker-mutator/api/report';

import flatMap = require('lodash.flatmap');
import groupBy = require('lodash.groupby');
import * as path from 'path';

import { freezeRecursively, setExitCode } from './utils/objectUtils';

const defaultScoreIfNoValidMutants = 100;
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/Stryker.ts
Expand Up @@ -3,6 +3,7 @@ import { Logger } from '@stryker-mutator/api/logging';
import { commonTokens, PluginKind } from '@stryker-mutator/api/plugin';
import { MutantResult } from '@stryker-mutator/api/report';
import { Injector } from 'typed-inject';

import { buildMainInjector, coreTokens, MainContext, PluginCreator } from './di';
import InputFileCollection from './input/InputFileCollection';
import InputFileResolver from './input/InputFileResolver';
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/StrykerCli.ts
@@ -1,5 +1,6 @@
import * as program from 'commander';
import { getLogger } from 'log4js';

import { CONFIG_SYNTAX_HELP } from './config/ConfigReader';
import { initializerFactory } from './initializer';
import LogConfigurator from './logging/LogConfigurator';
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/TestFrameworkOrchestrator.ts
Expand Up @@ -2,6 +2,7 @@ import { StrykerOptions } from '@stryker-mutator/api/core';
import { Logger } from '@stryker-mutator/api/logging';
import { commonTokens, PluginKind, tokens } from '@stryker-mutator/api/plugin';
import { TestFramework } from '@stryker-mutator/api/test_framework';

import { coreTokens } from './di';
import { PluginCreator } from './di/PluginCreator';

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/TestableMutant.ts
Expand Up @@ -3,6 +3,7 @@ import { Mutant } from '@stryker-mutator/api/mutant';
import { MutantResult, MutantStatus } from '@stryker-mutator/api/report';
import { TestSelection } from '@stryker-mutator/api/test_framework';
import { RunResult, TestResult } from '@stryker-mutator/api/test_runner';

import SourceFile, { isLineBreak } from './SourceFile';
import { freezeRecursively } from './utils/objectUtils';

Expand Down
7 changes: 5 additions & 2 deletions packages/core/src/child-proxy/ChildProcessProxy.ts
@@ -1,14 +1,17 @@
import { ChildProcess, fork } from 'child_process';
import * as os from 'os';

import { File, StrykerOptions } from '@stryker-mutator/api/core';
import { OptionsContext } from '@stryker-mutator/api/plugin';
import { isErrnoException } from '@stryker-mutator/util';
import { ChildProcess, fork } from 'child_process';
import { getLogger } from 'log4js';
import * as os from 'os';
import { Disposable, InjectableClass, InjectionToken } from 'typed-inject';

import LoggingClientContext from '../logging/LoggingClientContext';
import { deserialize, kill, padLeft, serialize } from '../utils/objectUtils';
import StringBuilder from '../utils/StringBuilder';
import { ExpirableTask, Task } from '../utils/Task';

import ChildProcessCrashedError from './ChildProcessCrashedError';
import { autoStart, ParentMessage, ParentMessageKind, WorkerMessage, WorkerMessageKind } from './messageProtocol';
import OutOfMemoryError from './OutOfMemoryError';
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/child-proxy/ChildProcessProxyWorker.ts
@@ -1,11 +1,14 @@
import * as path from 'path';

import { Config } from '@stryker-mutator/api/config';
import { File } from '@stryker-mutator/api/core';
import { errorToString } from '@stryker-mutator/util';
import { getLogger, Logger } from 'log4js';
import * as path from 'path';

import { buildChildProcessInjector } from '../di';
import LogConfigurator from '../logging/LogConfigurator';
import { deserialize, serialize } from '../utils/objectUtils';

import { autoStart, CallMessage, ParentMessage, ParentMessageKind, WorkerMessage, WorkerMessageKind } from './messageProtocol';

export default class ChildProcessProxyWorker {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/child-proxy/messageProtocol.ts
@@ -1,4 +1,5 @@
import { StrykerOptions } from '@stryker-mutator/api/core';

import LoggingClientContext from '../logging/LoggingClientContext';

export enum WorkerMessageKind {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/config/ConfigEditorApplier.ts
@@ -1,6 +1,7 @@
import { Config, ConfigEditor } from '@stryker-mutator/api/config';
import { commonTokens, PluginKind, PluginResolver } from '@stryker-mutator/api/plugin';
import { tokens } from 'typed-inject';

import { coreTokens } from '../di';
import { PluginCreator } from '../di/PluginCreator';

Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/config/ConfigReader.ts
@@ -1,10 +1,12 @@
import * as fs from 'fs';
import * as path from 'path';

import { Config } from '@stryker-mutator/api/config';
import { StrykerOptions } from '@stryker-mutator/api/core';
import { Logger } from '@stryker-mutator/api/logging';
import { commonTokens, tokens } from '@stryker-mutator/api/plugin';
import { StrykerError } from '@stryker-mutator/util';
import fs = require('fs');
import * as path from 'path';

import { coreTokens } from '../di';

export const CONFIG_SYNTAX_HELP = ' module.exports = function(config) {\n' + ' config.set({\n' + ' // your config\n' + ' });\n' + ' };';
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/config/ConfigValidator.ts
Expand Up @@ -4,6 +4,7 @@ import { Logger } from '@stryker-mutator/api/logging';
import { commonTokens, tokens } from '@stryker-mutator/api/plugin';
import { TestFramework } from '@stryker-mutator/api/test_framework';
import { StrykerError } from '@stryker-mutator/util';

import { coreTokens } from '../di';

export default class ConfigValidator {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/config/readConfig.ts
@@ -1,5 +1,7 @@
import { tokens } from '@stryker-mutator/api/plugin';

import { coreTokens } from '../di';

import ConfigReader from './ConfigReader';

export function readConfig(configReader: ConfigReader) {
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/di/PluginLoader.ts
@@ -1,9 +1,12 @@
import * as path from 'path';

import { Logger } from '@stryker-mutator/api/logging';
import { commonTokens, Plugin, PluginKind, PluginResolver, Plugins } from '@stryker-mutator/api/plugin';
import { fsAsPromised } from '@stryker-mutator/util';
import * as path from 'path';
import { tokens } from 'typed-inject';

import { importModule } from '../utils/fileUtils';

import * as coreTokens from './coreTokens';

const IGNORED_PACKAGES = ['core', 'api', 'util'];
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/di/buildChildProcessInjector.ts
Expand Up @@ -2,9 +2,11 @@ import { StrykerOptions } from '@stryker-mutator/api/core';
import { commonTokens, Injector, OptionsContext, Scope, tokens } from '@stryker-mutator/api/plugin';
import { getLogger } from 'log4js';
import { rootInjector } from 'typed-inject';
import { coreTokens } from '.';

import { loggerFactory, mutatorDescriptorFactory, pluginResolverFactory } from './factoryMethods';

import { coreTokens } from '.';

export function buildChildProcessInjector(options: StrykerOptions): Injector<OptionsContext> {
return rootInjector
.provideValue(commonTokens.options, options)
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/di/buildMainInjector.ts
Expand Up @@ -5,14 +5,17 @@ import { Reporter } from '@stryker-mutator/api/report';
import { TestFramework } from '@stryker-mutator/api/test_framework';
import { getLogger } from 'log4js';
import { rootInjector } from 'typed-inject';
import { coreTokens, PluginCreator } from '.';

import { ConfigEditorApplier, readConfig } from '../config';
import ConfigReader from '../config/ConfigReader';
import BroadcastReporter from '../reporters/BroadcastReporter';
import { TemporaryDirectory } from '../utils/TemporaryDirectory';
import Timer from '../utils/Timer';

import { loggerFactory, mutatorDescriptorFactory, optionsFactory, pluginResolverFactory, testFrameworkFactory } from './factoryMethods';

import { coreTokens, PluginCreator } from '.';

export interface MainContext extends OptionsContext {
[coreTokens.reporter]: Required<Reporter>;
[coreTokens.testFramework]: TestFramework | null;
Expand Down

0 comments on commit e896c18

Please sign in to comment.