Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[internal] Lint typescript, json, new eslint rules #4449

Merged
merged 26 commits into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
458aede
temp 07/01/19 [skip ci] main lint files
kuceb Jul 1, 2019
6cc6bfc
use lint-staged scripts
kuceb Jul 1, 2019
4cf9408
fix all auto-fixable eslint errors
kuceb Jul 1, 2019
a9c4104
manually fix lint issues in files
kuceb Jul 1, 2019
e0d7df7
temp 07/01/19 [skip ci]
kuceb Jul 1, 2019
250f97f
bump eslint plugin versions, update circle.yml
kuceb Jul 2, 2019
fed0625
[lint fix] remaining js files
kuceb Jul 2, 2019
47b6b39
update vscode/settings.json
kuceb Jul 2, 2019
0dd0e69
add back stop-only
kuceb Jul 2, 2019
810ff95
use stop-only for linting .onlys
kuceb Jul 2, 2019
ce4d05f
Merge remote-tracking branch 'origin/develop' into lint-typescript
kuceb Jul 2, 2019
2371e37
fix verify_spec, build_spec
kuceb Jul 2, 2019
5c8d7b4
update json plugin
kuceb Jul 2, 2019
ea65c9a
Merge remote-tracking branch 'origin/develop' into lint-typescript
kuceb Jul 3, 2019
b58f255
relint & apply corrections
kuceb Jul 3, 2019
d259886
fix appveyor.yml not cleansing env vars (very bad)
kuceb Jul 3, 2019
eaade53
dont echo commit message in appveyor script
kuceb Jul 3, 2019
692f3ce
retry build &
kuceb Jul 3, 2019
6ecc644
Merge remote-tracking branch 'origin/develop' into lint-typescript
kuceb Jul 9, 2019
45b1c2e
re-add & upgrade lint-staged
kuceb Jul 9, 2019
283b25c
update contributing docs
kuceb Jul 9, 2019
d532e99
only let stop-only catch staged changes
kuceb Jul 9, 2019
b2bafb5
Merge remote-tracking branch 'origin/develop' into lint-typescript
kuceb Jul 9, 2019
b17c881
Merge remote-tracking branch 'origin/develop' into lint-typescript
kuceb Jul 10, 2019
691e992
Merge remote-tracking branch 'origin/develop' into lint-typescript
kuceb Jul 12, 2019
220f5e8
Merge remote-tracking branch 'origin/develop' into lint-typescript
kuceb Jul 12, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
__snapshots__
# unignore hidden files
!.*

**/__snapshots__
**/build
**/cypress/fixtures
**/dist
**/dist-test
**/node_modules
**/support/fixtures
**/test/fixtures
**/vendor

# cli/types is linted by tslint/dtslint
cli/types
# packages/example is not linted (think about changing this)
packages/example

packages/extension/test/helpers/background.js
packages/server/lib/scaffold/plugins/index.js
packages/server/lib/scaffold/support/index.js
packages/server/lib/scaffold/support/commands.js
packages/server/test/fixtures
packages/example/cypress

packages/launcher/lib/**/*.js

**/package-lock.json
**/tsconfig.json
**/.vscode
73 changes: 5 additions & 68 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,72 +1,9 @@
{
"plugins": [
"@cypress/dev"
],
"extends": [
"plugin:cypress-dev/general"
"plugin:@cypress/dev/general"
],
"rules": {
"no-multiple-empty-lines": ["error", { "max": 1 } ],
"no-else-return": [ "error", { "allowElseIf": false } ],
"brace-style": ["error", "1tbs", { "allowSingleLine": false }],
"no-unneeded-ternary": ["error"],
"array-bracket-newline": ["error", "consistent"],
"arrow-body-style": ["error", "always"],
"padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "*",
"next": "return"
},
{
"blankLine": "always",
"prev": [
"const",
"let",
"var",
"if",
"while",
"export",
"cjs-export",
"import",
"cjs-import"
],
"next": "*"
},
{
"blankLine": "any",
"prev": [
"const",
"let",
"var",
"import",
"cjs-import"
],
"next": [
"const",
"let",
"var",
"import",
"cjs-import"
]
}
]
},
"env": {
"es6": true,
"node": true
},
"parserOptions": {
"ecmaFeatures": {
"legacyDecorators": true
}
},
"overrides": [
{
"files": [
"**/*.jsx"
],
"rules": {
"arrow-body-style": "off"
}
}
]
"rules": {}
}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ _test-output
cypress.zip
tmp/
.nyc_output
.vscode/settings.json

# from extension
Cached Theme.pak
Expand Down
5 changes: 4 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
"compounds": [
{
"name": "dev-debug w/ electron",
"configurations": ["dev-debug", "electron"]
"configurations": [
"dev-debug",
"electron"
]
}
]
}
28 changes: 28 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"eslint.validate": [
{
"language": "javascript",
"autoFix": true
},
{
"language": "javascriptreact",
"autoFix": true
},
{
"language": "typescript",
"autoFix": true
},
{
"language": "typescriptreact",
"autoFix": true
},
{
"language": "json",
"autoFix": true
},
{
"language": "coffeescript",
"autoFix": false
},
],
}
2 changes: 0 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
Expand Down
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--ignore-engines true
9 changes: 5 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,16 @@ DEBUG=cypress:launcher
### Coding Style

