All files / src/__test__ options.js

100% Statements 13/13
100% Branches 6/6
100% Functions 1/1
100% Lines 13/13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70      1x                                                                                       88x 88x 88x 88x 1x   88x 88x 4x         88x 88x 13x         88x    
// @flow
import { parse } from "path";
 
const Options = {
  default: {
    namespacePrefix: undefined,
    allowUnsafeMixedExports: false,
    noExportCollapse: false,
    noExportExtend: false,
    noImportInteropPrefixes: ["sap/"],
  },
  files: {
    "class-convert-never.controller": {
      neverConvertClass: true
    },
    "class-controller-w-oninit": {
      moveControllerPropsToOnInit: true
    },
    "class-controller-wo-oninit": {
      moveControllerPropsToOnInit: true
    },
    "export-options-global": {
      exportAllGlobal: true
    },
    "class-convert-controller-extend-static-assign": {
      addControllerStaticPropsToExtend: true
    },
    "class-convert-controller-extend-static-prop": {
      addControllerStaticPropsToExtend: true
    },
    "class-convert-all": {
      autoConvertAllExtendClasses: true
    },
  },
  dirs: {
    "min-wrap": {
      noWrapBeforeImport: true
    },
    "_private_": {
      noWrapBeforeImport: true,
      moveControllerPropsToOnInit: true,
      addControllerStaticPropsToExtend: true,
    }
  }
};
 
export function get(filePath: string) {
  const { name, dir: dirPath } = parse(filePath);
  const { base: dir } = parse(dirPath);
  let options = {...Options.default};
  if (filePath.includes("prefix")) {
    options.namespacePrefix = "prefix";
  }
  const fileOverrides = Options.files[name];
  if (fileOverrides) {
    options = {
      ...options,
      ...fileOverrides
    };
  }
  const dirOverride = Options.dirs[dir];
  if (dirOverride) {
    options = {
      ...options,
      ...dirOverride
    };
  }
  return options;
}