Skip to content

Commit

Permalink
fix: extend linting
Browse files Browse the repository at this point in the history
Mainly base our linting on `standard` and
`@typescript-eslint/recommended`.
  • Loading branch information
sQVe committed Feb 26, 2020
1 parent b5e1290 commit 039cadf
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 52 deletions.
98 changes: 46 additions & 52 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,55 @@
module.exports = {
root: true,
const defaultSettings = {
env: { es6: true, node: true },
extends: ["standard", "prettier"],
parser: "babel-eslint",
rules: {
indent: "off",
"no-unused-vars": "off",
semi: [2, "always"],
"keyword-spacing": [2, { before: true, after: true }],
"space-before-blocks": [2, "always"],
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
"no-cond-assign": 0,
"no-empty": 0,
"object-shorthand": [2, "always"],
"no-const-assign": 2,
"no-class-assign": 2,
"no-this-before-super": 2,
"no-var": 2,
"no-unreachable": 2,
"valid-typeof": 2,
"quote-props": [2, "as-needed"],
"one-var": [2, "never"],
"prefer-arrow-callback": 2,
"prefer-const": [2, { destructuring: "all" }],
"arrow-spacing": 2,
"no-inner-declarations": 0,
"require-atomic-updates": "off",
quotes: "off",
"@typescript-eslint/quotes": ["error", "double"],
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/no-object-literal-type-assertion": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/prefer-interface": "off",
"@typescript-eslint/no-non-null-assertion": "off",
},
env: {
es6: true,
browser: true,
node: true,
jest: true,
"no-unused-vars": [
"error",
{
args: "none",
ignoreRestSiblings: true,
vars: "all",
varsIgnorePattern: "^_+$",
},
],
},
};

const testSettings = {
env: { ...defaultSettings.env, jest: true },
files: ["tests/**/*.{js,jsx,mjs,ts,tsx}", "**/*.test.{js,jsx,mjs,ts,tsx}"],
rules: { ...defaultSettings.rules, "import/first": "off" },
};

const typescriptSettings = {
files: ["src/**/*.{ts,tsx}"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
// keep at the end
"plugin:prettier/recommended",
"prettier/@typescript-eslint",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 9,
sourceType: "module",
ecmaFeatures: { jsx: true },
ecmaVersion: 2020,
project: "./tsconfig.json",
warnOnUnsupportedTypeScriptVersion: false,
},
overrides: [
{
files: ["*.js"],
rules: {
"@typescript-eslint/no-var-requires": "off",
plugins: ["@typescript-eslint"],
rules: {
...defaultSettings.rules,
"@typescript-eslint/member-delimiter-style": [
"error",
{
multiline: { delimiter: "comma", requireLast: true },
singleline: { delimiter: "comma", requireLast: false },
},
},
],
],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-unused-vars": "error",
},
};

module.exports = {
...defaultSettings,
overrides: [testSettings, typescriptSettings],
};
7 changes: 7 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"target": "esnext"
},
"include": ["src/**/*", "test/**/*"]
}

0 comments on commit 039cadf

Please sign in to comment.