diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b5ecabd --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +dist: trusty +language: node_js +node_js: + - '10' + - '8' +install: npm i +script: + - npm run check-format + - npm run test diff --git a/README.md b/README.md index ecb1856..1a92f0d 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: @@ -43,3 +45,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. 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, }; 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, + }, }, -}) + }, +});