Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit ea53fb6

Browse files
authored
style(eslint): enable spaced-comment, @typescript-eslint/no-unused-vars (#1261)
* fix "spaced-comment" * fix "@typescript-eslint/no-unused-vars" * fix "no-shadow" * reenable no-shadow * remove unused import
1 parent f717dbc commit ea53fb6

File tree

36 files changed

+106
-125
lines changed

36 files changed

+106
-125
lines changed

build/gulp/plugins/gulp-component-menu-behaviors.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ type BehaviorMenuItem = {
2020
}
2121

2222
const getTextFromCommentToken = (commentTokens, tokenTitle): string => {
23-
const token = commentTokens.find(token => token.title === tokenTitle)
24-
return token ? token.description : ''
23+
const resultToken = commentTokens.find(token => token.title === tokenTitle)
24+
return resultToken ? resultToken.description : ''
2525
}
2626

2727
export default () => {

build/gulp/tasks/docs.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ const { paths } = config
2525
const g = require('gulp-load-plugins')()
2626
const { colors, log } = g.util
2727

28-
const handleWatchChange = path => log(`File ${path} was changed, running tasks...`)
29-
const handleWatchUnlink = (group, path) => {
30-
log(`File ${path} was deleted, running tasks...`)
31-
remember.forget(group, path)
28+
const handleWatchChange = changedPath => log(`File ${changedPath} was changed, running tasks...`)
29+
const handleWatchUnlink = (group, changedPath) => {
30+
log(`File ${changedPath} was deleted, running tasks...`)
31+
remember.forget(group, changedPath)
3232
}
3333

3434
// ----------------------------------------
@@ -227,7 +227,7 @@ task('watch:docs', cb => {
227227
// rebuild example menus
228228
watch(examplesIndexSrc, series('build:docs:example-menu'))
229229
.on('change', handleWatchChange)
230-
.on('unlink', path => handleWatchUnlink('example-menu', path))
230+
.on('unlink', changedPath => handleWatchUnlink('example-menu', changedPath))
231231

232232
watch(examplesSrc, series('build:docs:example-sources'))
233233
.on('change', handleWatchChange)
@@ -244,7 +244,7 @@ task('watch:docs', cb => {
244244

245245
watch(behaviorSrc, series('build:docs:component-menu-behaviors'))
246246
.on('change', handleWatchChange)
247-
.on('unlink', path => handleWatchUnlink('component-menu-behaviors', path))
247+
.on('unlink', changedPath => handleWatchUnlink('component-menu-behaviors', changedPath))
248248

249249
// rebuild images
250250
watch(`${config.paths.docsSrc()}/**/*.{png,jpg,gif}`, series('build:docs:images')).on(

build/gulp/tasks/perf.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ const normalizeMeasures = (measures: ProfilerMeasureCycle[]): NormalizedMeasures
7272
{},
7373
)
7474

75-
return _.mapValues(perExampleMeasures, (measures: ProfilerMeasure[]) => ({
76-
actualTime: reduceMeasures(measures, 'actualTime'),
77-
baseTime: reduceMeasures(measures, 'baseTime'),
75+
return _.mapValues(perExampleMeasures, (profilerMeasures: ProfilerMeasure[]) => ({
76+
actualTime: reduceMeasures(profilerMeasures, 'actualTime'),
77+
baseTime: reduceMeasures(profilerMeasures, 'baseTime'),
7878
}))
7979
}
8080

build/gulp/tasks/stats.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ const semverCmp = (a, b) => {
4646
return 0
4747
}
4848

49-
function webpackAsync(config): Promise<any> {
49+
function webpackAsync(webpackConfig): Promise<any> {
5050
return new Promise((resolve, reject) => {
51-
const compiler = webpack(config)
51+
const compiler = webpack(webpackConfig)
5252
compiler.run((err, stats) => {
5353
const statsJson = stats.toJson()
5454
const { errors, warnings } = statsJson
@@ -73,14 +73,14 @@ function webpackAsync(config): Promise<any> {
7373

7474
async function compileOneByOne(allConfigs) {
7575
let assets = []
76-
for (const config of allConfigs) {
77-
log('Compiling', config.output.filename)
76+
for (const webpackConfig of allConfigs) {
77+
log('Compiling', webpackConfig.output.filename)
7878
try {
79-
const result = await webpackAsync(config)
79+
const result = await webpackAsync(webpackConfig)
8080
assets = [...assets, ...result.assets]
8181
log('Done', result.assets[0].name) // All builds should produce just single asset
8282
} catch (err) {
83-
log('Error', config.output.filename)
83+
log('Error', webpackConfig.output.filename)
8484
throw err
8585
}
8686
}

build/gulp/tasks/test-projects.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const log = (context: string) => (message: string) => {
2323
console.log('='.repeat(80))
2424
}
2525

26-
export const runIn = path => cmd => sh(`cd ${path} && ${cmd}`)
26+
export const runIn = targetPath => cmd => sh(`cd ${targetPath} && ${cmd}`)
2727

2828
const addResolutionPathsForStardustPackages = async (
2929
testProjectDir: string,
@@ -136,7 +136,6 @@ task('test:projects:cra-ts', async () => {
136136
const logger = log('test:projects:cra-ts')
137137
const scaffoldPath = paths.base.bind(null, 'build/gulp/tasks/test-projects/cra')
138138

139-
//////// CREATE TEST REACT APP ///////
140139
logger('STEP 1. Create test React project with TSX scripts..')
141140

142141
const testAppPath = paths.withRootAt(
@@ -146,19 +145,16 @@ task('test:projects:cra-ts', async () => {
146145
const runInTestApp = runIn(testAppPath())
147146
logger(`Test React project is successfully created: ${testAppPath()}`)
148147

149-
//////// ADD STARDUST AS A DEPENDENCY ///////
150148
logger('STEP 2. Add Stardust dependency to test project..')
151149

152150
const packedPackages = await packStardustPackages(logger)
153151
await addResolutionPathsForStardustPackages(testAppPath(), packedPackages)
154152
await runInTestApp(`yarn add ${packedPackages['@stardust-ui/react']}`)
155153
logger(`✔️Stardust UI packages were added to dependencies`)
156154

157-
//////// REFERENCE STARDUST COMPONENTS IN TEST APP's MAIN FILE ///////
158155
logger("STEP 3. Reference Stardust components in test project's App.tsx")
159156
fs.copyFileSync(scaffoldPath('App.tsx'), testAppPath('src', 'App.tsx'))
160157

161-
//////// BUILD TEST PROJECT ///////
162158
logger('STEP 4. Build test project..')
163159
await runInTestApp(`yarn build`)
164160

build/gulp/tasks/test-vulns.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ const SCAN_RESULTS_DIR_PATH = paths.base(SCAN_RESULTS_DIR_NAME)
1414
const log = message => debug.log(message)
1515
log.success = message => debug.log(`✔ ${message}`)
1616

17-
const ensureDirExists = path => {
18-
if (!fs.existsSync(path)) {
19-
sh(`mkdir -p ${path}`)
17+
const ensureDirExists = directoryPath => {
18+
if (!fs.existsSync(directoryPath)) {
19+
sh(`mkdir -p ${directoryPath}`)
2020
}
2121
}
2222

docs/src/app.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react'
2-
import * as _ from 'lodash'
32
import { Provider, themes } from '@stardust-ui/react'
43

54
import { mergeThemes } from 'src/lib'

docs/src/components/ComponentDoc/ComponentPropsTable/ComponentPropsRow.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ export default class ComponentPropsRow extends React.Component<any, any> {
4343
<td>
4444
<ComponentPropDescription description={description} />
4545
{/* TODO change these according to the react-docgen-typescript generated json */}
46-
{/*<ComponentPropFunctionSignature name={name} tags={tags} />*/}
47-
{/*<ComponentPropEnum*/}
48-
{/*showAll={showEnums}*/}
49-
{/*toggle={this.toggleEnums}*/}
50-
{/*type={type}*/}
51-
{/*values={value}*/}
52-
{/*/>*/}
46+
{/* <ComponentPropFunctionSignature name={name} tags={tags} /> */}
47+
{/* <ComponentPropEnum */}
48+
{/* showAll={showEnums} */}
49+
{/* toggle={this.toggleEnums} */}
50+
{/* type={type} */}
51+
{/* values={value} */}
52+
{/* /> */}
5353
</td>
5454
</tr>
5555
)

docs/src/components/ComponentDoc/PerfChart/PerfDataProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const PerfDataProvider: React.FC = ({ children }) => {
2727
setData(responseJson)
2828
setLoading(false)
2929
})
30-
.catch(error => {
31-
setError(error)
30+
.catch(e => {
31+
setError(e)
3232
setLoading(false)
3333
})
3434
}

docs/src/components/ComponentPlayground.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ type ComponentPlaygroundProps = {
1313
}
1414

1515
const ComponentPlayground: React.FunctionComponent<ComponentPlaygroundProps> = props => {
16-
const playgroundPath = _.find(playgroundPaths, playgroundPath =>
16+
const resultPath = _.find(playgroundPaths, playgroundPath =>
1717
_.includes(playgroundPath, `/${props.componentName}/`),
1818
)
1919

20-
if (playgroundPath) {
21-
const PlaygroundComponent: React.FunctionComponent = examplePlaygroundContext(playgroundPath)
20+
if (resultPath) {
21+
const PlaygroundComponent: React.FunctionComponent = examplePlaygroundContext(resultPath)
2222
.default
2323

2424
return (

docs/src/components/DocsBehaviorRoot.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class DocsBehaviorRoot extends React.Component<any, any> {
6161
<>
6262
<strong>Description:</strong>
6363
<br />
64-
{variation.description.split('\n').map((splittedText, keyValue) => (
65-
<span key={keyValue}>
64+
{variation.description.split('\n').map((splittedText, key) => (
65+
<span key={key}>
6666
{splittedText}
6767
<br />
6868
</span>
@@ -74,8 +74,8 @@ class DocsBehaviorRoot extends React.Component<any, any> {
7474
{variation.description && <br />}
7575
<strong>Specification:</strong>
7676
<br />
77-
{variation.specification.split('\n').map((splittedText, keyValue) => (
78-
<span key={keyValue}>
77+
{variation.specification.split('\n').map((splittedText, key) => (
78+
<span key={key}>
7979
{splittedText}
8080
<br />
8181
</span>

docs/src/components/ExternalExampleLayout.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ class ExternalExampleLayout extends React.Component<
4747
const { exampleName } = this.props.match.params
4848
const exampleFilename = exampleKebabNameToSourceFilename(exampleName)
4949

50-
const examplePath = _.find(examplePaths, path => {
51-
const { exampleName } = parseExamplePath(path)
52-
return exampleFilename === exampleName
53-
})
50+
const examplePath = _.find(
51+
examplePaths,
52+
path => exampleFilename === parseExamplePath(path).exampleName,
53+
)
5454

5555
if (!examplePath) return <PageNotFound />
5656

docs/src/examples/components/Chat/Content/ChatExampleReactionGroupMeReacting.shorthand.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react'
2-
import * as _ from 'lodash'
32
import { Avatar, Chat } from '@stardust-ui/react'
43

54
const reactions = [

docs/src/examples/components/Provider/Types/ProviderExample.shorthand.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as React from 'react'
22
import { Provider } from '@stardust-ui/react'
33

4-
const theme = { siteVariables: { brand: 'cornflowerblue' } }
4+
const customTheme = { siteVariables: { brand: 'cornflowerblue' } }
55

66
const ProviderExampleShorthand = () => (
7-
<Provider theme={theme}>
7+
<Provider theme={customTheme}>
88
<div>
99
<p>
1010
Use the <code>Provider.Consumer</code> to access the <code>theme</code>:

docs/src/prototypes/chatPane/services/dateUtils.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export const getRandomDates = (count, daysAgo: number): Date[] => {
2222
].slice(0, count)
2323
}
2424

25-
export const getTimestamp = (date: Date): { short: string; long: string } => {
26-
const dateMoment = moment(date)
25+
export const getTimestamp = (inputDate: Date): { short: string; long: string } => {
26+
const dateMoment = moment(inputDate)
2727
const timeString = dateMoment.format('LT')
2828

2929
return {
@@ -32,17 +32,17 @@ export const getTimestamp = (date: Date): { short: string; long: string } => {
3232
}
3333
}
3434

35-
export const getFriendlyDateString = (date: Date): string => {
35+
export const getFriendlyDateString = (inputDate: Date): string => {
3636
const momentNow = moment()
37-
if (areMomentsSameDay(momentNow, date)) {
37+
if (areMomentsSameDay(momentNow, inputDate)) {
3838
return 'Today'
3939
}
4040

41-
if (areMomentsSameDay(momentNow.subtract(1, 'd'), date)) {
41+
if (areMomentsSameDay(momentNow.subtract(1, 'd'), inputDate)) {
4242
return 'Yesterday'
4343
}
4444

45-
return moment(date).format('LL')
45+
return moment(inputDate).format('LL')
4646
}
4747

4848
export const areSameDay = (d1: Date, d2: Date): boolean => areMomentsSameDay(moment(d1), d2)

docs/src/prototypes/chatPane/services/messageFactoryMock.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ function createMessageContent(message: MessageData): ShorthandValue {
8787
}
8888

8989
function createMessageContentWithAttachments(content: string, messageId: string): JSX.Element {
90-
const menuClickHandler = content => e => {
91-
alert(`${content} clicked`)
90+
const menuClickHandler = message => e => {
91+
alert(`${message} clicked`)
9292
e.stopPropagation()
9393
}
9494

docs/src/prototypes/mentions/MentionsDropdown.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react'
2-
import * as _ from 'lodash'
32
import { FontWeightProperty } from 'csstype'
43
import { Dropdown, DropdownItemProps, Provider } from '@stardust-ui/react'
54

packages/internal-tooling/eslint/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ module.exports = {
99
rules: {
1010
// False positive on arg types:
1111
// https://github.com/typescript-eslint/typescript-eslint/issues/46
12-
// '@typescript-eslint/no-unused-vars': ['error', { args: 'none' }],
12+
'@typescript-eslint/no-unused-vars': ['error', { args: 'none' }],
13+
1314
'import/no-unresolved': 'off',
1415
'prettier/prettier': 'error',
1516
'react/jsx-filename-extension': ['error', { extensions: ['.js', '.tsx'] }],
17+
'no-shadow': 'off', // https://github.com/stardust-ui/react/pull/1261#pullrequestreview-231005092
18+
'no-unused-vars': 'off', // we use @typescript-eslint/no-unused-vars instead
1619
semi: ['error', 'never'],
1720

1821
// Temporary disabled rules
19-
'@typescript-eslint/no-unused-vars': 'off',
2022
'jsx-a11y/click-events-have-key-events': 'off',
2123
'jsx-a11y/no-static-element-interactions': 'off',
2224
'jsx-a11y/alt-text': 'off',
@@ -83,20 +85,17 @@ module.exports = {
8385
'no-restricted-syntax': 'off',
8486
'no-throw-literal': 'off',
8587
'no-sparse-arrays': 'off',
86-
'no-shadow': 'off',
8788
'no-undef': 'off',
8889
'no-undef-init': 'off',
8990
'no-underscore-dangle': 'off',
9091
'no-unused-expressions': 'off',
9192
'no-useless-return': 'off',
92-
'no-unused-vars': 'off',
9393
'no-empty-function': 'off',
9494
'no-useless-constructor': 'off',
9595
'no-useless-escape': 'off',
9696
'no-use-before-define': 'off',
9797
'operator-assignment': 'off',
9898
'prefer-destructuring': 'off',
99-
'spaced-comment': 'off',
10099
},
101100
overrides: [
102101
{

packages/react/src/components/Avatar/Avatar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Avatar extends UIComponent<ReactProps<AvatarProps>, any> {
8080
const initials = reducedName
8181
.split(' ')
8282
.filter(item => item !== '')
83-
.map(name => name.charAt(0))
83+
.map(item => item.charAt(0))
8484
.reduce((accumulator, currentValue) => accumulator + currentValue)
8585

8686
if (initials.length > 2) {

packages/react/src/components/Dropdown/Dropdown.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ class Dropdown extends AutoControlledComponent<Extendable<DropdownProps>, Dropdo
978978
e: React.SyntheticEvent,
979979
item: ShorthandValue,
980980
predefinedProps: DropdownSelectedItemProps,
981-
DropdownSelectedItemProps: DropdownSelectedItemProps,
981+
dropdownSelectedItemProps: DropdownSelectedItemProps,
982982
rtl: boolean,
983983
) {
984984
const { activeSelectedIndex, value } = this.state as {
@@ -991,7 +991,7 @@ class Dropdown extends AutoControlledComponent<Extendable<DropdownProps>, Dropdo
991991
switch (keyboardKey.getCode(e)) {
992992
case keyboardKey.Delete:
993993
case keyboardKey.Backspace:
994-
this.handleSelectedItemRemove(e, item, predefinedProps, DropdownSelectedItemProps)
994+
this.handleSelectedItemRemove(e, item, predefinedProps, dropdownSelectedItemProps)
995995
break
996996
case previousKey:
997997
if (value.length > 0 && !_.isNil(activeSelectedIndex) && activeSelectedIndex > 0) {
@@ -1016,7 +1016,7 @@ class Dropdown extends AutoControlledComponent<Extendable<DropdownProps>, Dropdo
10161016
default:
10171017
break
10181018
}
1019-
_.invoke(predefinedProps, 'onKeyDown', e, DropdownSelectedItemProps)
1019+
_.invoke(predefinedProps, 'onKeyDown', e, dropdownSelectedItemProps)
10201020
}
10211021

10221022
private handleTriggerButtonOrListFocus = () => {
@@ -1039,13 +1039,13 @@ class Dropdown extends AutoControlledComponent<Extendable<DropdownProps>, Dropdo
10391039
e: React.SyntheticEvent,
10401040
item: ShorthandValue,
10411041
predefinedProps: DropdownSelectedItemProps,
1042-
DropdownSelectedItemProps: DropdownSelectedItemProps,
1042+
dropdownSelectedItemProps: DropdownSelectedItemProps,
10431043
) {
10441044
this.trySetState({ activeSelectedIndex: null })
10451045
this.removeItemFromValue(item)
10461046
this.tryFocusSearchInput()
10471047
this.tryFocusTriggerButton()
1048-
_.invoke(predefinedProps, 'onRemove', e, DropdownSelectedItemProps)
1048+
_.invoke(predefinedProps, 'onRemove', e, dropdownSelectedItemProps)
10491049
}
10501050

10511051
private removeItemFromValue(item?: ShorthandValue) {

0 commit comments

Comments
 (0)