Skip to content

Commit

Permalink
feat: add eslint-config-typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
john-d-pelingo committed Dec 1, 2020
1 parent b2f00b3 commit 74b5606
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 1 deletion.
1 change: 0 additions & 1 deletion docs/TODOS.md
Expand Up @@ -5,5 +5,4 @@
- find a way to publish on github push
- create multiple ESLint packages for:
- JavaScript only
- Typescript only
- TypeScript + React
47 changes: 47 additions & 0 deletions packages/eslint-config-typescript/.eslintrc.js
@@ -0,0 +1,47 @@
const config = {
env: {
browser: true,
es6: true,
node: true,
},
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'import', 'jsx-a11y'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/@typescript-eslint',
'plugin:import/typescript',
],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-var-requires': 'off',
'import/no-default-export': 'error',
'import/no-deprecated': 'warn',
'import/order': [
'error',
{
pathGroupsExcludedImportTypes: ['builtin'],
groups: [
'builtin',
'external',
'internal',
'unknown',
'parent',
'sibling',
'index',
],
'newlines-between': 'always',
alphabetize: { order: 'asc' },
},
],
'import/prefer-default-export': 'off',
},
settings: {
'import/ignore': ['node_modules'],
},
}

module.exports = config
3 changes: 3 additions & 0 deletions packages/eslint-config-typescript/README.md
@@ -0,0 +1,3 @@
# @jdp-dev/eslint-config-typescript

My shareable [ESLint](https://eslint.org/) config for [TypeScript](https://www.typescriptlang.org/) projects.
6 changes: 6 additions & 0 deletions packages/eslint-config-typescript/__tests__/index.js
@@ -0,0 +1,6 @@
const test = require('tape')

test('entry point parses', (t) => {
t.doesNotThrow(() => require('..'), 'index does not throw')
t.end()
})
20 changes: 20 additions & 0 deletions packages/eslint-config-typescript/__tests__/validate-config.js
@@ -0,0 +1,20 @@
const eslint = require('eslint')
const test = require('tape')

test('load config in eslint to validate all rule syntax is correct', (t) => {
const cli = new eslint.CLIEngine({
useEslintrc: false,
configFile: 'index.js',
})

const code = `
const greet = (name: string): void => {
console.log(\`Hello, \${name}!\`)
}
`

const result = cli.executeOnText(code)

t.equal(result.errorCount, 0)
t.end()
})
1 change: 1 addition & 0 deletions packages/eslint-config-typescript/index.js
@@ -0,0 +1 @@
module.exports = require('./.eslintrc.js')
44 changes: 44 additions & 0 deletions packages/eslint-config-typescript/package.json
@@ -0,0 +1,44 @@
{
"name": "@jdp-dev/eslint-config-typescript",
"version": "0.0.3",
"description": "My shareable ESLint config for TypeScript projects.",
"private": false,
"homepage": "https://github.com/john-d-pelingo/jdp-scripts",
"author": {
"email": "johndarrylpelingo@gmail.com",
"name": "John Darryl Pelingo",
"url": "https://johndpelingo.com"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/john-d-pelingo/jdp-scripts",
"directory": "packages/eslint-config"
},
"bugs": {
"url": "https://github.com/john-d-pelingo/jdp-scripts/issues"
},
"main": "index.js",
"scripts": {
"lint": "eslint . --config=.eslintrc.js",
"test": "npm run lint && tape __tests__/*.js"
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0",
"eslint": "^7.14.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"typescript": "^4.1.2"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0",
"eslint": "^7.14.0",
"eslint-config-airbnb-typescript": "^12.0.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"typescript": "^4.1.2"
}
}

0 comments on commit 74b5606

Please sign in to comment.