-
Notifications
You must be signed in to change notification settings - Fork 509
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 tsdx lint command #99
Merged
Merged
Changes from 27 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
a53365a
feat(lint): Add tsdx lint command
sam-kvale-sap c2d5ff8
feat(lint): process.exit(1) when errorCount > 0
sam-kvale-sap b34a8f4
style(lint): Fix lint errors that failed the CI build
sam-kvale-sap 641f5fb
feat(lint): Play nicely with pretty-quick husky hook
sam-kvale-sap 87d26f6
feat(lint): Install eslint-prettier dependencies, remove tslint devDeps
sam-kvale-sap 2009b77
feat(lint): Add jsx linting support for React by default
sam-kvale-sap ec9ee11
fix(lint): Fix local ignore-pattern
sam-kvale-sap dcf82df
feat(lint): Use @typescript-eslint/no-unused-vars instead of typescri…
sam-kvale-sap 9467d40
Merge branch 'master' into feat/linting-command
swyxio 5f82e13
Update lockfile
jaredpalmer 6be8bc4
Merge branch 'master' into pr/skvale/99
jaredpalmer 17a1f6c
Merge branch 'master' into pr/skvale/99
jaredpalmer 97e97c2
Add pre-commit lint hook
jaredpalmer 6fafc73
Specify no-unused-locals in tsconfig
jaredpalmer 0794e13
feat(lint): Extend react-app from eslint-config-react-app
sam-kvale-sap eae9bac
test(lint): Tests no longer failed from spacing violations
sam-kvale-sap 63cb7eb
feat(lint): Could just extend react-app instead of overriding anything
sam-kvale-sap 42fb986
feat(lint): Use prettier eslint for tsdx as an opt-in
sam-kvale-sap 4332881
feat(lint): Optionally use prettier with --prettier flag
sam-kvale-sap 12f2e99
feat(lint): Specify how to customize the lint rules in the README
sam-kvale-sap 92adf03
feat(lint): Use prettier by default again
sam-kvale-sap eb2fe5b
Merge branch 'master' into feat/linting-command
sam-kvale-sap 3f57f61
feat(lint): Use eslint@6
sam-kvale-sap 4197482
chore(lockfile): Commit updated lockfile
sam-kvale-sap 257a196
feat(lint): Update to @typescript-eslint/{parser,eslint-plugin} v1.11.0
sam-kvale-sap 83c753d
chore(deps): Bump eslint and @typescript-eslint
sam-kvale-sap 1604e99
Merge branch 'master' into feat/linting-command
sam-kvale-sap a51795a
Merge branch 'master' into feat/linting-command
sam-kvale-sap 9d595a5
feat(lint): Bump deps and simplify createEslintConfig
sam-kvale-sap 215cd93
feat(lint): Simplify written eslintrc
sam-kvale-sap 530b8b5
chore(docs): Remove wrongfully merged README addition
sam-kvale-sap fe37a21
chore(yarn.lock): Fix merge issue with the babel/core version
sam-kvale-sap 65ea74f
feat(lint): Bump eslint-config-react-app dep
sam-kvale-sap 00584a1
feat(lint): Last small updates
sam-kvale-sap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { CLIEngine } from 'eslint'; | ||
import reactAppConfig from 'eslint-config-react-app'; | ||
|
||
interface CreateEslintConfigArgs { | ||
rootDir: string; | ||
writeFile: boolean; | ||
} | ||
export function createEslintConfig({ | ||
rootDir, | ||
writeFile, | ||
}: CreateEslintConfigArgs): CLIEngine.Options['baseConfig'] { | ||
/* | ||
This config could change to | ||
{ | ||
extends: [ | ||
'react-app', | ||
'prettier/@typescript-eslint', | ||
'plugin:prettier/recommended' | ||
] | ||
} | ||
after https://github.com/facebook/create-react-app/commit/24489ac0a667af416f1d59dd806dfc2623aabe36 is released | ||
eslint-config-react-app defines overrides as an object instead of an array, which is not supported in eslint@6. | ||
*/ | ||
const config = { | ||
...reactAppConfig, | ||
extends: ['prettier/@typescript-eslint', 'plugin:prettier/recommended'], | ||
overrides: undefined, | ||
parser: require.resolve('@typescript-eslint/parser'), | ||
parserOptions: reactAppConfig.overrides.parserOptions, | ||
plugins: [ | ||
...reactAppConfig.plugins, | ||
...reactAppConfig.overrides.plugins, | ||
'no-for-of-loops', | ||
], | ||
rules: { | ||
...reactAppConfig.rules, | ||
...reactAppConfig.overrides.rules, | ||
}, | ||
}; | ||
|
||
if (writeFile) { | ||
const file = path.join(rootDir, '.eslintrc.js'); | ||
if (fs.existsSync(file)) { | ||
console.error( | ||
'Error trying to save the Eslint configuration file:', | ||
`${file} already exists.` | ||
); | ||
} else { | ||
try { | ||
fs.writeFileSync( | ||
file, | ||
`module.exports = ${JSON.stringify(config, null, 2)}` | ||
); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
} | ||
} | ||
|
||
return config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const foo () => !!'bar'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const foo = ( ) => | ||
!! ('bar') | ||
; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const foo = () => !!'bar'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from 'react'; | ||
|
||
export const Foobar = (props: any) => { | ||
return <<div {...props}>foobar</div>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from 'react'; | ||
|
||
export const Foobar = (props: any) => { | ||
return <div {...props}>foobar </div>; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this necessary?
I think use the
@typescript-eslint/parser
parser is enough.