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

chore: improve linting #25235

Merged
merged 31 commits into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e683cf8
data-context: remove custom eslintrc and unused vars
flotwig Dec 20, 2022
ca10890
config: remove custom eslintrc
flotwig Dec 20, 2022
35ac2e0
driver: inherit eslint from root
flotwig Dec 20, 2022
0921d79
app, frontend-shared, launchpad: clean up eslint
flotwig Dec 20, 2022
4eddcef
reporter: deduplicate eslintrcs
flotwig Dec 20, 2022
b6326f4
driver: remove unused dom eslint
flotwig Dec 20, 2022
f7abbd6
server: remove eslintrc
flotwig Dec 20, 2022
d4fd6df
root: disable no-console in scripts, tests, etc.
flotwig Dec 20, 2022
33243f2
remove no-op "extends" usages
flotwig Dec 20, 2022
453de59
remove unused jscodeshift script, dep
flotwig Dec 20, 2022
563617f
delete redundant script eslintrcs
flotwig Dec 20, 2022
d7d9ee7
linting, round 30?
flotwig Dec 21, 2022
2751d09
angular: simplify eslintrc
flotwig Dec 21, 2022
bb0e134
create-cypress-tests: simplify eslintrc, remove unused vars
flotwig Dec 21, 2022
db2d2c0
xpath: add linting, simplify, fix
flotwig Dec 21, 2022
8467c4c
webpack-preprocessor: remove duplicated eslintrc
flotwig Dec 21, 2022
18e3e70
webpack-batteries-included-preprocessor: remove duplicate eslintrc
flotwig Dec 21, 2022
23de19f
vue: simplify eslintrc + fix
flotwig Dec 21, 2022
9f926df
vue2: simplify eslintrc, remove unused var
flotwig Dec 21, 2022
9688185
vite-dev-server: remove no-unused-vars, remove unused var
flotwig Dec 21, 2022
117de56
svelte: remove no-unused-vars
flotwig Dec 21, 2022
5eb2c30
react: remove no-unused-vars
flotwig Dec 21, 2022
366e04e
grep: add missing lint script, stricten eslintrc, eslint --fix
flotwig Dec 21, 2022
a387a77
eslint-plugin-dev: remove unused eslintrcs, rules
flotwig Dec 21, 2022
f4b2464
run ci
flotwig Dec 21, 2022
5f348d0
graphql: remove no-unused-vars, fix errors
flotwig Dec 21, 2022
8e3060d
svelte: remove no-unused-vars, fix errors
flotwig Dec 21, 2022
dc63c07
cy-in-cy: remove no-unused-vars
flotwig Dec 21, 2022
13dfca7
run ci
flotwig Dec 21, 2022
966347a
Revert "root: disable no-console in scripts, tests, etc."
flotwig Dec 29, 2022
9590db3
add ignores for console usage that now errors
flotwig Dec 29, 2022
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const validators = specifiedRules
)

module.exports = {
root: true,
plugins: [
'@cypress/dev',
'graphql',
Expand Down
1 change: 0 additions & 1 deletion cli/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"extends": "../.eslintrc.js",
"rules": {
"no-restricted-syntax": [
"error",
Expand Down
5 changes: 0 additions & 5 deletions cli/test/lib/exec/.eslintrc.json

This file was deleted.

11 changes: 1 addition & 10 deletions npm/angular/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,5 @@
],
"extends": [
"plugin:@cypress/dev/tests"
],
"env": {
"cypress/globals": true
},
"rules": {
"mocha/no-global-tests": "off",
"no-unused-vars": "off",
"no-console": "off",
"@typescript-eslint/no-unused-vars": "off"
}
]
}
26 changes: 2 additions & 24 deletions npm/create-cypress-tests/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,10 @@
"plugin:@cypress/dev/general",
"plugin:@cypress/dev/tests"
],
"parser": "@typescript-eslint/parser",
"env": {
"cypress/globals": true
},
"rules": {
"no-console": "off",
"mocha/no-global-tests": "off",
"@typescript-eslint/no-unused-vars": "off"
},
"overrides": [
{
"files": [
"lib/*"
],
"rules": {
"no-console": 1
}
},
{
"files": [
"**/*.json"
],
"rules": {
"quotes": "off",
"comma-dangle": "off"
}
}
]
"no-console": "off"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/// <reference path="../../../../../cli/types/mocha/index.d.ts" />

import * as path from 'path'
import { expect } from 'chai'

import * as fs from 'fs-extra'
import { insertValueInJSString, insertValuesInConfigFile } from './configFileUpdater'
const projectRoot = process.cwd()
import { insertValueInJSString } from './configFileUpdater'

// Test util - if needed outside the tests we can move it to utils
const stripIndent = (strings: any, ...args: any) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _ from 'lodash'
import { parse } from '@babel/parser'
import type { File } from '@babel/types'
import type { NodePath } from 'ast-types/lib/node-path'
Expand Down
3 changes: 1 addition & 2 deletions npm/eslint-plugin-dev/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
"extends": [
"plugin:promise/recommended",
"plugin:@cypress/dev/general"
],
"rules": {}
]
}
5 changes: 0 additions & 5 deletions npm/eslint-plugin-dev/lib/scripts/.eslintrc.json

