-
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.
- Loading branch information
Showing
28 changed files
with
15,299 additions
and
9,783 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 @@ | ||
dist/** | ||
coverage/** | ||
package-lock.json |
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,73 @@ | ||
const invalidCodeBlockRules = { | ||
// Invalid rules for embedded code-blocks | ||
"import/no-unresolved": "off", | ||
"no-undef": "off", | ||
"no-unused-expressions": "off", | ||
"no-unused-vars": "off", | ||
"no-unreachable": "off" | ||
}; | ||
|
||
module.exports = { | ||
root: true, | ||
overrides: [ | ||
{ | ||
files: ["*.ts"], | ||
excludedFiles: ["*.md/*.ts"], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: "tsconfig.eslint.json", | ||
sourceType: "module" | ||
}, | ||
plugins: ["@typescript-eslint", "eslint-plugin"], | ||
extends: [ | ||
"eslint:recommended", | ||
"airbnb-base", | ||
"airbnb-typescript/base", | ||
"plugin:eslint-plugin/rules-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking", | ||
"plugin:prettier/recommended" | ||
] | ||
}, | ||
{ | ||
files: ["tests/**"], | ||
env: { | ||
"jest/globals": true | ||
}, | ||
extends: [ | ||
"plugin:jest/recommended", | ||
"plugin:jest/style", | ||
"plugin:eslint-plugin/tests-recommended" | ||
], | ||
plugins: ["jest"], | ||
rules: { | ||
"import/no-extraneous-dependencies": [ | ||
"error", | ||
{ devDependencies: true } | ||
] | ||
} | ||
}, | ||
{ | ||
files: ["*.js"], | ||
extends: [ | ||
"eslint:recommended", | ||
"airbnb-base", | ||
"plugin:prettier/recommended" | ||
] | ||
}, | ||
{ | ||
files: ["*.md"], | ||
extends: ["plugin:mdx/recommended"], | ||
settings: { | ||
"mdx/code-blocks": true | ||
} | ||
}, | ||
{ | ||
// Markdown JS code-blocks (virtual filepath) | ||
files: ["**/*.md/*.js"], | ||
rules: { | ||
...invalidCodeBlockRules | ||
} | ||
} | ||
] | ||
}; |
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 @@ | ||
* text=auto eol=lf |
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,11 @@ | ||
{ | ||
"arrowParens": "always", | ||
"printWidth": 80, | ||
"proseWrap": "always", | ||
"quoteProps": "consistent", | ||
"semi": true, | ||
"singleQuote": false, | ||
"tabWidth": 4, | ||
"useTabs": false, | ||
"trailingComma": "none" | ||
} |
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,8 @@ | ||
{ | ||
"plugins": [ | ||
"preset-lint-consistent", | ||
"preset-lint-markdown-style-guide", | ||
"preset-lint-recommended", | ||
"preset-prettier" | ||
] | ||
} |
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,52 +1,57 @@ | ||
# eslint-plugin-testcafe-community | ||
|
||
ESLint rules for [testcafe](https://github.com/DevExpress/testcafe) from the testcafe community. | ||
|
||
## Installation | ||
|
||
You'll first need to install [ESLint](http://eslint.org): | ||
|
||
``` | ||
npm i eslint --save-dev | ||
``` | ||
|
||
Next, install `eslint-plugin-testcafe-community`: | ||
|
||
``` | ||
npm install eslint-plugin-testcafe-community --save-dev | ||
``` | ||
|
||
**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-testcafe-community` globally. | ||
|
||
## Recommended configuration | ||
|
||
This plugin export a recommended configuration that enforce good practices. | ||
|
||
To enable this configuration use the extends property in your .eslintrc config file: | ||
|
||
``` | ||
{ | ||
"plugins": [ | ||
"testcafe-community" | ||
], | ||
"extends": "plugin:testcafe-community/recommended" | ||
} | ||
``` | ||
|
||
See [ESLint documentation](http://eslint.org/docs/user-guide/configuring#extending-configuration-files) for more information about extending configuration files. | ||
|
||
## Supported Rules | ||
|
||
✔️ indicates that a rule is recommended for all users. | ||
|
||
🛠 indicates that a rule is fixable. | ||
|
||
# eslint-plugin-testcafe-community | ||
|
||
ESLint rules for [testcafe](https://github.com/DevExpress/testcafe) from the | ||
testcafe community. | ||
|
||
## Installation | ||
|
||
You'll first need to install [ESLint](http://eslint.org): | ||
|
||
```sh | ||
npm i eslint --save-dev | ||
``` | ||
|
||
Next, install `eslint-plugin-testcafe-community`: | ||
|
||
```sh | ||
npm install eslint-plugin-testcafe-community --save-dev | ||
``` | ||
|
||
**Note:** If you installed ESLint globally (using the `-g` flag) then you must | ||
also install `eslint-plugin-testcafe-community` globally. | ||
|
||
## Recommended configuration | ||
|
||
This plugin export a recommended configuration that enforce good practices. | ||
|
||
To enable this configuration use the extends property in your .eslintrc config | ||
file: | ||
|
||
```json | ||
{ | ||
"plugins": ["testcafe-community"], | ||
"extends": "plugin:testcafe-community/recommended" | ||
} | ||
``` | ||
|
||
See | ||
[ESLint documentation](http://eslint.org/docs/user-guide/configuring#extending-configuration-files) | ||
for more information about extending configuration files. | ||
|
||
## Supported Rules | ||
|
||
✔️ indicates that a rule is recommended for all users. | ||
|
||
🛠 indicates that a rule is fixable. | ||
|
||
<!-- __BEGIN AUTOGENERATED RULES TABLE__ --> | ||
| Name | ✔️ | 🛠 | Description | | ||
| ----- | ----- | ----- | ----------- | | ||
| [expectExpect](https://github.com/testcafe-community/eslint-plugin-testcafe-community/blob/master/docs/rules/expectExpect.md) | ✔️ | | Ensure tests have at least one expect | | ||
| [noDebug](https://github.com/testcafe-community/eslint-plugin-testcafe-community/blob/master/docs/rules/noDebug.md) | ✔️ | | Don't allow `t.debug()` to be committed to the repository. | | ||
| [noIdenticalTitle](https://github.com/testcafe-community/eslint-plugin-testcafe-community/blob/master/docs/rules/noIdenticalTitle.md) | ✔️ | | Don't use identical titles for your tests | | ||
| [noOnly](https://github.com/testcafe-community/eslint-plugin-testcafe-community/blob/master/docs/rules/noOnly.md) | ✔️ | | Don't allow `test.only` to be added to the repository | | ||
| [noSkip](https://github.com/testcafe-community/eslint-plugin-testcafe-community/blob/master/docs/rules/noSkip.md) | ✔️ | | Don't allow `test.skip` or `fixture.skip` to be added to the repository | | ||
<!-- __END AUTOGENERATED RULES TABLE__ --> | ||
|
||
| Name | ✔️ | 🛠 | Description | | ||
| ------------------------------------------------------------------------------------------------------------------------------------- | --- | --- | ----------------------------------------------------------------------- | | ||
| [expectExpect](https://github.com/testcafe-community/eslint-plugin-testcafe-community/blob/master/docs/rules/expectExpect.md) | ✔️ | | Ensure tests have at least one expect | | ||
| [noDebug](https://github.com/testcafe-community/eslint-plugin-testcafe-community/blob/master/docs/rules/noDebug.md) | ✔️ | | Don't allow `t.debug()` to be committed to the repository. | | ||
| [noIdenticalTitle](https://github.com/testcafe-community/eslint-plugin-testcafe-community/blob/master/docs/rules/noIdenticalTitle.md) | ✔️ | | Don't use identical titles for your tests | | ||
| [noOnly](https://github.com/testcafe-community/eslint-plugin-testcafe-community/blob/master/docs/rules/noOnly.md) | ✔️ | | Don't allow `test.only` to be added to the repository | | ||
| [noSkip](https://github.com/testcafe-community/eslint-plugin-testcafe-community/blob/master/docs/rules/noSkip.md) | ✔️ | | Don't allow `test.skip` or `fixture.skip` to be added to the repository | | ||
|
||
<!-- __END AUTOGENERATED RULES TABLE__ --> |
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,64 +1,65 @@ | ||
"use strict"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
import { rules } from "../lib"; | ||
import { repository } from "../package.json"; | ||
|
||
const fs = require("fs"); | ||
const path = require("path"); | ||
const { rules } = require("../lib"); | ||
const { repository } = require("../package.json"); | ||
const repoURL = repository.url.replace(/^git:\/\//, ""); | ||
|
||
const README_LOCATION = path.resolve(__dirname, "..", "README.md"); | ||
const BEGIN_TABLE_MARKER = "<!-- __BEGIN AUTOGENERATED RULES TABLE__ -->"; | ||
const END_TABLE_MARKER = "<!-- __END AUTOGENERATED RULES TABLE__ -->"; | ||
|
||
const expectedTableLines = Object.keys(rules) | ||
.sort() | ||
.reduce( | ||
(lines, ruleId) => { | ||
const rule = rules[ruleId]; | ||
.sort() | ||
.reduce( | ||
(lines, ruleId) => { | ||
const rule = rules[ruleId]; | ||
|
||
const tr = [ | ||
`[${ruleId}](https://${repoURL}/blob/master/docs/rules/${ruleId}.md)`, | ||
rule.meta.docs.recommended ? "✔️" : "", | ||
rule.meta.fixable ? "🛠" : "", | ||
rule.meta.docs.description | ||
].join(" | ") | ||
const tr = [ | ||
`[${ruleId}](https://${repoURL}/blob/master/docs/rules/${ruleId}.md)`, | ||
rule.meta.docs.recommended ? "✔️" : "", | ||
rule.meta.fixable ? "🛠" : "", | ||
rule.meta.docs.description | ||
].join(" | "); | ||
|
||
lines.push(`| ${tr} |`); | ||
lines.push(`| ${tr} |`); | ||
|
||
return lines; | ||
}, | ||
[ | ||
"| Name | ✔️ | 🛠 | Description |", | ||
"| ----- | ----- | ----- | ----------- |" | ||
] | ||
) | ||
.join("\n"); | ||
return lines; | ||
}, | ||
[ | ||
"| Name | ✔️ | 🛠 | Description |", | ||
"| ----- | ----- | ----- | ----------- |" | ||
] | ||
) | ||
.join("\n"); | ||
|
||
const readmeContents = fs.readFileSync(README_LOCATION, "utf8"); | ||
|
||
if (!readmeContents.includes(BEGIN_TABLE_MARKER)) { | ||
throw new Error( | ||
`Could not find '${BEGIN_TABLE_MARKER}' marker in README.md.` | ||
); | ||
throw new Error( | ||
`Could not find '${BEGIN_TABLE_MARKER}' marker in README.md.` | ||
); | ||
} | ||
|
||
if (!readmeContents.includes(END_TABLE_MARKER)) { | ||
throw new Error(`Could not find '${END_TABLE_MARKER}' marker in README.md.`); | ||
throw new Error( | ||
`Could not find '${END_TABLE_MARKER}' marker in README.md.` | ||
); | ||
} | ||
|
||
const linesStartIndex = | ||
readmeContents.indexOf(BEGIN_TABLE_MARKER) + BEGIN_TABLE_MARKER.length; | ||
readmeContents.indexOf(BEGIN_TABLE_MARKER) + BEGIN_TABLE_MARKER.length; | ||
const linesEndIndex = readmeContents.indexOf(END_TABLE_MARKER); | ||
|
||
const updatedReadmeContents = [ | ||
readmeContents.slice(0, linesStartIndex), | ||
expectedTableLines, | ||
readmeContents.slice(linesEndIndex) | ||
readmeContents.slice(0, linesStartIndex), | ||
expectedTableLines, | ||
readmeContents.slice(linesEndIndex) | ||
].join("\n"); | ||
|
||
if (require.main === module) { | ||
// Run on command line | ||
fs.writeFileSync(README_LOCATION, updatedReadmeContents); | ||
// Run on command line | ||
fs.writeFileSync(README_LOCATION, updatedReadmeContents); | ||
} else { | ||
module.exports = updatedReadmeContents; | ||
module.exports = updatedReadmeContents; | ||
} |
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.