-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable custom eslint configuration
- Loading branch information
Showing
7 changed files
with
648 additions
and
76 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "airbnb" | ||
} |
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 |
---|---|---|
@@ -1,20 +1,21 @@ | ||
import readPkgUp from 'read-pkg-up' | ||
import readPkgUp from 'read-pkg-up'; | ||
|
||
const DEFAULT_CONF = { | ||
withTest: false, | ||
withStyled: false, | ||
testSuffix: 'test', | ||
} | ||
eslint: '', | ||
}; | ||
|
||
const getConfiguration = async () => { | ||
const packageJson = await readPkgUp() | ||
const packageJson = await readPkgUp(); | ||
|
||
if(!packageJson || !packageJson.package.mkcomponent) return DEFAULT_CONF | ||
if (!packageJson || !packageJson.package.mkcomponent) return DEFAULT_CONF; | ||
|
||
return { | ||
...DEFAULT_CONF, | ||
...packageJson.package.mkcomponent | ||
} | ||
} | ||
...packageJson.package.mkcomponent, | ||
}; | ||
}; | ||
|
||
export default getConfiguration | ||
export default getConfiguration; |
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,21 @@ | ||
/* eslint-disable global-require */ | ||
import fs from 'fs'; | ||
import findUp from 'find-up'; | ||
|
||
export const lintFile = (config) => ({ dir, data }) => { | ||
const { CLIEngine, Linter } = require('eslint'); | ||
|
||
const linter = new Linter(); | ||
const cli = new CLIEngine({ baseConfig: config }); | ||
const fileConfig = cli.getConfigForFile(dir); | ||
|
||
const lintedData = linter.verifyAndFix(data, fileConfig); | ||
|
||
return lintedData.output; | ||
}; | ||
|
||
export const getEslintConfig = async (option) => { | ||
const configFile = await findUp(option); | ||
const file = fs.readFileSync(configFile, 'utf8'); | ||
return JSON.parse(file); | ||
}; |
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
Oops, something went wrong.