This file was deleted.

6 changes: 0 additions & 6 deletions npm/eslint-plugin-dev/test/fixtures/.eslintrc

This file was deleted.

4 changes: 1 addition & 3 deletions npm/grep/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
},
"rules": {
"mocha/no-global-tests": "off",
"no-unused-vars": "off",
"no-console": "off",
"@typescript-eslint/no-unused-vars": "off",
"no-restricted-syntax": "off"
}
}
}
2 changes: 1 addition & 1 deletion npm/grep/cypress/e2e/nested-describe-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('grand', () => {
describe('top', { tags: '@smoke' }, () => {
describe('middle', () => {
context('bottom', { tags: ['@integration', '@fast'] }, () => {
it('runs too', () => {});
it('runs too', () => {})
})
})
})
1 change: 1 addition & 0 deletions npm/grep/cypress/e2e/omit-and-skip-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// @ts-check
describe('Page', () => {
describe('List', { tags: ['@us1'] }, () => {
// eslint-disable-next-line @cypress/dev/skip-comment
it.skip('first test', () => {})
it('second test', () => {})
it('third test', () => {})
Expand Down
1 change: 1 addition & 0 deletions npm/grep/cypress/e2e/skip-spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @cypress/dev/skip-comment */
/// <reference types="cypress" />
describe('tests that use .skip', () => {
// use a template literal
Expand Down
2 changes: 2 additions & 0 deletions npm/grep/cypress/e2e/ts-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('TypeScript spec', () => {

it('loads', () => {
const n: number = 1

cy.wrap(n).should('eq', 1)
})

Expand All @@ -24,6 +25,7 @@ describe('TypeScript spec', () => {
const p: Person = {
name: 'Joe',
}

cy.wrap(p).should('have.property', 'name', 'Joe')
})
})
3 changes: 2 additions & 1 deletion npm/grep/cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/// <reference types="cypress" />

import cypressGrep from '../../src/support'

// register the grep feature
// https://github.com/cypress-io/cypress-grep
cypressGrep()
cypressGrep()
3 changes: 2 additions & 1 deletion npm/grep/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "src/support.js",
"scripts": {
"cy:run": "node ../../scripts/cypress.js run --config specPattern='**/unit.js'",
"cy:open": "node ../../scripts/cypress.js open --e2e -b electron --config specPattern='**/unit.js'"
"cy:open": "node ../../scripts/cypress.js open --e2e -b electron --config specPattern='**/unit.js'",
"lint": "eslint . --ext .js,.ts"
},
"dependencies": {
"debug": "^4.3.2",
Expand Down
22 changes: 1 addition & 21 deletions npm/react/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"rules": {
"no-console": "off",
"mocha/no-global-tests": "off",
"@typescript-eslint/no-unused-vars": "off",
"react/jsx-filename-extension": [
"warn",
{
Expand All @@ -30,24 +29,5 @@
]
}
]
},
"overrides": [
{
"files": [
"lib/*"
],
"rules": {
"no-console": 1
}
},
{
"files": [
"**/*.json"
],
"rules": {
"quotes": "off",
"comma-dangle": "off"
}
}
]
}
}
4 changes: 1 addition & 3 deletions npm/svelte/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
},
"rules": {
"mocha/no-global-tests": "off",
"no-unused-vars": "off",
"no-console": "off",
"@typescript-eslint/no-unused-vars": "off"
"no-console": "off"
}
}
2 changes: 1 addition & 1 deletion npm/svelte/src/mount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const cleanup = () => {
// Extract the component name from the object passed to mount
const getComponentDisplayName = <T extends SvelteComponent>(Component: SvelteConstructor<T>): string => {
if (Component.name) {
const [_, match] = /Proxy\<(\w+)\>/.exec(Component.name) || []
const [, match] = /Proxy\<(\w+)\>/.exec(Component.name) || []

return match || Component.name
}
Expand Down
22 changes: 1 addition & 21 deletions npm/vite-dev-server/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"rules": {
"no-console": "off",
"mocha/no-global-tests": "off",
"@typescript-eslint/no-unused-vars": "off",
"react/jsx-filename-extension": [
"warn",
{
Expand All @@ -32,24 +31,5 @@
]
}
]
},
"overrides": [
{
"files": [
"lib/*"
],
"rules": {
"no-console": 1
}
},
{
"files": [
"**/*.json"
],
"rules": {
"quotes": "off",
"comma-dangle": "off"
}
}
]
}
}
2 changes: 1 addition & 1 deletion npm/vite-dev-server/src/devServer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import debugFn from 'debug'
import type { InlineConfig, UserConfig } from 'vite'
import type { UserConfig } from 'vite'
import { getVite, Vite } from './getVite'
import { createViteDevServerConfig } from './resolveConfig'

Expand Down
2 changes: 0 additions & 2 deletions npm/vue/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
},
"rules": {
"mocha/no-global-tests": "off",
"no-unused-vars": "off",
"no-console": "off",
"@typescript-eslint/no-unused-vars": "off",
"vue/multi-word-component-names": "off"
}
}
2 changes: 1 addition & 1 deletion npm/vue/cypress/component/tailwind/redbox.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mount, mountCallback } from '@cypress/vue'
import { mount } from '@cypress/vue'
import RedBox from './RedBox.vue'

