Skip to content

Commit

Permalink
added custom eslint rule (check testcafe test.only)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-kurmanov committed Dec 7, 2021
1 parent e357658 commit 8e88024
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 45 deletions.
123 changes: 80 additions & 43 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,60 @@
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint"
],
"rules": {
"root": true,
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint",
"surveyjs"
],
"rules": {
"surveyjs/no-test-only": 2,
"no-console": 2, // Remember, this means error!
"indent": ["error", 2, { "SwitchCase": 1, "MemberExpression": 1, "CallExpression": { "arguments": 1 } }],
"indent": [
"error",
2,
{
"SwitchCase": 1,
"MemberExpression": 1,
"CallExpression": {
"arguments": 1
}
}
],
"no-trailing-spaces": "error",
"no-multi-spaces": "error",
"block-spacing": "error",
"no-multi-spaces": "error",
"block-spacing": "error",
"comma-spacing": "error",
"key-spacing": "error",
"semi-spacing": "error",

"object-curly-spacing": ["error", "always"],
"space-before-blocks": ["error", "always"],
"space-in-parens": ["error", "never"],
"array-bracket-spacing": ["error", "never"],
"computed-property-spacing": "error",
"object-curly-spacing": [
"error",
"always"
],
"space-before-blocks": [
"error",
"always"
],
"space-in-parens": [
"error",
"never"
],
"array-bracket-spacing": [
"error",
"never"
],
"computed-property-spacing": "error",
// "keyword-spacing": ["error", {
// "overrides": {
// "if": { "after": false },
Expand All @@ -44,13 +67,24 @@
// "catch": { "after": false }
// }
// }],
"no-multiple-empty-lines": [ "error", { "max": 1 } ],
"no-whitespace-before-property": "error",
"no-multiple-empty-lines": [
"error",
{
"max": 1
}
],
"no-whitespace-before-property": "error",
// sub group: semicolons
"semi": ["error", "always"], "semi": "error",
"no-extra-semi": ["error"],

"@typescript-eslint/member-delimiter-style": ["error",
"semi": [
"error",
"always"
],
"semi": "error",
"no-extra-semi": [
"error"
],
"@typescript-eslint/member-delimiter-style": [
"error",
{
"multiline": {
"delimiter": "comma",
Expand All @@ -71,11 +105,15 @@
}
],
"no-case-declarations": "off",
"quotes": ["error", "double", { "avoidEscape": true }],


"quotes": [
"error",
"double",
{
"avoidEscape": true
}
],
"no-useless-escape": "off",
// group: add in future
// group: add in future
"@typescript-eslint/no-var-requires": "off", // TODO add ignores
"no-unexpected-multiline": "off",
"no-constant-condition": "off",
Expand All @@ -88,8 +126,8 @@
"no-prototype-builtins": "off",
"prefer-spread": "off",
//sub group: var definition:
"no-var": "off",
"prefer-const": "off",
"no-var": "off",
"prefer-const": "off",
"@typescript-eslint/no-use-before-define": "off",
"no-unsafe-finally": "off",
//"curly": [ "error", "multi-line", "consistent" ],
Expand All @@ -104,16 +142,15 @@
"@typescript-eslint/consistent-type-assertions": "off",
"@typescript-eslint/no-inferrable-types": "off",
// group: usless rules
"no-empty": "off",
"no-empty": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/ban-types": "off",
// group: ok
//"@typescript-eslint/consistent-type-assertions": [ "error", { "assertionStyle": "angle-bracket" }],

"linebreak-style": [
"off",
"windows"
]
}
}
}
12 changes: 12 additions & 0 deletions eslint-surveyjs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
rules: {
"no-test-only": context =>
({
MemberExpression: function (node) {
if (node.object.name === "test" && node.property.name === "only") {
context.report(node, ":( please don't push 'test.only' testcafe statement it will disable all other tests:(");
}
}
}),
}
};
5 changes: 5 additions & 0 deletions eslint-surveyjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "eslint-plugin-surveyjs",
"version": "1.0.0",
"main": "index.js"
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"testcafe:file": "lerna run testcafe:file",
"dev": "concurrently \"npm run dev --prefix ../survey-library\" \"http-server -p 7777 --silent\" \"npm run watch:dev --prefix packages/survey-creator-core\" \"npm run watch:prod --prefix packages/survey-creator-core\" \"npm run watch:dev --prefix packages/survey-creator-knockout\" \"npm run watch:prod --prefix packages/survey-creator-knockout\" \"npm run watch:dev --prefix packages/survey-creator-react\" \"npm run watch:prod --prefix packages/survey-creator-react\" ",
"testcafe:dev": "testcafe chrome ./testCafe/designer/drag-drop.js --reporter minimal --selector-timeout 1500",
"lint": "eslint ./packages --quiet",
"lint": "eslint ./packages --quiet && eslint ./testCafe --quiet && eslint ./visualRegressionTests --quiet",
"pre-push-check": "npm run lint && npm run test",
"prepare": "husky install"
},
Expand All @@ -30,10 +30,11 @@
"eslint": "^7.32.0",
"eslint-cli": "^1.1.1",
"eslint-plugin-react": "^7.25.1",
"eslint-plugin-surveyjs": "file:eslint-surveyjs",
"husky": "^7.0.4",
"lerna": "^3.22.1",
"testcafe": "^1.16.0",
"testcafe-reporter-dashboard": "^0.2.4-rc.1",
"typescript": "4.4.4"
}
}
}

0 comments on commit 8e88024

Please sign in to comment.