From 1dbaa5f31d44848b7ef83dce368a53ee00d0ba0b Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Fri, 26 Oct 2018 09:19:32 -0700 Subject: [PATCH 1/5] [TEST] add travis config --- .travis.yml | 10 ++++++++++ package.json | 5 ++++- prettier.config.js | 11 ++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0fa5f54 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +dist: trusty +language: node_js +node_js: + - '10' + - '8' + - '6' +install: npm i +script: + - npm run check-format + - npm run test diff --git a/package.json b/package.json index 2ea3f18..f0f471d 100644 --- a/package.json +++ b/package.json @@ -32,9 +32,12 @@ "dummy.js": "file:dummy.js", "eslint": "^5.6.1", "eslint-plugin-import": "^2.14.0", + "prettier": "^1.14.3", "typescript": "^3.1.1" }, "scripts": { - "test": "eslint ./tests/withPaths/index.ts && eslint ./tests/withoutPaths/index.ts" + "test": "eslint ./tests/withPaths/index.ts && eslint ./tests/withoutPaths/index.ts", + "check-format": "prettier --config prettier.config.js index.js -l", + "format": "prettier --config prettier.config.js index.js --write" } } diff --git a/prettier.config.js b/prettier.config.js index fd2b43c..5f9578e 100644 --- a/prettier.config.js +++ b/prettier.config.js @@ -1,5 +1,14 @@ +'use strict'; + module.exports = { - parser: 'typescript', + arrowParens: 'avoid', + bracketSpacing: true, + parser: 'babylon', + jsxBracketSameLine: true, + proseWrap: 'preserve', + semi: true, singleQuote: true, + tabWidth: 2, trailingComma: 'all', + useTabs: false, }; From a99870f3524f191134a4e44dc8d57d1ee04d2b2b Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Fri, 26 Oct 2018 10:33:26 -0700 Subject: [PATCH 2/5] Updated the README --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index aef2dd1..6ce4289 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # eslint-import-resolver-typescript +[![Build Status](https://travis-ci.org/alexgorbatchev/eslint-import-resolver-typescript.svg?branch=master)](https://travis-ci.org/alexgorbatchev/eslint-import-resolver-typescript) + This plugin adds typescript support to [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import). This means you can: @@ -45,3 +47,7 @@ Add the following to your `.eslintrc` config: - Make sure your change is covered by a test import. - Make sure that `npm test` passes without a failure. +- Make sure your code is formatted `npm format`. + +We have an [automatic travis build](https://travis-ci.org/alexgorbatchev/eslint-import-resolver-typescript) which will run the above on your PRs. +If either fails, we won't be able to merge your PR until it's fixed. From 04a9513e924a94c4621322e13d39234f52d808f2 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Fri, 26 Oct 2018 10:49:58 -0700 Subject: [PATCH 3/5] fixed module breaking on node 6 --- index.js | 4 ++-- prettier.config.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 7a14792..8f65a6e 100644 --- a/index.js +++ b/index.js @@ -28,7 +28,7 @@ function resolveFile(source, file, config) { const extensions = Object.keys(require.extensions).concat( '.ts', '.tsx', - '.d.ts', + '.d.ts' ); // setup tsconfig-paths @@ -37,7 +37,7 @@ function resolveFile(source, file, config) { if (configLoaderResult.resultType === 'success') { const matchPath = tsconfigPaths.createMatchPath( configLoaderResult.absoluteBaseUrl, - configLoaderResult.paths, + configLoaderResult.paths ); // look for files based on setup tsconfig "paths" diff --git a/prettier.config.js b/prettier.config.js index 5f9578e..32aedf9 100644 --- a/prettier.config.js +++ b/prettier.config.js @@ -9,6 +9,6 @@ module.exports = { semi: true, singleQuote: true, tabWidth: 2, - trailingComma: 'all', + trailingComma: 'es5', useTabs: false, }; From 3321b98647416ade0d45bce4ba4a75340f4c76f6 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Thu, 13 Dec 2018 08:55:39 -0800 Subject: [PATCH 4/5] drop node 6 compatability --- .travis.yml | 1 - prettier.config.js | 2 +- tests/baseEslintConfig.js | 60 +++++++++++++++++++-------------------- 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0fa5f54..b5ecabd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: node_js node_js: - '10' - '8' - - '6' install: npm i script: - npm run check-format diff --git a/prettier.config.js b/prettier.config.js index 32aedf9..5f9578e 100644 --- a/prettier.config.js +++ b/prettier.config.js @@ -9,6 +9,6 @@ module.exports = { semi: true, singleQuote: true, tabWidth: 2, - trailingComma: 'es5', + trailingComma: 'all', useTabs: false, }; diff --git a/tests/baseEslintConfig.js b/tests/baseEslintConfig.js index 1435844..d89d048 100644 --- a/tests/baseEslintConfig.js +++ b/tests/baseEslintConfig.js @@ -1,34 +1,32 @@ -const path = require('path') +const path = require('path'); -module.exports = (dirname) => ({ - env: { - es6: true, - }, - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - }, - plugins: [ - 'import' +module.exports = dirname => ({ + env: { + es6: true, + }, + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + }, + plugins: ['import'], + rules: { + 'import/no-unresolved': 'error', + 'import/extensions': [ + 'error', + 'ignorePackages', + { + js: 'never', + jsx: 'never', + ts: 'never', + tsx: 'never', + }, ], - rules: { - 'import/no-unresolved': 'error', - 'import/extensions': [ - 'error', - 'ignorePackages', - { - js: 'never', - jsx: 'never', - ts: 'never', - tsx: 'never', - }, - ], - }, - settings: { - 'import/resolver': { - [path.resolve(`${__dirname}/../index.js`)]: { - directory: dirname, - }, - }, + }, + settings: { + 'import/resolver': { + [path.resolve(`${__dirname}/../index.js`)]: { + directory: dirname, + }, }, -}) + }, +}); From ce6458068a38bd1e6850b72f2dc77d8a71777d90 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Thu, 13 Dec 2018 09:32:50 -0800 Subject: [PATCH 5/5] format --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 8f65a6e..7a14792 100644 --- a/index.js +++ b/index.js @@ -28,7 +28,7 @@ function resolveFile(source, file, config) { const extensions = Object.keys(require.extensions).concat( '.ts', '.tsx', - '.d.ts' + '.d.ts', ); // setup tsconfig-paths @@ -37,7 +37,7 @@ function resolveFile(source, file, config) { if (configLoaderResult.resultType === 'success') { const matchPath = tsconfigPaths.createMatchPath( configLoaderResult.absoluteBaseUrl, - configLoaderResult.paths + configLoaderResult.paths, ); // look for files based on setup tsconfig "paths"