0

I achieved to configure a VS code project according to the airbnb and typescript config, and finally the typescruipt code linting behaves as expected.

Find the .eslintrc.js:

const path = require('path'); module.exports = { root: true, env: { browser: true, jquery: true }, extends: [ 'airbnb/base', 'plugin:@typescript-eslint/recommended', ], parserOptions: { parser: 'parser: '@typescript-eslint/parser', ecmaVersion: 2018, sourceType: 'module', }, settings: { 'import/resolver': { alias: { map: [ ['@', path.resolve(__dirname, 'src')], ], extensions: [ '.js', '.js', '.json', ], }, }, }, rules: { 'comma-dangle': ['error', { 'arrays': 'always-multiline', 'objects': 'always-multiline', 'imports': 'always-multiline', 'exports': 'always-multiline', 'functions': 'never' }], 'function-paren-newline': ['error', 'consistent'], 'no-alert': 0, 'no-bitwise': 0, 'no-console': 0, 'no-param-reassign': 0, 'no-shadow': 0, 'jsx-a11y/anchor-is-valid': 0, 'jsx-a11y/click-events-have-key-events': 0, 'jsx-a11y/label-has-associated-control': 0, 'jsx-a11y/label-has-for': 0, 'jsx-a11y/no-autofocus': 0, 'jsx-a11y/no-noninteractive-element-interactions': 0, 'jsx-a11y/no-static-element-interactions': 0, 'linebreak-style': [0, "windows"], 'camelcase' : 0, 'no-plusplus' : 0, 'no-underscore-dangle' : 0, 'no-buffer-constructor:': 0 }, }; 

However, es-lint also works for the typescript compiled .js files, which I dont want to. I tried with the tsc compiler and prettier plugin to have these compiled according to the airbnn rules which I think is the most desirable. Another option would be to disable eslint for the js files. I have checked many articles about how to configure a proyect to work with typescript which I already achieved, but I am missing this last step of what happens to the .js compiled files regarding to linting and how to configure that. Also how to compile many files at once when you are working with many files in a proyect.

Apart from my concrete doubt, any comments regarding the typescript working flow is appreciated. I guess that you compile all your tsc files and set as your app entry point the corresponding tsc compiled .js file, but I am not sure if its like that.

Many thanks in advance.

1 Answer 1

2

You can configure eslint to ignore certain files or directories

If you have your app being compiled to a build directory, you might have this in your eslint:

"ignorePatterns": ["build"] 

Or if you want to ignore all .js files regardless of where they get compiled to:

"ignorePatterns": ["**/*.js"] 

Or use similar patterns in a .eslintignore file.

Sign up to request clarification or add additional context in comments.

3 Comments

thanks, that was useful. And what is usually done, compile all the tsc files to one folder, and ignore that for linting?
Yeah, exactly. add something like "outDir": "build" to tsconfig.json and then you can easily sequester compiled code from all your typescript code. It makes it very easily to treat it differently that way.
Nice. Thank you so much

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.