Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Switch from TSLint to ESLint
Browse files Browse the repository at this point in the history
  • Loading branch information
ek68794998 committed Apr 7, 2020
1 parent 9f5ef17 commit cea0fc4
Show file tree
Hide file tree
Showing 35 changed files with 1,008 additions and 286 deletions.
267 changes: 267 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
module.exports = {
"extends": [
"plugin:react/recommended"
],
"env": {
"browser": true,
"es6": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"@typescript-eslint/eslint-plugin-tslint",
"import",
"prefer-arrow",
"react"
],
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/explicit-member-accessibility": [
"error",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/indent": [
"error",
"tab",
{
"CallExpression": {
"arguments": "first"
},
"FunctionDeclaration": {
"parameters": "first"
},
"FunctionExpression": {
"parameters": "first"
},
"SwitchCase": 1
}
],
"@typescript-eslint/interface-name-prefix": "error",
"@typescript-eslint/member-delimiter-style": [
"error",
{
"multiline": {
"delimiter": "semi",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/member-ordering": "error",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-this-alias": "error",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/quotes": [
"error",
"double"
],
"@typescript-eslint/semi": [
"error",
"always"
],
"@typescript-eslint/triple-slash-reference": "error",
"@typescript-eslint/tslint/config": [
"error",
{
"rules": {
"import-spacing": true,
"jsdoc-format": true,
"naming-convention": [
true,
{
"type": "variable",
"format": "camelCase"
}
],
"no-reference-import": true,
"object-literal-sort-keys": true,
"one-line": [
true,
"check-catch",
"check-else",
"check-open-brace",
"check-whitespace"
],
"prefer-conditional-expression": true,
"typedef": [
true,
"arrow-call-signature",
"call-signature",
"member-variable-declaration",
"parameter",
"property-declaration",
"variable-declaration",
"variable-declaration-ignore-function"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-module",
"check-operator",
"check-separator",
"check-type",
"check-typecast"
]
}
}
],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unified-signatures": "error",
"arrow-body-style": "error",
"arrow-parens": [
"error",
"as-needed"
],
"camelcase": "error",
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "always-multiline"
}
],
"complexity": "off",
"constructor-super": "error",
"curly": "error",
"default-case": "error",
"dot-notation": "error",
"eol-last": "off",
"eqeqeq": [
"error",
"smart"
],
"guard-for-in": "error",
"id-blacklist": [
"error",
"any",
"Undefined",
"undefined"
],
"id-match": "error",
"import/no-extraneous-dependencies": "error",
"import/no-internal-modules": "off",
"import/order": "error",
"max-classes-per-file": [
"error",
1
],
"max-len": [
"error",
{
"code": 120,
"ignorePattern": "[`\"'];?$",
"ignoreStrings": true
}
],
"new-parens": "error",
"no-bitwise": "error",
"no-caller": "error",
"no-cond-assign": "error",
"no-console": "off",
"no-debugger": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "error",
"no-empty": "error",
"no-eval": "error",
"no-extra-bind": "error",
"no-fallthrough": "error",
"no-invalid-this": "off",
"no-multiple-empty-lines": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-redeclare": "error",
"no-return-await": "error",
"no-sequences": "error",
"no-shadow": [
"error",
{
"builtinGlobals": true,
"hoist": "all"
}
],
"no-sparse-arrays": "error",
"no-template-curly-in-string": "error",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-underscore-dangle": [
"error",
{
"allow": [
"__PRELOADED_STATE__",
"__REDUX_DEVTOOLS_EXTENSION_COMPOSE__",
],
},
],
"no-unsafe-finally": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-var": "error",
"object-shorthand": "error",
"one-var": [
"error",
"never"
],
"prefer-arrow/prefer-arrow-functions": "error",
"prefer-const": "error",
"prefer-object-spread": "error",
"quote-props": [
"error",
"consistent-as-needed"
],
"radix": "error",
"react/jsx-boolean-value": [
"error",
"always",
],
"react/jsx-curly-spacing": "error",
"react/jsx-equals-spacing": "error",
"react/jsx-key": "error",
"react/jsx-no-bind": "off",
"react/no-string-refs": "error",
"react/no-unescaped-entities": "off",
"space-before-function-paren": [
"error",
{
"anonymous": "never",
"asyncArrow": "always",
"named": "never"
}
],
"space-in-parens": [
"error",
"never"
],
"spaced-comment": "error",
"use-isnan": "error",
"valid-typeof": "off"
}
};
3 changes: 3 additions & 0 deletions .github/workflows/react-ci-yarn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install packages
run: yarn install
- name: Run linting
run: |
yarn lint:ts
- name: Run unit tests
run: |
yarn test:ci
Expand Down
47 changes: 25 additions & 22 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
{
"[json]": {
"editor.insertSpaces": true,
"editor.tabSize": 2
},
"[yml]": {
"editor.insertSpaces": true,
"editor.tabSize": 2
},
"editor.insertSpaces": false,
"editor.detectIndentation": false,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/__snapshots__/**": true,
"build/**": true,
"coverage/**": true,
"node_modules/**": true
}
}
"[json]": {
"editor.insertSpaces": true,
"editor.tabSize": 2
},
"[yml]": {
"editor.insertSpaces": true,
"editor.tabSize": 2
},
"editor.detectIndentation": false,
"editor.insertSpaces": false,
"eslint.nodePath": "./node_modules",
"eslint.options": { "configFile": "./.eslintrc.js" },
"eslint.packageManager": "yarn",
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/__snapshots__/**": true,
"build/**": true,
"coverage/**": true,
"node_modules/**": true
}
}
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"build": "razzle build",
"debug": "razzle start --inspect --inspect-port=9230",
"lint:ts": "eslint --ext=jsx,ts,tsx src",
"postinstall": "npm rebuild node-sass",
"start": "razzle start",
"start:prod": "node build/server.js",
Expand Down Expand Up @@ -47,15 +48,21 @@
"@types/serialize-javascript": "^1.5.0",
"@types/webpack-env": "^1.13.6",
"@types/yaml": "^1.2.0",
"@typescript-eslint/eslint-plugin": "^2.27.0",
"@typescript-eslint/eslint-plugin-tslint": "^2.27.0",
"@typescript-eslint/parser": "^2.27.0",
"cross-env": "^7.0.2",
"eslint": "^6.8.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-prefer-arrow": "^1.1.7",
"eslint-plugin-react": "^7.19.0",
"jest": "^25.2.3",
"razzle": "^3.0.0",
"razzle-plugin-scss": "^3.0.0",
"razzle-plugin-typescript": "^3.0.0",
"react-test-renderer": "^16.13.1",
"ts-jest": "^25.0.0",
"tslint": "^5.19.0",
"tslint-react": "^4.0.0",
"typescript": "^3.2.2"
},
"jest": {
Expand Down
7 changes: 3 additions & 4 deletions src/__tests__/TestUtils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
type ComponentGenerator = (props: {}) => string;

export const mockComponent = (componentName: string): ComponentGenerator => {
return (props: {}): string => {
export const mockComponent = (componentName: string): ComponentGenerator =>
(props: {}): string => {
const openingTag: string = `[component: ${componentName}`;
const closingTag: string = `/]`;
const closingTag: string = "/]";

const propKeys: string[] = Object.keys(props);

Expand All @@ -27,4 +27,3 @@ export const mockComponent = (componentName: string): ComponentGenerator => {

return `${openingTag} ${propsList.join(" ")} ${closingTag}`;
};
};
6 changes: 2 additions & 4 deletions src/__tests__/employer-records.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { EmployerRecord } from "../common/EmployerRecord";
const directory: string = "./public";
const subDirectory: string = "employers";

const dateToNumber = (date: string | Date | null): number => {
return new Date(date || "").getTime();
};
const dateToNumber = (date: string | Date | null): number => new Date(date || "").getTime();

const recordIds: string[] =
fs.readdirSync(`${directory}/${subDirectory}`)
Expand All @@ -24,7 +22,7 @@ describe("employer records", () => {
});

test.each(
recordIds.map((recordId: string) => [ recordId ])
recordIds.map((recordId: string) => [ recordId ]),
)("can load and parse %p (%#)", async (recordId: string) => {
const record: EmployerRecord = await loader.loadAsync(recordId);

Expand Down
Loading

0 comments on commit cea0fc4

Please sign in to comment.