Skip to content

Commit c629186

Browse files
authored
Merge pull request #1715 from golopot/eslint-7
[Tests] Add eslint 7 to CI - [patch] refactor to use non-deprecated function in eslint 7
2 parents 71ca88f + 5c67f17 commit c629186

16 files changed

+119
-145
lines changed

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ node_js:
1010
os: linux
1111

1212
env:
13+
- ESLINT_VERSION=^7.0.0-0
1314
- ESLINT_VERSION=6
1415
- ESLINT_VERSION=5
1516
- ESLINT_VERSION=4
@@ -65,8 +66,14 @@ matrix:
6566
env: ESLINT_VERSION=5
6667
- node_js: '4'
6768
env: ESLINT_VERSION=6
69+
- node_js: '4'
70+
env: ESLINT_VERSION=^7.0.0-0
6871
- node_js: '6'
6972
env: ESLINT_VERSION=6
73+
- node_js: '6'
74+
env: ESLINT_VERSION=^7.0.0-0
75+
- node_js: '8'
76+
env: ESLINT_VERSION=^7.0.0-0
7077

7178
fast_finish: true
7279
allow_failures:

src/rules/dynamic-import-chunkname.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ module.exports = {
4242

4343
const sourceCode = context.getSourceCode()
4444
const arg = node.arguments[0]
45-
const leadingComments = sourceCode.getComments(arg).leading
45+
const leadingComments = sourceCode.getCommentsBefore
46+
? sourceCode.getCommentsBefore(arg) // This method is available in ESLint >= 4.
47+
: sourceCode.getComments(arg).leading // This method is deprecated in ESLint 7.
4648

4749
if (!leadingComments || leadingComments.length === 0) {
4850
context.report({

tests/src/rules/exports-last.js

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import rule from 'rules/exports-last'
66
const ruleTester = new RuleTester()
77

88
const error = type => ({
9-
ruleId: 'exports-last',
109
message: 'Export statements should appear at the end of the file',
1110
type,
1211
})

tests/src/rules/no-absolute-path.js

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const ruleTester = new RuleTester()
66
, rule = require('rules/no-absolute-path')
77

88
const error = {
9-
ruleId: 'no-absolute-path',
109
message: 'Do not import modules using an absolute path',
1110
}
1211

tests/src/rules/no-cycle.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { RuleTester } from 'eslint'
55
const ruleTester = new RuleTester()
66
, rule = require('rules/no-cycle')
77

8-
const error = message => ({ ruleId: 'no-cycle', message })
8+
const error = message => ({ message })
99

1010
const test = def => _test(Object.assign(def, {
1111
filename: testFilePath('./cycles/depth-zero.js'),

tests/src/rules/no-default-export.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ ruleTester.run('no-default-export', rule, {
8989
test({
9090
code: 'export default function bar() {};',
9191
errors: [{
92-
ruleId: 'ExportDefaultDeclaration',
92+
type: 'ExportDefaultDeclaration',
9393
message: 'Prefer named exports.',
9494
}],
9595
}),
@@ -98,14 +98,14 @@ ruleTester.run('no-default-export', rule, {
9898
export const foo = 'foo';
9999
export default bar;`,
100100
errors: [{
101-
ruleId: 'ExportDefaultDeclaration',
101+
type: 'ExportDefaultDeclaration',
102102
message: 'Prefer named exports.',
103103
}],
104104
}),
105105
test({
106106
code: 'let foo; export { foo as default }',
107107
errors: [{
108-
ruleId: 'ExportNamedDeclaration',
108+
type: 'ExportNamedDeclaration',
109109
message: 'Do not alias `foo` as `default`. Just export `foo` itself ' +
110110
'instead.',
111111
}],
@@ -114,7 +114,7 @@ ruleTester.run('no-default-export', rule, {
114114
code: 'export default from "foo.js"',
115115
parser: require.resolve('babel-eslint'),
116116
errors: [{
117-
ruleId: 'ExportNamedDeclaration',
117+
type: 'ExportNamedDeclaration',
118118
message: 'Prefer named exports.',
119119
}],
120120
}),

tests/src/rules/no-dynamic-require.js

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const ruleTester = new RuleTester()
66
, rule = require('rules/no-dynamic-require')
77

88
const error = {
9-
ruleId: 'no-dynamic-require',
109
message: 'Calls to require() should use string literals',
1110
}
1211

tests/src/rules/no-extraneous-dependencies.js

-24
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
126126
filename: path.join(packageDirMonoRepoRoot, 'foo.js'),
127127
options: [{packageDir: packageDirMonoRepoRoot }],
128128
errors: [{
129-
ruleId: 'no-extraneous-dependencies',
130129
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
131130
}],
132131
}),
@@ -135,67 +134,58 @@ ruleTester.run('no-extraneous-dependencies', rule, {
135134
filename: path.join(packageDirMonoRepoWithNested, 'foo.js'),
136135
options: [{packageDir: packageDirMonoRepoRoot}],
137136
errors: [{
138-
ruleId: 'no-extraneous-dependencies',
139137
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
140138
}],
141139
}),
142140
test({
143141
code: 'import "not-a-dependency"',
144142
options: [{packageDir: packageDirMonoRepoRoot}],
145143
errors: [{
146-
ruleId: 'no-extraneous-dependencies',
147144
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
148145
}],
149146
}),
150147
test({
151148
code: 'import "not-a-dependency"',
152149
errors: [{
153-
ruleId: 'no-extraneous-dependencies',
154150
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
155151
}],
156152
}),
157153
test({
158154
code: 'var donthaveit = require("@org/not-a-dependency")',
159155
errors: [{
160-
ruleId: 'no-extraneous-dependencies',
161156
message: '\'@org/not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S @org/not-a-dependency\' to add it',
162157
}],
163158
}),
164159
test({
165160
code: 'var donthaveit = require("@org/not-a-dependency/foo")',
166161
errors: [{
167-
ruleId: 'no-extraneous-dependencies',
168162
message: '\'@org/not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S @org/not-a-dependency\' to add it',
169163
}],
170164
}),
171165
test({
172166
code: 'import "eslint"',
173167
options: [{devDependencies: false, peerDependencies: false}],
174168
errors: [{
175-
ruleId: 'no-extraneous-dependencies',
176169
message: '\'eslint\' should be listed in the project\'s dependencies, not devDependencies.',
177170
}],
178171
}),
179172
test({
180173
code: 'import "lodash.isarray"',
181174
options: [{optionalDependencies: false}],
182175
errors: [{
183-
ruleId: 'no-extraneous-dependencies',
184176
message: '\'lodash.isarray\' should be listed in the project\'s dependencies, not optionalDependencies.',
185177
}],
186178
}),
187179
test({
188180
code: 'var foo = require("not-a-dependency")',
189181
errors: [{
190-
ruleId: 'no-extraneous-dependencies',
191182
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
192183
}],
193184
}),
194185
test({
195186
code: 'var glob = require("glob")',
196187
options: [{devDependencies: false}],
197188
errors: [{
198-
ruleId: 'no-extraneous-dependencies',
199189
message: '\'glob\' should be listed in the project\'s dependencies, not devDependencies.',
200190
}],
201191
}),
@@ -204,7 +194,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
204194
options: [{devDependencies: ['*.test.js']}],
205195
filename: 'foo.tes.js',
206196
errors: [{
207-
ruleId: 'no-extraneous-dependencies',
208197
message: '\'chai\' should be listed in the project\'s dependencies, not devDependencies.',
209198
}],
210199
}),
@@ -213,7 +202,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
213202
options: [{devDependencies: ['*.test.js']}],
214203
filename: path.join(process.cwd(), 'foo.tes.js'),
215204
errors: [{
216-
ruleId: 'no-extraneous-dependencies',
217205
message: '\'chai\' should be listed in the project\'s dependencies, not devDependencies.',
218206
}],
219207
}),
@@ -222,7 +210,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
222210
options: [{devDependencies: ['*.test.js', '*.spec.js']}],
223211
filename: 'foo.tes.js',
224212
errors: [{
225-
ruleId: 'no-extraneous-dependencies',
226213
message: '\'chai\' should be listed in the project\'s dependencies, not devDependencies.',
227214
}],
228215
}),
@@ -231,39 +218,34 @@ ruleTester.run('no-extraneous-dependencies', rule, {
231218
options: [{devDependencies: ['*.test.js', '*.spec.js']}],
232219
filename: path.join(process.cwd(), 'foo.tes.js'),
233220
errors: [{
234-
ruleId: 'no-extraneous-dependencies',
235221
message: '\'chai\' should be listed in the project\'s dependencies, not devDependencies.',
236222
}],
237223
}),
238224
test({
239225
code: 'var eslint = require("lodash.isarray")',
240226
options: [{optionalDependencies: false}],
241227
errors: [{
242-
ruleId: 'no-extraneous-dependencies',
243228
message: '\'lodash.isarray\' should be listed in the project\'s dependencies, not optionalDependencies.',
244229
}],
245230
}),
246231
test({
247232
code: 'import "not-a-dependency"',
248233
options: [{packageDir: path.join(__dirname, '../../../')}],
249234
errors: [{
250-
ruleId: 'no-extraneous-dependencies',
251235
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
252236
}],
253237
}),
254238
test({
255239
code: 'import "bar"',
256240
options: [{packageDir: path.join(__dirname, './doesn-exist/')}],
257241
errors: [{
258-
ruleId: 'no-extraneous-dependencies',
259242
message: 'The package.json file could not be found.',
260243
}],
261244
}),
262245
test({
263246
code: 'import foo from "foo"',
264247
options: [{packageDir: packageDirWithSyntaxError}],
265248
errors: [{
266-
ruleId: 'no-extraneous-dependencies',
267249
message: 'The package.json file could not be parsed: ' + packageFileWithSyntaxErrorMessage,
268250
}],
269251
}),
@@ -272,15 +254,13 @@ ruleTester.run('no-extraneous-dependencies', rule, {
272254
filename: path.join(packageDirMonoRepoWithNested, 'foo.js'),
273255
options: [{packageDir: packageDirMonoRepoWithNested}],
274256
errors: [{
275-
ruleId: 'no-extraneous-dependencies',
276257
message: "'left-pad' should be listed in the project's dependencies. Run 'npm i -S left-pad' to add it",
277258
}],
278259
}),
279260
test({
280261
code: 'import react from "react";',
281262
filename: path.join(packageDirMonoRepoRoot, 'foo.js'),
282263
errors: [{
283-
ruleId: 'no-extraneous-dependencies',
284264
message: "'react' should be listed in the project's dependencies. Run 'npm i -S react' to add it",
285265
}],
286266
}),
@@ -289,7 +269,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
289269
filename: path.join(packageDirMonoRepoWithNested, 'foo.js'),
290270
options: [{packageDir: packageDirMonoRepoRoot}],
291271
errors: [{
292-
ruleId: 'no-extraneous-dependencies',
293272
message: "'react' should be listed in the project's dependencies. Run 'npm i -S react' to add it",
294273
}],
295274
}),
@@ -298,7 +277,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
298277
filename: path.join(packageDirWithEmpty, 'index.js'),
299278
options: [{packageDir: packageDirWithEmpty}],
300279
errors: [{
301-
ruleId: 'no-extraneous-dependencies',
302280
message: "'react' should be listed in the project's dependencies. Run 'npm i -S react' to add it",
303281
}],
304282
}),
@@ -319,14 +297,12 @@ ruleTester.run('no-extraneous-dependencies', rule, {
319297
test({
320298
code: 'export { foo } from "not-a-dependency";',
321299
errors: [{
322-
ruleId: 'no-extraneous-dependencies',
323300
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
324301
}],
325302
}),
326303
test({
327304
code: 'export * from "not-a-dependency";',
328305
errors: [{
329-
ruleId: 'no-extraneous-dependencies',
330306
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
331307
}],
332308
}),

0 commit comments

Comments
 (0)