diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb1e703..e9d3dd6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,5 +44,10 @@ jobs: run: npm install env: CI: true + - name: Install examples/typescript Packages + working-directory: ./examples/typescript + run: npm install + env: + CI: true - name: Test run: npm run test-cov diff --git a/examples/typescript/.eslintrc.js b/examples/typescript/.eslintrc.js new file mode 100644 index 0000000..d512301 --- /dev/null +++ b/examples/typescript/.eslintrc.js @@ -0,0 +1,22 @@ +"use strict"; + +module.exports = { + root: true, + extends: [ + "eslint:recommended", + "plugin:markdown/recommended", + ], + overrides: [ + { + files: [".eslintrc.js"], + env: { + node: true + } + }, + { + files: ["*.ts"], + parser: "@typescript-eslint/parser", + extends: ["plugin:@typescript-eslint/recommended"] + }, + ] +}; diff --git a/examples/typescript/.npmrc b/examples/typescript/.npmrc new file mode 100644 index 0000000..c1ca392 --- /dev/null +++ b/examples/typescript/.npmrc @@ -0,0 +1 @@ +package-lock = false diff --git a/examples/typescript/README.md b/examples/typescript/README.md new file mode 100644 index 0000000..031b152 --- /dev/null +++ b/examples/typescript/README.md @@ -0,0 +1,25 @@ +# React Example + +The `@typescript-eslint` parser and the `recommended` config's rules will work in `ts` code blocks. However, [type-aware rules](https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/TYPED_LINTING.md) will not work because the code blocks are not part of a compilable `tsconfig.json` project. + +```ts +function hello(name: String) { + console.log(`Hello, ${name}!`); +} + +hello(42 as any); +``` + +```sh +$ git clone https://github.com/eslint/eslint-plugin-markdown.git +$ cd eslint-plugin-markdown/examples/typescript +$ npm install +$ npm test + +eslint-plugin-markdown/examples/typescript/README.md + 6:22 error Don’t use `String` as a type. Use string instead @typescript-eslint/ban-types + 10:13 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any + +✖ 2 problems (1 error, 1 warning) + 1 error and 0 warnings potentially fixable with the `--fix` option. +``` diff --git a/examples/typescript/package.json b/examples/typescript/package.json new file mode 100644 index 0000000..45df326 --- /dev/null +++ b/examples/typescript/package.json @@ -0,0 +1,13 @@ +{ + "private": true, + "scripts": { + "test": "eslint ." + }, + "devDependencies": { + "@typescript-eslint/eslint-plugin": "^3.6.1", + "@typescript-eslint/parser": "^3.6.1", + "eslint": "^7.5.0", + "eslint-plugin-markdown": "file:../..", + "typescript": "^3.9.7" + } +}