Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eslint #70

Closed
wants to merge 6 commits into from
Closed

Conversation

Ethan-Arrowood
Copy link

✨ Wonderful Project! Thought i could lend a hand and add eslint for you. The configuration I'm using is based on one I'm using in my own TypeScript package development project: Matterhorn. Going to push a second commit that adds rules to fit the current project structure. Furthermore, I set the ecmaVersion based on what you have in the tsconfig.json file. Let me know if you have any questions!

@Ethan-Arrowood
Copy link
Author

Looks like there may be a conflict with prettier. I'll defer to your review on what modifications I should make. I believe there is a plugin to merge prettier with eslint I just haven't used it in a while

@jaredpalmer
Copy link
Owner

Do a reinstall with yarn for me.

@jaredpalmer
Copy link
Owner

and push

@jaredpalmer
Copy link
Owner

We've been a little lazy to move off of TSLint on our team. I guess we should bite the bullet and update palmerhq/typerscript.

@Ethan-Arrowood
Copy link
Author

This PR actually inspired me to dive head first and write up a detailed article on TypeScript + ESLint. You can check out the unpublished version here. It is nearly done just waiting on one more peer to review it. In the article I detail how to set it up with prettier too. I'm going to push some changes to this PR soon with an ESLint & Prettier integration (also outlined in the article).

@Ethan-Arrowood
Copy link
Author

Okay updated and fixed up some of the rules. Pretty close to passing. Here is the current output of yarn lint

👻 tsdx (add-eslint)▷ yarn lint
yarn run v1.15.2
$ eslint src/**/*.ts

/Users/ethanarrowood/Documents/GitHub/tsdx/src/createJestConfig.ts
  1:8  warning  'fs' is defined but never used    @typescript-eslint/no-unused-vars
  2:8  warning  'path' is defined but never used  @typescript-eslint/no-unused-vars

/Users/ethanarrowood/Documents/GitHub/tsdx/src/createRollupConfig.ts
  2:1  error  'ge' is not defined  no-undef

/Users/ethanarrowood/Documents/GitHub/tsdx/src/index.ts
   25:13  error    Require statement not part of import statement  @typescript-eslint/no-var-requires
   26:22  error    Require statement not part of import statement  @typescript-eslint/no-var-requires
   38:10  warning  Unexpected any. Specify a different type        @typescript-eslint/no-explicit-any
   42:13  warning  Empty block statement                           no-empty
   60:1   error    Expected indentation of 6 spaces but found 4    @typescript-eslint/indent
   61:1   error    Expected indentation of 6 spaces but found 4    @typescript-eslint/indent
   67:15  warning  Unexpected any. Specify a different type        @typescript-eslint/no-explicit-any
   68:13  warning  Unexpected any. Specify a different type        @typescript-eslint/no-explicit-any
   81:35  warning  Unexpected any. Specify a different type        @typescript-eslint/no-explicit-any
  105:15  warning  Empty block statement                           no-empty
  225:7   warning  Unexpected console statement                    no-console
  244:24  warning  Unexpected any. Specify a different type        @typescript-eslint/no-explicit-any
  257:1   error    Expected indentation of 4 spaces but found 10   @typescript-eslint/indent
  258:1   error    Expected indentation of 2 spaces but found 8    @typescript-eslint/indent
  261:1   error    Expected indentation of 4 spaces but found 10   @typescript-eslint/indent
  262:1   error    Expected indentation of 2 spaces but found 8    @typescript-eslint/indent
  291:9   warning  Unexpected console statement                    no-console
  296:26  warning  Empty block statement                           no-empty
  312:24  warning  Unexpected any. Specify a different type        @typescript-eslint/no-explicit-any
  327:1   error    Expected indentation of 4 spaces but found 10   @typescript-eslint/indent
  328:1   error    Expected indentation of 2 spaces but found 8    @typescript-eslint/indent
  331:1   error    Expected indentation of 4 spaces but found 10   @typescript-eslint/indent
  332:1   error    Expected indentation of 2 spaces but found 8    @typescript-eslint/indent
  353:20  warning  Unexpected any. Specify a different type        @typescript-eslint/no-explicit-any

/Users/ethanarrowood/Documents/GitHub/tsdx/src/logError.ts
  3:16  warning  Unexpected console statement              no-console
  5:39  warning  Unexpected any. Specify a different type  @typescript-eslint/no-explicit-any

/Users/ethanarrowood/Documents/GitHub/tsdx/src/output.ts
   7:3  warning  Unexpected console statement  no-console
  15:3  warning  Unexpected console statement  no-console
  19:3  warning  Unexpected console statement  no-console

✖ 32 problems (13 errors, 19 warnings)
  10 errors and 0 warnings potentially fixable with the `--fix` option.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@skvale
Copy link
Contributor

skvale commented May 11, 2019

Configuring eslint with TypeScript isn't easy. What if tsdx had a lint command as well? #99

And it used tsdx lint to lint its own source code.

@jaredpalmer
Copy link
Owner

See #99

@@ -1,4 +1,5 @@
import { DEFAULT_EXTENSIONS } from '@babel/core';
ge;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wut.

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

Successfully merging this pull request may close these issues.

None yet

4 participants