JSCS行很长,当它没有

时间:2017-11-03 13:28:08

标签: javascript jscs

我正在使用带有airbnb预设的JSCS(看着切换到eslint更难以获得我们想要的样式)。

JSCS抛出此错误

    maximumLineLength: Line must be at most 100 characters at ./src/AbstractClient.es6 :
     1 |define(['underscore',
--------^
     2 |    'backbone',
     3 |    'som/models/Model',],

第1行不超过100个字符,事实上如果我在它停止抱怨的行上添加')'(开始在其他地方开始抱怨)。

我用Google搜索,但没有找到这样的东西。目前,我已经删除了行长度检查,但想将其重新添加。

1 个答案:

答案 0 :(得分:0)

显然,数组的缩进不会从maximumLineLength

中排除

更多信息请点击此处: https://github.com/jscs-dev/node-jscs/issues/424

现在,用

包装你的代码
internal class Zipper
{
    /// <summary>
    /// is adding an item to an existing Zip Archive
    /// </summary>
    /// <param name="pathZipFile"></param>
    /// <param name="pathItem"></param>
    public static void AddItem(string pathZipFile, string pathItem)
    {
        Program.WriteLine($"Opening archive '{pathZipFile}'..");
        using (FileStream fileStream = new FileStream(pathZipFile, FileMode.Open))
        {
            using (ZipArchive archive = new ZipArchive(fileStream, ZipArchiveMode.Update))
            {
                Program.WriteLine("successfully opened");
                if (File.Exists(pathItem))
                {
                    Program.WriteLine($"{pathItem} is a file. Starting to add the file to the archive..");

                    FileInfo fileInfo = new FileInfo(pathItem);
                    archive.CreateEntryFromFile(fileInfo.FullName, fileInfo.Name);
                    Program.WriteLine($"{pathItem} successfully added.");
                }
                else if (Directory.Exists(pathItem))
                {
                    Program.WriteLine($"{pathItem} is a directory. Starting to recursively add the files..");

                    DirectoryInfo directoryInfo = new DirectoryInfo(pathItem);
                    foreach (FileInfo file in directoryInfo.AllFilesAndFolders().Where(o => o is FileInfo).Cast<FileInfo>())
                    {
                        Program.WriteLine($"Adding file '{file.FullName}'");
                        string relPath = file.FullName.Substring(directoryInfo.FullName.Length - directoryInfo.Name.Length);
                        archive.CreateEntryFromFile(file.FullName, relPath);
                    }
                }
            }
        }
    }
}

public static class FileExtensions
{
    public static IEnumerable<FileSystemInfo> AllFilesAndFolders(this DirectoryInfo dir)
    {
        foreach (var f in dir.GetFiles())
            yield return f;
        foreach (var d in dir.GetDirectories())
        {
            yield return d;
            foreach (var o in AllFilesAndFolders(d))
                yield return o;
        }
    }
}