BVB Source Codes

prettier Show options.js Source code

Return Download prettier: download options.js Source code - Download prettier Source code - Type:.js
  1. "use strict";
  2.  
  3. const validate = require("jest-validate").validate;
  4. const deprecatedConfig = require("./deprecated");
  5.  
  6. const defaults = {
  7.   cursorOffset: -1,
  8.   rangeStart: 0,
  9.   rangeEnd: Infinity,
  10.   useTabs: false,
  11.   tabWidth: 2,
  12.   printWidth: 80,
  13.   singleQuote: false,
  14.   trailingComma: "none",
  15.   bracketSpacing: true,
  16.   jsxBracketSameLine: false,
  17.   parser: "babylon",
  18.   semi: true
  19. };
  20.  
  21. const exampleConfig = Object.assign({}, defaults, {
  22.   filepath: "path/to/Filename",
  23.   printWidth: 80,
  24.   originalText: "text"
  25. });
  26.  
  27. // Copy options and fill in default values.
  28. function normalize(options) {
  29.   const normalized = Object.assign({}, options || {});
  30.   const filepath = normalized.filepath;
  31.  
  32.   if (/\.(css|less|scss)$/.test(filepath)) {
  33.     normalized.parser = "postcss";
  34.   } else if (/\.(ts|tsx)$/.test(filepath)) {
  35.     normalized.parser = "typescript";
  36.   }
  37.  
  38.   if (typeof normalized.trailingComma === "boolean") {
  39.     // Support a deprecated boolean type for the trailing comma config
  40.     // for a few versions. This code can be removed later.
  41.     normalized.trailingComma = "es5";
  42.  
  43.     console.warn(
  44.       "Warning: `trailingComma` without any argument is deprecated. " +
  45.         'Specify "none", "es5", or "all".'
  46.     );
  47.   }
  48.  
  49.   validate(normalized, { exampleConfig, deprecatedConfig });
  50.  
  51.   // For backward compatibility. Deprecated in 0.0.10
  52.   if ("useFlowParser" in normalized) {
  53.     normalized.parser = normalized.useFlowParser ? "flow" : "babylon";
  54.     delete normalized.useFlowParser;
  55.   }
  56.  
  57.   Object.keys(defaults).forEach(k => {
  58.     if (normalized[k] == null) {
  59.       normalized[k] = defaults[k];
  60.     }
  61.   });
  62.  
  63.   return normalized;
  64. }
  65.  
  66. module.exports = { normalize };
  67.  
downloadoptions.js Source code - Download prettier Source code
Related Source Codes/Software:
storybook - 2017-06-07
ionicons - The premium icon font for Ionic ... 2017-06-07
AsyncDisplayKit - Smooth asynchronous user interfaces for iOS apps. ... 2017-06-07
lottie-android - Render After Effects animations natively on Androi... 2017-06-07
parse-server - Parse-compatible API server module for Node/Expres... 2017-06-07
inferno - An extremely fast, React-like JavaScript library f... 2017-06-08
guetzli - Perceptual JPEG encoder 2017-06-08
cs-video-courses - List of Computer Science courses with video lectur... 2017-06-08
interviews - Everything you need to know to get the job. 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top