const tailwindCdnLink = 'https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css'
Expand Down
4 changes: 1 addition & 3 deletions npm/vue2/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
},
"rules": {
"mocha/no-global-tests": "off",
"no-unused-vars": "off",
"no-console": "off",
"@typescript-eslint/no-unused-vars": "off"
"no-console": "off"
}
}
1 change: 0 additions & 1 deletion npm/vue2/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// The default for running tests in this project
// https://vue-loader.vuejs.org/guide/#manual-setup
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path')
const pkg = require('package.json')

Expand Down
11 changes: 0 additions & 11 deletions npm/webpack-batteries-included-preprocessor/.eslintrc.json

This file was deleted.

11 changes: 0 additions & 11 deletions npm/webpack-preprocessor/.eslintrc.json

This file was deleted.

5 changes: 1 addition & 4 deletions npm/xpath/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
"cypress/globals": true
},
"rules": {
"mocha/no-global-tests": "off",
"no-unused-vars": "off",
"no-console": "off",
"@typescript-eslint/no-unused-vars": "off"
"no-console": "off"
}
}
1 change: 1 addition & 0 deletions npm/xpath/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Adds XPath command to Cypress.io test runner",
"main": "src",
"scripts": {
"lint": "eslint . --ext .ts,.js",
"cy:run": "node ../../scripts/cypress.js run --e2e",
"cy:open": "node ../../scripts/cypress.js open --e2e --project ${PWD}"
},
Expand Down
5 changes: 3 additions & 2 deletions npm/xpath/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference types="cypress" />

declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not totally sure what the right thing to do here is, I made this change to fix the lint error from no-unused-vars but this doesn't look exactly right. Should E on line 14 extend Subject instead of HTMLElement? @jordanpowell88 any ideas?

Copy link
Contributor

@lmiller1990 lmiller1990 Dec 22, 2022

Choose a reason for hiding this comment

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

Doe we need Chainable to have Subject? We might be able to omit it. Should it just be

declare namespace Cypress {
  interface Chainable {
    /**
    * Get one or more DOM elements by an XPath selector.
    * **Note:** you can test XPath expressions from DevTools console using $x(...) function, for example $x('//div') to find all divs.
    * @see https://github.com/cypress-io/cypress-xpath
    * @example
    * cy.xpath(`//ul[@class="todo-list"]//li`)
    *   .should('have.length', 3)
    */
    xpath<E extends Node = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
  }
}

Copy link
Contributor

Choose a reason for hiding this comment

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

We have some examples in the docs that don't pass Subject to Chainable: https://docs.cypress.io/guides/tooling/typescript-support#Types-for-Custom-Commands

interface Chainable<Subject> {
/**
* Get one or more DOM elements by an XPath selector.
Expand All @@ -10,6 +11,6 @@ declare namespace Cypress {
* cy.xpath(`//ul[@class="todo-list"]//li`)
* .should('have.length', 3)
*/
xpath<E extends Node = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
xpath<E extends Node = HTMLElement>(selector: string, options?: Partial<Loggable & Timeoutable>): Chainable<JQuery<E>>
}
}
}
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"ensure-deps": "./scripts/ensure-dependencies.sh",
"get-next-version": "node scripts/get-next-version.js",
"postinstall": "node ./scripts/run-postInstall.js",
"jscodeshift": "jscodeshift -t ./node_modules/js-codemod/transforms/arrow-function-arguments.js",
"lint": "lerna run lint --no-bail --concurrency 2",
"lint-changed": "lint-changed",
"prepare-release-artifacts": "node ./scripts/prepare-release-artifacts.js",
Expand Down Expand Up @@ -176,9 +175,6 @@
"inquirer": "3.3.0",
"inquirer-confirm": "2.0.3",
"jest": "24.9.0",
"js-codemod": "cpojer/js-codemod",
"jscodemods": "https://github.com/cypress-io/jscodemods.git#01b546e",
"jscodeshift": "0.7.0",
Comment on lines -179 to -181
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing these 3 historical deps got rid of 249 transitive dependencies and 74 MB:

Before:

~ echo **/node_modules/* | wc -w
7371
~ du -c -B M **/node_modules/*
...
2792M   total

After:

~ echo **/node_modules/* | wc -w
7122
~ du -c -B M **/node_modules/*
...
2718M   total

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

I wonder if there's a tool we can use to detect unused dependencies and prune more?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's called depcheck: https://github.com/depcheck/depcheck I want to add this to the repo at some point for sure.

"lazy-ass": "1.6.0",
"lerna": "3.20.2",
"lint-staged": "11.1.2",
Expand Down
Loading