I have a little problem with ESLint and Typescript, especially on semicolons, after declaring my interfaces. In addition I use VSCode as an editor and automatic formatting when saving.
Here is my configuration file .eslintrc.json:
{
// "parser": "babel-eslint",
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "babel", "standard"],
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module"
},
"env": {
"es6": true,
"browser": true,
"amd": true,
"node": true,
"jest": true
},
"globals": {},
// "extends": ["eslint:recommended"],
"extends": ["plugin:@typescript-eslint/recommended"],
"rules": {
"array-bracket-spacing": ["error", "never", {}],
"brace-style": "error",
"camelcase": ["error", { "properties": "never" }],
"comma-dangle": [
"error",
{
"arrays": "never",
"objects": "never",
"imports": "never",
"exports": "never",
"functions": "never"
}
],
"comma-spacing": ["error", { "before": false, "after": true }],
"comma-style": ["error", "last"],
"complexity": ["warn", 7],
"computed-property-spacing": ["error", "never"],
"curly": ["error", "all"],
"dot-notation": ["error", { "allowPattern": "^[a-z]+(_[a-z]+)+$" }],
"eol-last": "error",
"eqeqeq": ["error", "always"],
"for-direction": "off",
"func-call-spacing": ["error", "never"],
"indent": [
"error",
2,
{
"ArrayExpression": "first",
"CallExpression": { "arguments": "first" },
"flatTernaryExpressions": false,
"MemberExpression": 1,
"ObjectExpression": "first",
"outerIIFEBody": 0,
"SwitchCase": 1,
"VariableDeclarator": { "var": 2, "let": 2, "const": 3 }
}
],
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
"keyword-spacing": ["error"],
"linebreak-style": ["error", "unix"],
"max-depth": ["error", 3],
"multiline-comment-style": ["error", "starred-block"],
"no-caller": "error",
"no-cond-assign": ["error", "except-parens"],
"no-console": ["error", { "allow": ["warn", "error"] }],
"no-empty": "error",
"no-loop-func": "error",
"no-mixed-spaces-and-tabs": "error",
"no-multiple-empty-lines": ["error", { "max": 1 }],
"no-multi-str": "error",
"no-new": "error",
"no-self-assign": ["error", { "props": false }],
"no-sequences": "error",
"no-trailing-spaces": "error",
"no-undef": "error",
"no-unreachable": "error",
"no-unsafe-negation": "error",
"no-unused-expressions": ["error", { "allowShortCircuit": true }],
//"no-unused-vars": "error",
"no-unused-vars": "warn",
"no-with": "error",
"object-curly-spacing": ["error", "always"],
"one-var": [
"error",
{ "var": "always", "let": "consecutive", "const": "never" }
],
"one-var-declaration-per-line": ["error", "initializations"],
"operator-linebreak": ["error", "after"],
"quotes": ["error", "single"],
"semi": ["error", "always"],
"semi-spacing": ["error", { "before": false, "after": true }],
"semi-style": ["error", "last"],
"space-before-blocks": ["error", "always"],
"space-before-function-paren": ["error", "never"],
"space-in-parens": ["error", "never"],
"space-infix-ops": "error",
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
"wrap-iife": ["error", "inside", { "functionPrototypeMethods": true }]
}
}
Here is the content of my Typescript file which worries me:
export default interface ComponentProperties {
id: string;
context?: string;
}
Right after my end bracket, eslint says to me: "Missing semicolon". Okay, I add my semicolon, but VSCode add several semicolons to me ... and it always tells me that I am missing a semicolon.
export default interface ComponentProperties {
id: string;
context?: string;
};;;;;;;;;;;
Anyone have an idea? thank you so much
Well it seems that it comes from the "export default" instruction. ESLint cannot manage the default and interface properly. I did a simple export and it works. Well, after that I don't have the possibility of making an "export default", but by analyzing my code more, I don't necessarily need it.