Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

JS files not being linted after update to 0.1.0 #31

Closed
vladimir-djokic opened this issue Nov 19, 2018 · 7 comments
Closed

JS files not being linted after update to 0.1.0 #31

vladimir-djokic opened this issue Nov 19, 2018 · 7 comments

Comments

@vladimir-djokic
Copy link

After updating the typescript-tslint-plugin package from 0.0.5 to 0.1.0 and adding "jsEnable": true to my tsconfig.json, .js files are not linted anymore.

VSCode 1.29.1
TypeScript TSLint Plugin 0.1.0
typescript 3.1.6 (locally installed for the project; VSCode uses this installation instead of built-in)
typescript-tslint-plugin 0.1.0

tsconfig.json snippet:

"plugins": [{
  "name": "typescript-tslint-plugin",
  "jsEnable": true
}]
@vladimir-djokic vladimir-djokic changed the title JS files not being linted after upgrade to 0.1.0 JS files not being linted after update to 0.1.0 Nov 19, 2018
@vladimir-djokic
Copy link
Author

Do you need any more information to help you identify the issue? Still not behaving as expected with 0.1.2, yet works with 0.0.5.

@mjbvz
Copy link
Contributor

mjbvz commented Dec 13, 2018

Do you also have jsRules set in your tslint.json? I see this working as expected using the 0.1.2 plugin version

@vladimir-djokic
Copy link
Author

I do. My tsconfig.json extends tslint:all and then I switch rules on/off based on my preference. I can cleary see rules from tslint:all (and additional ones I configured) being applied when using 0.0.5, but not with 0.1.2.

Thank you for you time in tracking this. If you need any more info or you can clearly see that there is something wrong with the configuration, don't hesitate to let me know.

{
    "extends": "tslint:all",
    "rules": {
        "arrow-parens": [ true, "ban-single-arg-parens" ],
        "array-type": false,
        "ban-types": {
            "options": [
                [ "Function", "Avoid using the `Function` type. Prefer a specific function type, like `() => void`." ],
                [ "Boolean", "Avoid using the `Boolean` type. Did you mean `boolean`?" ],
                [ "Number", "Avoid using the `Number` type. Did you mean `number`?" ],
                [ "String", "Avoid using the `String` type. Did you mean `string`?" ],
                [ "Symbol", "Avoid using the `Symbol` type. Did you mean `symbol`?" ]
            ]
        },
        "comment-format": false,
        "completed-docs": [
            true,
            {
                "all": { "visibilities": [ "exported" ] }
            }
        ],
        "curly": false,
        "encoding": false,
        "file-name-casing": false,
        "linebreak-style": false,
        "match-default-export-name": false,
        "max-classes-per-file": false,
        "max-line-length": false,
        "member-ordering": [
            true,
            {
                "order": [
                    "public-constructor",
                    "protected-constructor",
                    "private-constructor",

                    "public-static-method",
                    "protected-static-method",
                    "private-static-method",
                    "public-instance-method",
                    "protected-instance-method",
                    "private-instance-method",

                    "public-static-field",
                    "protected-static-field",
                    "private-static-field",
                    "public-instance-field",
                    "protected-instance-field",
                    "private-instance-field"
                ]
            }
        ],
        "newline-before-return": false,
        "newline-per-chained-call": false,
        "no-consecutive-blank-lines": [ true, 3 ],
        "no-implicit-dependencies": [ true, "dev" ],
        "no-import-side-effect": [
            true,
            { "ignore-module": "(\\.[s]?css)$" }
        ],
        "no-magic-numbers": false,
        "no-namespace": false,
        "no-non-null-assertion": false,
        "no-null-keyword": false,
        "no-parameter-properties": false,
        "no-parameter-reassignment": false,
        "no-submodule-imports": false,
        "no-unbound-method": [ true, "ignore-static" ],
        "no-unsafe-any": false,
        "no-unused-variable": false,
        "no-use-before-declare": false,
        "no-var-keyword": true,
        "no-void-expression": [ true, "ignore-arrow-function-shorthand" ],
        "object-literal-sort-keys": false,
        "object-literal-shorthand": false,
        "one-line": [
            true,
            "check-whitespace"
        ],
        "only-arrow-functions": [ true, "allow-declarations", "allow-named-functions" ],
        "ordered-imports": false,
        "prefer-conditional-expression": false,
        "prefer-method-signature": false,
        "prefer-switch": false,
        "promise-function-async": true,
        "strict-boolean-expressions": [
            true,
            "allow-null-union",
            "allow-undefined-union",
            "allow-string",
            "allow-mix"
        ],
        "strict-type-predicates": false,
        "switch-default": false,
        "switch-final-break": [ true, "always" ],
        "trailing-comma": [
            true,
            { "esSpecCompliant": true }
        ],
        "typedef": false
    },
    "jsRules": {
        "curly": false,
        "file-name-casing": false,
        "forin": false,
        "linebreak-style": false,
        "newline-before-return": false,
        "newline-per-chained-call": false,
        "no-consecutive-blank-lines": [ true, 3 ],
        "no-implicit-dependencies": [ true, "dev" ],
        "no-magic-numbers": false,
        "no-null-keyword": false,
        "no-require-imports": false,
        "object-literal-sort-keys": false,
        "object-literal-shorthand": false,
        "one-line": [
            true,
            "check-whitespace"
        ],
        "trailing-comma": [
            true,
            { "esSpecCompliant": true }
        ]
    }
}

