ESLint linting my Typescript files correctly
I have .js files ( src/client/...) and .ts files ( src/server/.. )
I installed the following packages :
package.json
"eslint": "^5.11.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-typescript": "^1.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-typescript": "^0.14.0",
....
"typescript": "^3.0.3",
"typescript-eslint-parser": "^21.0.2",
And I defined the following aslant config in package.json
"eslintConfig": {
"extends": ["airbnb-base", "eslint:recommended", "typescript"],
"env": { "es6": true, "browser": true },
"parserOptions": { "parser": "typescript-eslint-parser" },
"plugins": ["typescript"],
"rules": {
"no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }],
"no-var": ["off"],
"one-var": ["off"],
"prefer-destructuring": ["error", { "object": false, "array": false } ],
"no-underscore-dangle": ["error", { "allow": ["__blogPostData"] }]
}
}
Then I set the lint script :
"lint": "eslint src --fix",
It's listing correctly all my .js files , but I don't see any warnings/errors in my .ts files ( I doubt they are all well written...)
Am I wrong or missing anything in my eslint setup for typescript ?
node.js typescript eslint
add a comment |
I have .js files ( src/client/...) and .ts files ( src/server/.. )
I installed the following packages :
package.json
"eslint": "^5.11.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-typescript": "^1.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-typescript": "^0.14.0",
....
"typescript": "^3.0.3",
"typescript-eslint-parser": "^21.0.2",
And I defined the following aslant config in package.json
"eslintConfig": {
"extends": ["airbnb-base", "eslint:recommended", "typescript"],
"env": { "es6": true, "browser": true },
"parserOptions": { "parser": "typescript-eslint-parser" },
"plugins": ["typescript"],
"rules": {
"no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }],
"no-var": ["off"],
"one-var": ["off"],
"prefer-destructuring": ["error", { "object": false, "array": false } ],
"no-underscore-dangle": ["error", { "allow": ["__blogPostData"] }]
}
}
Then I set the lint script :
"lint": "eslint src --fix",
It's listing correctly all my .js files , but I don't see any warnings/errors in my .ts files ( I doubt they are all well written...)
Am I wrong or missing anything in my eslint setup for typescript ?
node.js typescript eslint
add a comment |
I have .js files ( src/client/...) and .ts files ( src/server/.. )
I installed the following packages :
package.json
"eslint": "^5.11.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-typescript": "^1.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-typescript": "^0.14.0",
....
"typescript": "^3.0.3",
"typescript-eslint-parser": "^21.0.2",
And I defined the following aslant config in package.json
"eslintConfig": {
"extends": ["airbnb-base", "eslint:recommended", "typescript"],
"env": { "es6": true, "browser": true },
"parserOptions": { "parser": "typescript-eslint-parser" },
"plugins": ["typescript"],
"rules": {
"no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }],
"no-var": ["off"],
"one-var": ["off"],
"prefer-destructuring": ["error", { "object": false, "array": false } ],
"no-underscore-dangle": ["error", { "allow": ["__blogPostData"] }]
}
}
Then I set the lint script :
"lint": "eslint src --fix",
It's listing correctly all my .js files , but I don't see any warnings/errors in my .ts files ( I doubt they are all well written...)
Am I wrong or missing anything in my eslint setup for typescript ?
node.js typescript eslint
I have .js files ( src/client/...) and .ts files ( src/server/.. )
I installed the following packages :
package.json
"eslint": "^5.11.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-typescript": "^1.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-typescript": "^0.14.0",
....
"typescript": "^3.0.3",
"typescript-eslint-parser": "^21.0.2",
And I defined the following aslant config in package.json
"eslintConfig": {
"extends": ["airbnb-base", "eslint:recommended", "typescript"],
"env": { "es6": true, "browser": true },
"parserOptions": { "parser": "typescript-eslint-parser" },
"plugins": ["typescript"],
"rules": {
"no-unused-vars": ["error", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }],
"no-var": ["off"],
"one-var": ["off"],
"prefer-destructuring": ["error", { "object": false, "array": false } ],
"no-underscore-dangle": ["error", { "allow": ["__blogPostData"] }]
}
}
Then I set the lint script :
"lint": "eslint src --fix",
It's listing correctly all my .js files , but I don't see any warnings/errors in my .ts files ( I doubt they are all well written...)
Am I wrong or missing anything in my eslint setup for typescript ?
node.js typescript eslint
node.js typescript eslint
edited Jan 1 at 10:48
CertainPerformance
88.1k154775
88.1k154775
asked Jan 1 at 10:47
user762579
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You should use tslint for TypeScript, not eslint:
npm i tslint --save
after that, create a tslint.json in your project root (or pick one from the web with the rules you like). Just a link I found on Google: ts lint setup
thanks a lot @Bronco... going to set it up ... I'll also write 2 scripts : lint-client ( eslint .js client files and lint-server ( ts lint .ts node server files )
– user762579
Jan 1 at 13:21
Solved .. it runs OK
– user762579
Jan 1 at 17:49
Please provide a rationale if your answer to "How do I use technology A?" is "Use technology B instead". However, one shouldn't use tslint because Microsoft has deprecated it in favor of eslint - github.com/Microsoft/TypeScript/issues/… (granted, this development occurred 6 days after the answer was posted)
– Spain Train
4 hours ago
add a comment |
parser
is a root-level config item, not a field of parserOptions
:
"eslintConfig": {
"parser": "typescript-eslint-parser"
"parserOptions": { ...options },
"plugins": ["typescript"]
}
Also, the parser and plugin you are using are deprecated. The newer/maintained projects are both available at https://github.com/typescript-eslint/typescript-eslint. (Config is the same, just with updated names). Here is an nice step-by-step walk-through on how to set this up - https://dev.to/robertcoopercode/using-eslint-and-prettier-in-a-typescript-project-53jb
Note that rather than defining your eslint config in package.json
, you could instead use a separate.eslintrc.{js,yaml}
. One in the root directory would setup your standard rules for JavaScript and another one in ./src/server
could setup the TypeScript parser & plugin only for the relevant directory (but still pick up all your standard root rules).
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53994834%2feslint-linting-my-typescript-files-correctly%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should use tslint for TypeScript, not eslint:
npm i tslint --save
after that, create a tslint.json in your project root (or pick one from the web with the rules you like). Just a link I found on Google: ts lint setup
thanks a lot @Bronco... going to set it up ... I'll also write 2 scripts : lint-client ( eslint .js client files and lint-server ( ts lint .ts node server files )
– user762579
Jan 1 at 13:21
Solved .. it runs OK
– user762579
Jan 1 at 17:49
Please provide a rationale if your answer to "How do I use technology A?" is "Use technology B instead". However, one shouldn't use tslint because Microsoft has deprecated it in favor of eslint - github.com/Microsoft/TypeScript/issues/… (granted, this development occurred 6 days after the answer was posted)
– Spain Train
4 hours ago
add a comment |
You should use tslint for TypeScript, not eslint:
npm i tslint --save
after that, create a tslint.json in your project root (or pick one from the web with the rules you like). Just a link I found on Google: ts lint setup
thanks a lot @Bronco... going to set it up ... I'll also write 2 scripts : lint-client ( eslint .js client files and lint-server ( ts lint .ts node server files )
– user762579
Jan 1 at 13:21
Solved .. it runs OK
– user762579
Jan 1 at 17:49
Please provide a rationale if your answer to "How do I use technology A?" is "Use technology B instead". However, one shouldn't use tslint because Microsoft has deprecated it in favor of eslint - github.com/Microsoft/TypeScript/issues/… (granted, this development occurred 6 days after the answer was posted)
– Spain Train
4 hours ago
add a comment |
You should use tslint for TypeScript, not eslint:
npm i tslint --save
after that, create a tslint.json in your project root (or pick one from the web with the rules you like). Just a link I found on Google: ts lint setup
You should use tslint for TypeScript, not eslint:
npm i tslint --save
after that, create a tslint.json in your project root (or pick one from the web with the rules you like). Just a link I found on Google: ts lint setup
answered Jan 1 at 13:14
Bronco OostermeyerBronco Oostermeyer
9117
9117
thanks a lot @Bronco... going to set it up ... I'll also write 2 scripts : lint-client ( eslint .js client files and lint-server ( ts lint .ts node server files )
– user762579
Jan 1 at 13:21
Solved .. it runs OK
– user762579
Jan 1 at 17:49
Please provide a rationale if your answer to "How do I use technology A?" is "Use technology B instead". However, one shouldn't use tslint because Microsoft has deprecated it in favor of eslint - github.com/Microsoft/TypeScript/issues/… (granted, this development occurred 6 days after the answer was posted)
– Spain Train
4 hours ago
add a comment |
thanks a lot @Bronco... going to set it up ... I'll also write 2 scripts : lint-client ( eslint .js client files and lint-server ( ts lint .ts node server files )
– user762579
Jan 1 at 13:21
Solved .. it runs OK
– user762579
Jan 1 at 17:49
Please provide a rationale if your answer to "How do I use technology A?" is "Use technology B instead". However, one shouldn't use tslint because Microsoft has deprecated it in favor of eslint - github.com/Microsoft/TypeScript/issues/… (granted, this development occurred 6 days after the answer was posted)
– Spain Train
4 hours ago
thanks a lot @Bronco... going to set it up ... I'll also write 2 scripts : lint-client ( eslint .js client files and lint-server ( ts lint .ts node server files )
– user762579
Jan 1 at 13:21
thanks a lot @Bronco... going to set it up ... I'll also write 2 scripts : lint-client ( eslint .js client files and lint-server ( ts lint .ts node server files )
– user762579
Jan 1 at 13:21
Solved .. it runs OK
– user762579
Jan 1 at 17:49
Solved .. it runs OK
– user762579
Jan 1 at 17:49
Please provide a rationale if your answer to "How do I use technology A?" is "Use technology B instead". However, one shouldn't use tslint because Microsoft has deprecated it in favor of eslint - github.com/Microsoft/TypeScript/issues/… (granted, this development occurred 6 days after the answer was posted)
– Spain Train
4 hours ago
Please provide a rationale if your answer to "How do I use technology A?" is "Use technology B instead". However, one shouldn't use tslint because Microsoft has deprecated it in favor of eslint - github.com/Microsoft/TypeScript/issues/… (granted, this development occurred 6 days after the answer was posted)
– Spain Train
4 hours ago
add a comment |
parser
is a root-level config item, not a field of parserOptions
:
"eslintConfig": {
"parser": "typescript-eslint-parser"
"parserOptions": { ...options },
"plugins": ["typescript"]
}
Also, the parser and plugin you are using are deprecated. The newer/maintained projects are both available at https://github.com/typescript-eslint/typescript-eslint. (Config is the same, just with updated names). Here is an nice step-by-step walk-through on how to set this up - https://dev.to/robertcoopercode/using-eslint-and-prettier-in-a-typescript-project-53jb
Note that rather than defining your eslint config in package.json
, you could instead use a separate.eslintrc.{js,yaml}
. One in the root directory would setup your standard rules for JavaScript and another one in ./src/server
could setup the TypeScript parser & plugin only for the relevant directory (but still pick up all your standard root rules).
add a comment |
parser
is a root-level config item, not a field of parserOptions
:
"eslintConfig": {
"parser": "typescript-eslint-parser"
"parserOptions": { ...options },
"plugins": ["typescript"]
}
Also, the parser and plugin you are using are deprecated. The newer/maintained projects are both available at https://github.com/typescript-eslint/typescript-eslint. (Config is the same, just with updated names). Here is an nice step-by-step walk-through on how to set this up - https://dev.to/robertcoopercode/using-eslint-and-prettier-in-a-typescript-project-53jb
Note that rather than defining your eslint config in package.json
, you could instead use a separate.eslintrc.{js,yaml}
. One in the root directory would setup your standard rules for JavaScript and another one in ./src/server
could setup the TypeScript parser & plugin only for the relevant directory (but still pick up all your standard root rules).
add a comment |
parser
is a root-level config item, not a field of parserOptions
:
"eslintConfig": {
"parser": "typescript-eslint-parser"
"parserOptions": { ...options },
"plugins": ["typescript"]
}
Also, the parser and plugin you are using are deprecated. The newer/maintained projects are both available at https://github.com/typescript-eslint/typescript-eslint. (Config is the same, just with updated names). Here is an nice step-by-step walk-through on how to set this up - https://dev.to/robertcoopercode/using-eslint-and-prettier-in-a-typescript-project-53jb
Note that rather than defining your eslint config in package.json
, you could instead use a separate.eslintrc.{js,yaml}
. One in the root directory would setup your standard rules for JavaScript and another one in ./src/server
could setup the TypeScript parser & plugin only for the relevant directory (but still pick up all your standard root rules).
parser
is a root-level config item, not a field of parserOptions
:
"eslintConfig": {
"parser": "typescript-eslint-parser"
"parserOptions": { ...options },
"plugins": ["typescript"]
}
Also, the parser and plugin you are using are deprecated. The newer/maintained projects are both available at https://github.com/typescript-eslint/typescript-eslint. (Config is the same, just with updated names). Here is an nice step-by-step walk-through on how to set this up - https://dev.to/robertcoopercode/using-eslint-and-prettier-in-a-typescript-project-53jb
Note that rather than defining your eslint config in package.json
, you could instead use a separate.eslintrc.{js,yaml}
. One in the root directory would setup your standard rules for JavaScript and another one in ./src/server
could setup the TypeScript parser & plugin only for the relevant directory (but still pick up all your standard root rules).
answered 5 hours ago
Spain TrainSpain Train
3,32221825
3,32221825
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53994834%2feslint-linting-my-typescript-files-correctly%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown