Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

tslint npm package missing './test/parse' #3072

Closed
m1chaeldg opened this issue Jul 25, 2017 · 7 comments · Fixed by #3079
Closed

tslint npm package missing './test/parse' #3072

m1chaeldg opened this issue Jul 25, 2017 · 7 comments · Fixed by #3079

Comments

@m1chaeldg
Copy link

Bug Report

  • TSLint version: 5.5.0
  • TypeScript version:
  • Running TSLint via: CLI

TypeScript code being linted

// code snippet

with tslint.json configuration:

{
  "extends": "tslint:latest",
  "rules": {
    /**
     * Security Rules. The following rules should be turned on because they find security issues
     * or are recommended in the Microsoft Secure Development Lifecycle (SDL)
     */
    "insecure-random": true,
    "no-banned-terms": true,
    "no-delete-expression": true,
    "no-disable-auto-sanitization": true,
    "no-eval": true,
    "no-function-constructor-with-string-args": true,
    "no-http-string": [true, "http://www.example.com/?.*", "http://www.examples.com/?.*"],
    "no-octal-literal": true,
    "no-reserved-keywords": true,
    "no-string-based-set-immediate": true,
    "no-string-based-set-interval": true,
    "no-string-based-set-timeout": true,
    "non-literal-require": true,
    "possible-timing-attack": true,

    /**
     * Common Bugs and Correctness. The following rules should be turned on because they find
     * common bug patterns in the code or enforce type safety.
     */
    "forin": true,
    "no-any": true,
    "no-arg": true,
    "no-bitwise": true,
    "no-conditional-assignment": true,
    "no-console": [true, "debug", "info", "log", "time", "timeEnd", "trace"],
    "no-constant-condition": true,
    "no-control-regex": true,
    "no-duplicate-case": true,
    "no-duplicate-variable": true,
    "no-empty": true,
    "no-for-in-array": false,
    "no-increment-decrement": true,
    "no-invalid-regexp": true,
    "no-invalid-this": true,
    "no-regex-spaces": true,
    "no-sparse-arrays": true,
    "no-stateless-class": true,
    "no-string-literal": true,
    "no-string-throw": true,
    "no-unnecessary-bind": true,
    "no-unnecessary-override": true,
    "no-unsafe-finally": true,
    "no-unused-expression": true,
    "no-unused-new": true,
    "no-use-before-declare": true,
    "no-with-statement": true,
    "promise-must-complete": true,
    "radix": true,
    "switch-default": true,
    "triple-equals": [true, "allow-null-check"],
    "use-isnan": true,
    "use-named-parameter": true,
    "valid-typeof": true,

    /**
     * Code Clarity. The following rules should be turned on because they make the code
     * generally more clear to the reader.
     */
    "adjacent-overload-signatures": true,
    "array-type": [true, "array"],
    "arrow-parens": false, // for simple functions the parens on arrow functions are not needed
    "callable-types": true,
    "class-name": true,
    "comment-format": [true, "check-space", "check-uppercase"],
    "export-name": false,
    "function-name": [true, {
      "method-regex": "^[a-z][\\w\\d]+$",
      "private-method-regex": "^[a-z_][\\w\\d]+$",
      "protected-method-regex": "^[a-z][\\w\\d]+$",
      "static-method-regex": "^[A-Z][\\w\\d]+$",
      "function-regex": "^[a-z][\\w\\d]+$"
    }],
    "import-name": false,
    "interface-name": [true, "never-prefix"],
    "jsdoc-format": true,
    "max-classes-per-file": [true, 3], // we generally recommend making one public class per file
    "max-file-line-count": [true, 500],
    "max-func-body-length": [true, 100, {
      "ignore-parameters-to-function-regex": "describe"
    }],
    "max-line-length": [true, 140],
    "member-access": true,
    "member-ordering": [
      true,
      {
        "order": [{
            "name": "static non-private",
            "kinds": [
              "public-static-field",
              "protected-static-field",
              "public-static-method",
              "protected-static-method"
            ]
          },
          "instance-field",
          "constructor"
        ]
      }
    ],
    "missing-jsdoc": false,
    "new-parens": true,
    "no-construct": true,
    "no-default-export": false,
    "no-empty-interfaces": true,
    "no-for-in": false,
    "no-function-expression": true,
    "no-multiline-string": true, // multiline-strings often introduce unnecessary whitespace into the string literals
    "no-null-keyword": false, // turn no-null-keyword off and use undefined to mean not initialized and null to mean without a value
    "no-parameter-properties": false,
    "no-relative-imports": false,
    "no-require-imports": true,
    "no-shadowed-variable": true,
    "no-suspicious-comment": true,
    "no-typeof-undefined": true,
    "no-unnecessary-field-initialization": true,
    "no-unnecessary-local-variable": false,
    "no-var-keyword": true,
    "no-var-requires": true,
    "no-var-self": true,
    "object-literal-sort-keys": false, // turn object-literal-sort-keys off and sort keys in a meaningful manner
    "one-variable-per-declaration": [true, "ignore-for-loop"],
    "ordered-imports": [false, "any"],
    "prefer-array-literal": true,
    "prefer-const": false,
    "prefer-for-of": true,
    "typedef": [true, "call-signature", "parameter", "property-declaration", "member-variable-declaration"],
    "underscore-consistent-invocation": true,
    "unified-signatures": true,
    "variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore"],

    /**
     * Whitespace related rules. The only recommended whitespace strategy is to pick a single format and
     * be consistent.
     */
    "align": [true, "parameters", "statements"],
    "curly": true,
    "eofline": false,
    "import-spacing": true,
    "indent": [true, "spaces"],
    "no-empty-line-after-opening-brace": false,
    "no-single-line-block-comment": true,
    "no-trailing-whitespace": true,
    "no-unnecessary-semicolons": true,
    "object-literal-key-quotes": [true, "as-needed"],
    "one-line": [true, "check-open-brace", "check-catch", "check-else", "check-whitespace"],
    "quotemark": [true, "single"],
    "semicolon": [true, "never"],
    "trailing-comma": [true, {
      "singleline": "never",
      "multiline": "always"
    }], // forcing trailing commas for multi-line
    "typedef-whitespace": [
      true,
      {
        "call-signature": "nospace",
        "index-signature": "nospace",
        "parameter": "nospace",
        "property-declaration": "nospace",
        "variable-declaration": "nospace"
      },
      {
        "call-signature": "onespace",
        "index-signature": "onespace",
        "parameter": "onespace",
        "property-declaration": "onespace",
        "variable-declaration": "onespace"
      }
    ],
    "whitespace": [true, "check-branch", "check-decl", "check-operator", "check-separator", "check-type"],

    /**
     * Controversial/Configurable rules.
     */
    "ban": false, // only enable this if you have some code pattern that you want to ban
    "import-blacklist": false, // enable and configure this as you desire
    "interface-over-type-literal": false, // there are plenty of reasons to prefer interfaces
    "no-angle-bracket-type-assertion": false, // pick either type-cast format and use it consistently
    "no-empty-interface": false, // it is currently better to use the MS version of this rule
    "no-inferred-empty-object-type": false, // if the compiler is satisfied then this is probably not an issue
    "no-internal-module": false, // only enable this if you are not using internal modules
    "no-magic-numbers": false, // by default it will find too many false positives
    "no-mergeable-namespace": false, // your project may require mergeable namespaces
    "no-namespace": false, // only enable this if you are not using modules/namespaces
    "no-reference": true, // in general you should use a module system and not /// reference imports
    "no-unexternalized-strings": false, // the VS Code team has a specific localization process that this rule enforces
    "object-literal-shorthand": false, // object-literal-shorthand offers an abbreviation not an abstraction
    "prefer-type-cast": true, // pick either type-cast format and use it consistently
    "space-before-function-paren": false // turn this on if this is really your coding standard
  },
  "rulesDirectory": [
    "node_modules/tslint-microsoft-contrib"
  ]
}