We use [eslint](https://eslint.org/) to lint all JavaScript code and follow rules specified in
[eslint-plugin-cypress-dev](https://github.com/cypress-io/eslint-plugin-cypress-dev) plugin.
[@cypress/eslint-plugin-dev](https://github.com/cypress-io/cypress-eslint-plugin-dev) plugin.

When you edit files, you can quickly fix all changed files before committing using
When you edit files, you can quickly fix all changed files before you commit using

```bash
npm run lint-changed
npm run lint-changed-fix
```

When committing files, we run Git pre-commit hook to fix the staged JS files. See the `precommit-lint` script in [package.json](package.json). This might change JS files and you would need to commit the changes again.
When committing files, we run a Git pre-commit hook to lint the staged JS files. See the `lint-staged` script in [package.json](package.json).
If this command fails, you may need to run `npm run lint-changed-fix` and commit those changes.

### Tests

Expand Down
8 changes: 4 additions & 4 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ jobs:
steps:
- attach_workspace:
at: ~/
- run: npm run lint
- run: npm run all lint
## this will catch .only's in js/coffee as well
- run: npm run lint-all

unit-tests:
<<: *defaults
Expand Down Expand Up @@ -237,7 +237,7 @@ jobs:
- store_test_results:
path: /tmp/cypress

lint-typescript:
lint-types:
<<: *defaults
parallelism: 1
steps:
Expand Down Expand Up @@ -717,7 +717,7 @@ linux-workflow: &linux-workflow
name: Linux lint
requires:
- build
- lint-typescript:
- lint-types:
requires:
- build
# unit, integration and e2e tests
Expand Down
10 changes: 5 additions & 5 deletions cli/__snapshots__/build_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ exports['package.json build outputs expected properties 1'] = {
"url": "https://github.com/cypress-io/cypress.git"
},
"keywords": [
"automation",
"browser",
"cypress",
"cypress.io",
"automation",
"end-to-end",
"e2e",
"end-to-end",
"integration",
"mocks",
"test",
"testing",
"runner",
"spies",
"stubs"
"stubs",
"test",
"testing"
],
"types": "types",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions cli/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const spaceDelimitedSpecsMsg = (files) => {
If you are trying to pass multiple spec filenames, separate them by commas instead:
cypress run --spec spec1,spec2,spec3
`)

logger.log()
}

Expand Down Expand Up @@ -73,8 +74,7 @@ const parseOpts = (opts) => {
'project', 'spec', 'reporter', 'reporterOptions', 'path', 'destination',
'port', 'env', 'cypressVersion', 'config', 'record', 'key',
'browser', 'detached', 'headed', 'global', 'dev', 'force', 'exit',
'cachePath', 'cacheList', 'cacheClear', 'parallel', 'group', 'ciBuildId'
)
'cachePath', 'cacheList', 'cacheClear', 'parallel', 'group', 'ciBuildId')

if (opts.exit) {
opts = _.omit(opts, 'exit')
Expand Down
6 changes: 4 additions & 2 deletions cli/lib/tasks/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,11 @@ const downloadFromUrl = ({ url, downloadDestination, progress }) => {
})
}

const start = ({ version, downloadDestination, progress }) => {
const start = (opts) => {
let { version, downloadDestination, progress } = opts

if (!downloadDestination) {
la(is.unemptyString(downloadDestination), 'missing download dir', arguments)
la(is.unemptyString(downloadDestination), 'missing download dir', opts)
}

if (!progress) {
Expand Down
10 changes: 8 additions & 2 deletions cli/lib/tasks/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ const start = (options = {}) => {
debug('environment variable CYPRESS_INSTALL_BINARY = 0, skipping install')
logger.log(
stripIndent`
${chalk.yellow('Note:')} Skipping binary installation: Environment variable CYPRESS_INSTALL_BINARY = 0.`)
${chalk.yellow('Note:')} Skipping binary installation: Environment variable CYPRESS_INSTALL_BINARY = 0.`
)

logger.log()

return Promise.resolve()
Expand All @@ -184,7 +186,9 @@ const start = (options = {}) => {
${chalk.yellow('Note:')} Overriding Cypress cache directory to: ${chalk.cyan(envCache)}

Previous installs of Cypress may not be found.
`)
`
)

logger.log()
}

Expand Down Expand Up @@ -217,6 +221,7 @@ const start = (options = {}) => {
logger.log(stripIndent`
Cypress ${chalk.green(binaryVersion)} is installed in ${chalk.cyan(installDir)}
`)

logger.log()

if (options.force) {
Expand Down Expand Up @@ -254,6 +259,7 @@ const start = (options = {}) => {
These versions may not work properly together.
`)
)

logger.log()
}

Expand Down
3 changes: 2 additions & 1 deletion cli/lib/tasks/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ const writeBinaryVerifiedAsync = (verified, binaryDir) => {
return fs.outputJsonAsync(
getBinaryStatePath(binaryDir),
_.extend(contents, { verified }),
{ spaces: 2 })
{ spaces: 2 }
)
})
}

Expand Down
1 change: 1 addition & 0 deletions cli/lib/tasks/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ const start = (options = {}) => {

This overrides the default Cypress binary path used.
`)

logger.log()

return util.isExecutableAsync(envBinaryPath)
Expand Down
1 change: 1 addition & 0 deletions cli/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const logBrokenGtkDisplayWarning = () => {

Cypress will attempt to fix the problem and rerun.
`)

logger.warn()
}

Expand Down
Loading