Skip to content

Commit adb36b7

Browse files
committed
rename eslint config file & update eslint rules
1 parent 730a586 commit adb36b7

File tree

13 files changed

+85
-62
lines changed

13 files changed

+85
-62
lines changed

packages/react-dom/src/__tests__/ReactDOMComponent-test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,10 @@ describe('ReactDOMComponent', () => {
443443
});
444444

445445
it('should not set null/undefined attributes', () => {
446-
var container = document.createElement('div');
446+
const container = document.createElement('div');
447447
// Initial render.
448448
ReactDOM.render(<img src={null} data-foo={undefined} />, container);
449-
var node = container.firstChild;
449+
const node = container.firstChild;
450450
expect(node.hasAttribute('src')).toBe(false);
451451
expect(node.hasAttribute('data-foo')).toBe(false);
452452
// Update in one direction.
@@ -468,9 +468,9 @@ describe('ReactDOMComponent', () => {
468468
});
469469

470470
it('should apply React-specific aliases to HTML elements', () => {
471-
var container = document.createElement('div');
471+
const container = document.createElement('div');
472472
ReactDOM.render(<form acceptCharset="foo" />, container);
473-
var node = container.firstChild;
473+
const node = container.firstChild;
474474
// Test attribute initialization.
475475
expect(node.getAttribute('accept-charset')).toBe('foo');
476476
expect(node.hasAttribute('acceptCharset')).toBe(false);
@@ -501,9 +501,9 @@ describe('ReactDOMComponent', () => {
501501
});
502502

503503
it('should apply React-specific aliases to SVG elements', () => {
504-
var container = document.createElement('div');
504+
const container = document.createElement('div');
505505
ReactDOM.render(<svg arabicForm="foo" />, container);
506-
var node = container.firstChild;
506+
const node = container.firstChild;
507507
// Test attribute initialization.
508508
expect(node.getAttribute('arabic-form')).toBe('foo');
509509
expect(node.hasAttribute('arabicForm')).toBe(false);
@@ -543,9 +543,9 @@ describe('ReactDOMComponent', () => {
543543
});
544544

545545
it('should not apply React-specific aliases to custom elements', () => {
546-
var container = document.createElement('div');
546+
const container = document.createElement('div');
547547
ReactDOM.render(<some-custom-element arabicForm="foo" />, container);
548-
var node = container.firstChild;
548+
const node = container.firstChild;
549549
// Should not get transformed to arabic-form as SVG would be.
550550
expect(node.getAttribute('arabicForm')).toBe('foo');
551551
expect(node.hasAttribute('arabic-form')).toBe(false);

packages/react-dom/src/__tests__/validateDOMNesting-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
'use strict';
1111

12-
var React = require('react');
13-
var ReactDOM = require('react-dom');
12+
const React = require('react');
13+
const ReactDOM = require('react-dom');
1414

1515
function normalizeCodeLocInfo(str) {
1616
return str && str.replace(/at .+?:\d+/g, 'at **');

packages/react-dom/src/events/forks/EventListener-www.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow
88
*/
99

10-
var EventListenerWWW = require('EventListener');
10+
const EventListenerWWW = require('EventListener');
1111

1212
import typeof * as EventListenerType from '../EventListener';
1313
import typeof * as EventListenerShimType from './EventListener-www';

scripts/babel/__tests__/transform-prevent-infinite-loops-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
7+
'use strict';
78

89
describe('transform-prevent-infinite-loops', () => {
910
// Note: instead of testing the transform by applying it,

scripts/eslint/es5Config.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

scripts/eslint/esNextConfig.js

Lines changed: 0 additions & 9 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* Copyright (c) 2013-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
'use strict';
9+
110
const eslintrc = require('../../.eslintrc');
211

312
const ERROR = 2;
@@ -6,13 +15,13 @@ module.exports = Object.assign({}, eslintrc, {
615
parser: 'espree',
716
parserOptions: {
817
ecmaVersion: 2017,
9-
sourceType: 'module',
18+
sourceType: 'script',
1019
ecmaFeatures: {
11-
jsx: true,
1220
experimentalObjectRestSpread: true,
1321
},
1422
},
1523
rules: Object.assign({}, eslintrc.rules, {
1624
'no-var': ERROR,
25+
strict: ERROR,
1726
}),
1827
});

scripts/eslint/eslintrc.npm.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Copyright (c) 2013-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
'use strict';
9+
10+
const eslintrc = require('../../.eslintrc');
11+
12+
module.exports = Object.assign({}, eslintrc, {
13+
parser: 'espree',
14+
parserOptions: {
15+
ecmaVersion: 5,
16+
sourceType: 'script',
17+
},
18+
});

scripts/eslint/eslintrc.source.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Copyright (c) 2013-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
'use strict';
9+
10+
const eslintrc = require('../../.eslintrc');
11+
12+
const ERROR = 2;
13+
14+
module.exports = Object.assign({}, eslintrc, {
15+
rules: Object.assign({}, eslintrc.rules, {
16+
'no-var': ERROR,
17+
}),
18+
});

scripts/eslint/index.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,34 @@
88
'use strict';
99

1010
const CLIEngine = require('eslint').CLIEngine;
11-
const {es5Path, es6Path, esNextPath} = require('../shared/esPath');
11+
const {npmPath, nodePath, sourcePath} = require('../shared/esPath');
1212

13-
const es5Options = {
14-
configFile: `${__dirname}/es5Config.js`,
15-
ignorePattern: [...es6Path, ...esNextPath],
13+
const npmOptions = {
14+
configFile: `${__dirname}/eslintrc.npm.js`,
15+
ignorePattern: [...nodePath, ...sourcePath],
1616
};
1717

18-
const es6Options = {
19-
configFile: `${__dirname}/es6Config.js`,
20-
ignorePattern: [...es5Path, ...esNextPath],
18+
const nodeOptions = {
19+
configFile: `${__dirname}/eslintrc.node.js`,
20+
ignorePattern: [...npmPath, ...sourcePath],
2121
};
2222

23-
const esNextOptions = {
24-
configFile: `${__dirname}/esNextConfig.js`,
25-
ignorePattern: [...es5Path, ...es6Path],
23+
const sourceOptions = {
24+
configFile: `${__dirname}/eslintrc.source.js`,
25+
ignorePattern: [...npmPath, ...nodePath],
2626
};
2727

2828
module.exports = function lintOnFiles({ecmaVersion, filePatterns}) {
2929
let options;
3030
switch (ecmaVersion) {
3131
case '5':
32-
options = es5Options;
32+
options = npmOptions;
3333
break;
3434
case '6':
35-
options = es6Options;
35+
options = nodeOptions;
3636
break;
3737
case 'next':
38-
options = esNextOptions;
38+
options = sourceOptions;
3939
break;
4040
default:
4141
console.error('ecmaVersion only accpet value: "5", "6", "next"');

0 commit comments

Comments
 (0)