editorconfig javascript example

Solutions on MaxInterview for editorconfig javascript example by the best coders in the world

showing results for - "editorconfig javascript example"
Colin
18 Aug 2018
1function set_file_editorconfig_opts(file, config) {
2  try {
3    var eConfigs = editorconfig.parseSync(file);
4    if (eConfigs.indent_style === "tab") {
5      config.indent_with_tabs = true;
6    } else if (eConfigs.indent_style === "space") {
7      config.indent_with_tabs = false;
8    if (eConfigs.indent_size) {
9      config.indent_size = eConfigs.indent_size;
10    if (eConfigs.max_line_length) {
11      if (eConfigs.max_line_length === "off") {
12        config.wrap_line_length = 0;
13      } else {
14        config.wrap_line_length = parseInt(eConfigs.max_line_length, 10);
15    if (eConfigs.insert_final_newline === true) {
16      config.end_with_newline = true;
17    } else if (eConfigs.insert_final_newline === false) {
18      config.end_with_newline = false;
19    if (eConfigs.end_of_line) {
20      if (eConfigs.end_of_line === 'cr') {
21        config.eol = '\r';
22      } else if (eConfigs.end_of_line === 'lf') {
23        config.eol = '\n';
24      } else if (eConfigs.end_of_line === 'crlf') {
25        config.eol = '\r\n';
26