Actual behavior

running the cli below produce an error
tslint -c tslint.json -t stylish '{src,tests,scripts}/**/*.{ts,tsx}'
module.js:487
throw err;
^

Error: Cannot find module './test/parse'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object. (D:\temp\helloworld\node_modules\tslint\lib\test.js:28
:13)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)

Expected behavior

I think the './test/parse' files/modules are not publish

@ajafff
Copy link
Contributor

ajafff commented Jul 25, 2017

I can't reproduce this locally. ./test/*.js is in the published package. I verified that with v5.5.0. There must be something wrong with your installation of tslint.
Try removing node_modules and installing it again.

@m1chaeldg
Copy link
Author

Thank you for your reply. I have reinstall all packages and still encounter the same issue above. I even create a new project just to test the tslint. Btw does the OS affect on this behavior? I am using windows 10.

@aleung
Copy link
Contributor

aleung commented Jul 28, 2017

@m1chaeldg Are you using yarn? I faced the same issue when I was using yarn install. Then I tried npm install and the lib/test/ folder is their.

I can reproduce the issue in both MacOS and Linux with yarn 0.27.5.

@aleung
Copy link
Contributor

aleung commented Jul 28, 2017

It's caused by yarn clean.

Once you run yarn clean, Yarn will create a .yarnclean file.
Cleaning is then automatically done as part of yarn install (or simply yarn) and yarn add.

The default .yarnclean file includes these lines:

# test directories
__tests__
test
tests
powered-test

That's why the lib/test/ folder is missing. I don't intent to use yarn clean. But I ran it once by mistake ( I want to run yarn run clean).

A workaround is to remove test from .yarnclean or even delete everything from .yarnclean and only keep an empty file if you don't plan to use yarn clean.

@ajafff , I suggest to rename test folder to avoid this issue.

@aleung
Copy link
Contributor

aleung commented Jul 28, 2017

Just found that there were several issues in this project (#1770) and in yarn project (yarnpkg/yarn#1235, yarnpkg/yarn#1825) about tslint doesn't work.

If tslint changes the folder name, it would avoid trouble to others. I spend almost one afternoon to debug it.

@ajafff
Copy link
Contributor

ajafff commented Jul 28, 2017

I suggest to rename test folder to avoid this issue.

That would definitely fix this issue. But I don't know if we want consider renaming this folder a breaking change.

For now I'd just require ./test if the --test option is used. That fixes the issue for our regular users.

@m1chaeldg
Copy link
Author

thanks

HyphnKnight pushed a commit to HyphnKnight/tslint that referenced this issue Apr 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants