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

Commit

Permalink
Merge pull request #329 from votingworks/eslint-all-the-things
Browse files Browse the repository at this point in the history
feat: Deprecate tslint and eslint all the things.
  • Loading branch information
beausmith authored May 11, 2019
2 parents b3b33c6 + 2ba074a commit 51d5e3e
Show file tree
Hide file tree
Showing 54 changed files with 1,335 additions and 556 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/build
/cypress/plugins
/cypress/integration/examples
30 changes: 0 additions & 30 deletions .eslintrc

This file was deleted.

86 changes: 86 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
const jsExtensions = ['.js', '.jsx']
const tsExtensions = ['.ts', '.tsx']
const allExtensions = jsExtensions.concat(tsExtensions)

module.exports = {
env: {
browser: true,
node: true,
es6: true,
'jest/globals': true,
'cypress/globals': true,
},
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'airbnb',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'eslint:recommended',
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
'plugin:jsx-a11y/recommended',
'prettier/react', // Overrides some of the rules in 'airbnb' to have more relaxed formatting in react.
'plugin:cypress/recommended',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
// fetch: true, // required if using via 'jest-fetch-mock'
fetchMock: true, // required if using via 'jest-fetch-mock'
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
project: './tsconfig.json',
sourceType: 'module',
},
plugins: [
'@typescript-eslint',
'jest',
'no-null',
'react',
'cypress',
'jsx-a11y',
],
settings: {
react: {
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
},
'import/extensions': allExtensions,
'import/parsers': {
'@typescript-eslint/parser': tsExtensions,
},
'import/resolver': {
node: {
extensions: allExtensions,
},
},
},
rules: {
'@typescript-eslint/explicit-function-return-type': 'off', // Want to use it, but it requires return types for all built-in React lifecycle methods.
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-null-keyword': 'on',
camelcase: 'error',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: true,
},
],
'no-null/no-null': 2, // TypeScript with strictNullChecks
'react/destructuring-assignment': 'off',
'react/jsx-boolean-value': [2, 'never'],
'react/jsx-filename-extension': [
1,
{
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
],
strict: 0,
},
}
14 changes: 0 additions & 14 deletions .lintstagedrc

This file was deleted.

6 changes: 0 additions & 6 deletions .prettierrc

This file was deleted.

6 changes: 6 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
proseWrap: 'always',
semi: false,
singleQuote: true,
trailingComma: 'es5',
}
11 changes: 11 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
processors: ['stylelint-processor-styled-components'],
extends: [
'stylelint-config-palantir',
'stylelint-config-prettier',
'stylelint-config-styled-components',
],
rules: {
'selector-max-id': 1,
},
}
33 changes: 29 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
{
"editor.formatOnSave": true,
"editor.tabSize": 2,
"files.autoSave": "onFocusChange",
"eslint.packageManager": "yarn",
"prettier.eslintIntegration": true,
"prettier.tslintIntegration": true
"eslint.autoFixOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
{
"language": "typescript",
"autoFix": true
},
{
"language": "typescriptreact",
"autoFix": true
}
],
"editor.formatOnSave": true,
"[javascript]": {
"editor.formatOnSave": false
},
"[javascriptreact]": {
"editor.formatOnSave": false
},
"[typescript]": {
"editor.formatOnSave": false
},
"[typescriptreact]": {
"editor.formatOnSave": false
},
"css.validate": false,
"less.validate": false,
"scss.validate": false
}
51 changes: 19 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
# VotingWorks Ballot Marking Device

The BMD (Ballot Marking Device) app will be used in the following ways:

- An election offical can:
- [x] configure the BMD app with an election file which supports:
- [ ] single seat contests.
- [ ] multiple seat contest.
- [ ] stack rank contest.
- [ ] yes/no measures and propositions.
- [ ] specify location-based ballot content.
- and more TBD…
- A voter can:
- [ ] load their ballot using a code provided by a poll worker.
- [x] cast a vote for each contest/prop/measure of their ballot.
- [x] review votes and print offical paper ballot.

## Public Demo
## Live Demo

The `master` branch of this repo is auto-deployed to:

Expand Down Expand Up @@ -91,23 +76,23 @@ help you contribute.
1. Add features, fix bugs, etc. and then use `git` to commit your changes in
logical commits.

There is a pre-commit hook which will run linting and code formatting
scripts. You can run these manually with these three commands which are found
in the `package.json` scripts:
There is a pre-commit hook (see `lint-staged` in package.json) which will run
linting and code formatting scripts. You can run these manually with these
commands which are found in the `package.json` scripts:

```
yarn eslint:base
tslint:base
yarn prettier:write
yarn lint
yarn format
```

**Using Visual Studio Code?** Autorun linting and code formatting by
installing/enabling the following plugins (which will pick up their
installing/enabling/disabling the following plugins (which will pick up the
respective config files in this project):

- `TSLint` for TypeScript linting
- `ESLint` for (ECMAScript) JavaScript linting
- `Prettier - Code formatter` for code formatting
- disable `TSLint` as ESLint handles this functionality
- install/enable `ESLint` for (ECMAScript) JavaScript linting
- install/enable `stylelint` for modern CSS linting
- install/enable `Prettier - Code formatter` for code formatting

1. Check for test coverage. When you push your branch to github, CircleCI will
run all the tests and check for test coverage. To check this yourself, run:
Expand Down Expand Up @@ -140,9 +125,11 @@ See `package.json` for all available scripts.
This project was bootstrapped with
[Create React App](https://github.com/facebook/create-react-app) for TypeScript.
It uses [Styled Components](https://www.styled-components.com/docs/) for styles
(and some `css` files too). [ESLint](https://eslint.org/),
[TSLint](https://palantir.github.io/tslint/), and
[Prettier](https://prettier.io/) are used to maintain clean code.
[Jest](https://jestjs.io/), [dom-testing-library](https://testing-library.com)
and [react-testing-library](https://github.com/kentcdodds/react-testing-library)
are used to test components and end-to-end user flows.
(and some `css` files too). [ESLint](https://eslint.org/) is configured to lint
Javascript and TypeScript files, and format code using
[Prettier](https://prettier.io/). [stylelint](https://stylelint.io/) is used to
lint modern css. [Jest](https://jestjs.io/),
[dom-testing-library](https://testing-library.com),
[react-testing-library](https://github.com/kentcdodds/react-testing-library),
and [Cypress](https://www.cypress.io/) are used to test components and
end-to-end user flows.
45 changes: 31 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,33 @@
"pretest:e2e:ci": "yarn build",
"test:e2e:ci": "start-server-and-test start http://localhost:3000 cypress:run",
"test:e2e:watch": "start-server-and-test start http://localhost:3000 cypress:open",
"eslint:base": "eslint 'src/**/*.+(js|jsx)'",
"prettier:base": "prettier '**/*.+(js|jsx|json|yml|yaml|css|less|scss|ts|tsx|md|graphql|mdx)'",
"prettier:check": "yarn prettier:base --list-different",
"prettier:write": "yarn prettier:base --write",
"tslint:base": "tslint -c tslint.json 'src/**/*.+(ts,tsx)'"
"lint": "tsc --noEmit && eslint '*/**/*.{js,jsx,ts,tsx}' --quiet --fix && stylelint --fix",
"format": "prettier '**/*.+(css|graphql|json|less|md|mdx|sass|scss|yaml|yml)' --write"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
"pre-commit": "tsc && lint-staged"
}
},
"lint-staged": {
"linters": {
"*.+(js|jsx|ts|tsx)": [
"eslint --quiet --fix",
"git add"
],
"*.css": [
"stylelint --fix",
"git add"
],
"*.+(css|graphql|json|less|md|mdx|sass|scss|yaml|yml)": [
"prettier --write",
"git add"
]
}
},
"eslintConfig": {
"extends": "react-app"
},
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
Expand All @@ -44,9 +60,6 @@
}
}
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
Expand All @@ -72,6 +85,7 @@
"@types/react-modal": "^3.8.2",
"@types/react-router-dom": "^4.3.3",
"@types/styled-components": "^4.1.14",
"history": "^4.9.0",
"lodash.camelcase": "^4.3.0",
"mousetrap": "^1.6.3",
"normalize.css": "^8.0.1",
Expand All @@ -86,11 +100,11 @@
"react-scripts": "3.0.1",
"react-simple-keyboard": "^1.22.0",
"styled-components": "^4.2.0",
"tslint-react-hooks": "^2.1.0",
"typescript": "3.4.5"
},
"devDependencies": {
"babel-eslint": "^10.0.1",
"@typescript-eslint/eslint-plugin": "^1.7.0",
"@typescript-eslint/parser": "^1.7.0",
"cypress": "^3.2.0",
"cypress-testing-library": "^3.0.1",
"eslint": "^5.16.0",
Expand All @@ -100,6 +114,7 @@
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-jest": "^22.5.1",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-react": "^7.13.0",
"husky": "^2.2.0",
Expand All @@ -110,8 +125,10 @@
"prettier": "^1.17.0",
"react-testing-library": "7.0.0",
"start-server-and-test": "^1.9.0",
"tslint": "^5.16.0",
"tslint-config-prettier": "^1.18.0",
"tslint-react": "^4.0.0"
"stylelint": "^10.0.1",
"stylelint-config-palantir": "^4.0.0",
"stylelint-config-prettier": "^5.1.0",
"stylelint-config-styled-components": "^0.1.1",
"stylelint-processor-styled-components": "^1.6.0"
}
}
Loading

0 comments on commit 51d5e3e

Please sign in to comment.