Skip to content

Commit

Permalink
[internal] Lint typescript, json, new eslint rules (#4449)
Browse files Browse the repository at this point in the history
* temp 07/01/19 [skip ci] main lint files

* use lint-staged scripts

* fix all auto-fixable eslint errors

* manually fix lint issues in files

* temp 07/01/19 [skip ci]

* bump eslint plugin versions, update circle.yml

* [lint fix] remaining js files

* update vscode/settings.json

* add back stop-only

* use stop-only for linting .onlys

* fix verify_spec, build_spec

* update json plugin

* relint & apply corrections

* fix appveyor.yml not cleansing env vars (very bad)

* dont echo commit message in appveyor script

* retry build &

* re-add & upgrade lint-staged

* update contributing docs

* only let stop-only catch staged changes
  • Loading branch information
kuceb authored and brian-mann committed Jul 12, 2019
1 parent f6f41c6 commit fbd5236
Show file tree
Hide file tree
Showing 166 changed files with 1,249 additions and 868 deletions.
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
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
},
],
}
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 @@ -354,15 +354,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` project](https://github.com/okonet/lint-staged).
If this command fails, you may need to run `npm run lint-changed-fix` and commit those changes.

### Tests

Expand Down
4 changes: 1 addition & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,9 @@ install:
# Post-install test scripts.
test_script:
# Output useful info for debugging.
# beware of echo-ing environment variables that may have batch syntax (e.g. commit messages)
- node --version
- npm --version
- echo Commit message
- echo %APPVEYOR_REPO_COMMIT_MESSAGE%
- echo body of commit message, if any
- 7z
- cd packages/launcher && node index.js && cd ../..
# make sure mocha runs
Expand Down
10 changes: 5 additions & 5 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ jobs:
paths:
- packages/ts/node_modules

- run: npm run stop-only
- run: npm run stop-only-all
## now go build all of subpackages
- run: npm run prebuild -- --serial
- run: npm run build -- --serial
Expand All @@ -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 @@ -723,7 +723,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
10 changes: 7 additions & 3 deletions cli/lib/tasks/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ const verifyDownloadedFile = (filename, expectedSize, expectedChecksum) => {
debug(text)

throw new Error(text)
})
}
)
}

if (expectedChecksum) {
Expand Down Expand Up @@ -211,6 +212,7 @@ const downloadFromUrl = ({ url, downloadDestination, progress }) => {
// see https://github.com/cypress-io/cypress/pull/4092
expectedSize = response.headers['x-amz-meta-size'] ||
response.headers['content-length']

expectedChecksum = response.headers['x-amz-meta-checksum']

if (expectedChecksum) {
Expand Down Expand Up @@ -274,9 +276,11 @@ const downloadFromUrl = ({ url, downloadDestination, progress }) => {
* @param [string] version Could be "3.3.0" or full URL
* @param [string] downloadDestination Local filename to save as
*/
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 @@ -164,7 +164,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 @@ -187,7 +189,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 @@ -220,6 +224,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 @@ -257,6 +262,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 @@ -108,6 +108,7 @@ const logBrokenGtkDisplayWarning = () => {
Cypress will attempt to fix the problem and rerun.
`)

logger.warn()
}

Expand Down
Loading

2 comments on commit fbd5236

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on fbd5236 Jul 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.4.1/win32-ia32/appveyor-develop-fbd523615e38fd3faff74d98379e22b6d819ab56-25943210/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.4.1/win32-ia32/appveyor-develop-fbd523615e38fd3faff74d98379e22b6d819ab56-25943210/cypress.zip

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on fbd5236 Jul 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

You can install this pre-release platform-specific build using instructions at https://on.cypress.io/installing-cypress#Install-pre-release-version.

You will need to use custom CYPRESS_INSTALL_BINARY url and install Cypress using an url instead of the version.

set CYPRESS_INSTALL_BINARY=https://cdn.cypress.io/beta/binary/3.4.1/win32-x64/appveyor-develop-fbd523615e38fd3faff74d98379e22b6d819ab56-25943210/cypress.zip
npm install https://cdn.cypress.io/beta/binary/3.4.1/win32-x64/appveyor-develop-fbd523615e38fd3faff74d98379e22b6d819ab56-25943210/cypress.zip

Please sign in to comment.