@mjbvz
Copy link
Contributor

mjbvz commented Dec 13, 2018

Here's what I see in a js file with the latest version of the plugin and your config:

screen shot 2018-12-12 at 6 16 05 pm

In VS Code can you please make sure the js files is include in the tsconfig.json project. Open the JS file and run the Go to project configuration command in the command palette. The js file must be part of the tsconfig.json project for the plugin to be enabled. Try setting "allowJs": true in the tsconfig if the js file is not part of the project

@vladimir-djokic
Copy link
Author

I'm using webpack so I do not have files included in tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": ".",
    "experimentalDecorators": true,
    "jsx": "react",
    "lib": [ "es2015", "dom" ],
    "module": "es2015",
    "moduleResolution": "node",
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "skipDefaultLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "target": "es5",
    "types": [ "webpack-env" ],
    "plugins": [{
      "name": "typescript-tslint-plugin",
      "jsEnable": true
    }]
  },
  "exclude": [
      "bin",
      "node_modules"
  ]
}

I cannot put "allowJs": true - that would try to override .js files with them-self. With my current config, .js files are not being linted as are on your side:

annotation 2018-12-13 145918

@mjbvz mjbvz removed the info-needed label Dec 13, 2018
@mjbvz
Copy link
Contributor

mjbvz commented Dec 13, 2018

The js files need to be part of your tsconfig for the plugin to work with them. One possible project setup for this:

  • Set allowJs: true in you base tsconfig.json
  • Create a tsconfig.build.json that extends the base tsconfig and sets allowJs: false

@mjbvz mjbvz closed this as completed Dec 13, 2018
@villelahdenvuo
Copy link

villelahdenvuo commented Apr 12, 2019

@mjbvz I'm also hitting this issue, but I have allowJs and jsEnable true. 🤔

		"tslint": "5.15.0",
		"typescript": "3.3.3333",
		"typescript-tslint-plugin": "0.3.1",
{
	"compilerOptions": {
		"allowJs": true,
		"checkJs": true,
		"noUnusedLocals": true,
		"esModuleInterop": true,
		"moduleResolution": "node",
		"experimentalDecorators": true,
		"resolveJsonModule": true,
		"target": "esnext",
		"module": "commonjs",
		"inlineSourceMap": true,
		"inlineSources": true,
		"outDir": "dist",
		"lib": [
			"dom",
			"esnext"
		],
		"plugins": [
			{
				"name": "typescript-tslint-plugin",
				"jsEnable": true,
				"suppressWhileTypeErrorsPresent": false
			}
		]
	}
}

Running tslint via the CLI does show js errors as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants