Skip to content

Commit

Permalink
add lint
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaLarina committed Nov 8, 2023
1 parent eb72223 commit 7695f32
Show file tree
Hide file tree
Showing 45 changed files with 1,284 additions and 1,105 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
playwright
eslint-surveyjs
159 changes: 159 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"surveyjs"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"globals": {
"document": true,
"foo": true,
"window": true,
"console": true
},
"rules": {
"surveyjs/no-test-only": 2,
"surveyjs/no-test-debug": 2,
"indent": [
"error", 2,
{
"SwitchCase": 1,
"MemberExpression": 1,
"CallExpression": {
"arguments": 1
}
}
],
"no-trailing-spaces": [
"error",
{
"ignoreComments": true
}
],
"no-trailing-spaces": "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",
// "keyword-spacing": ["error", {
// "overrides": {
// "if": { "after": false },
// "for": { "after": false },
// "while": { "after": false },
// "switch": { "after": false },
// //"this": { "after": false, "before": false },
// "new": { "before": false },
// "function": { "after": false, "before": false },
// "catch": { "after": false }
// }
// }],
"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",
{
"multiline": {
"delimiter": "comma",
"requireLast": true
},
"singleline": {
"delimiter": "comma",
"requireLast": false
},
"overrides": {
"interface": {
"multiline": {
"delimiter": "semi",
"requireLast": true
}
}
}
}
],
"no-case-declarations": "off",
"quotes": [
"error",
"single",
{
"avoidEscape": true
}
],
"no-useless-escape": "off",
// group: add in future
"@typescript-eslint/no-var-requires": "off", // TODO add ignores
"no-unexpected-multiline": "off",
"no-constant-condition": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/class-name-casing": "off",
"@typescript-eslint/camelcase": "off",
"no-extra-boolean-cast": "off",
//sub group: js native functions
"no-prototype-builtins": "off",
"prefer-spread": "off",
//sub group: var definition:
"no-var": "off",
"prefer-const": "off",
"@typescript-eslint/no-use-before-define": "off",
"no-unsafe-finally": "off",
//"curly": [ "error", "multi-line", "consistent" ],
//"eqeqeq": ["error", "allow-null"],
"@typescript-eslint/no-unused-vars": "off",
// group: add in very far future
//"no-eval": "error",
//"no-extend-native": "error",
"@typescript-eslint/interface-name-prefix": "off",
"prefer-rest-params": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/consistent-type-assertions": "off",
"@typescript-eslint/no-inferrable-types": "off",
// group: usless rules
"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"
]
}
}
29 changes: 29 additions & 0 deletions eslint-surveyjs/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const testOnlyMessage = " :( please don't forget to remove 'test.only' testcafe statement it will disable all other tests :( ";
const debugMessage = " :( please don't forget to remove 'debug()' :( ";

module.exports = {
rules: {
"no-test-only": context =>
({
MemberExpression: function (node) {
if (node.object.name === "test" && node.property.name === "only") {
context.report(node, testOnlyMessage);
} else if (node.object.type === "CallExpression" && node.property.name === "only" ){
context.report(node, testOnlyMessage);
} else if (node.object.name === "QUnit" && node.property.name === "only" ){
context.report(node, testOnlyMessage);
}
}
}),
"no-test-debug": context =>
({
MemberExpression: function (node) {
if (node.object.name === "t" && node.property.name === "debug") {
context.report(node, debugMessage);
} else if (node.object.type === "CallExpression" && node.property.name === "debug" ){
context.report(node, debugMessage);
}
}
}),
}
};
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"
}
Loading

0 comments on commit 7695f32

Please sign in to comment.