Skip to content

Commit 505779d

Browse files
committed
Remove option aliases
[breaking change]
1 parent 7228608 commit 505779d

5 files changed

Lines changed: 12 additions & 232 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
* Bump eslint dependency to ^3.0.0 <http://eslint.org/blog/2016/07/eslint-v3.0.0-released>
66
* Use ES2015 syntax
7+
* Remove these deprecated option aliases:
8+
* `global`
9+
* `env`
10+
* `config`
11+
* `rulesdir`
12+
* `eslintrc`
13+
* Drop support for non-array `globals` option
714

815
## 2.1.0
916

README.md

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,14 @@ Or use the plugin API to do things like:
4343
```javascript
4444
gulp.src(['**/*.js','!node_modules/**'])
4545
.pipe(eslint({
46-
extends: 'eslint:recommended',
47-
parserOptions: {
48-
sourceType: 'module'
49-
},
5046
rules: {
5147
'my-custom-rule': 1,
5248
'strict': 2
5349
},
54-
globals: {
55-
'jQuery':false,
56-
'$':true
57-
},
50+
globals: [
51+
'jQuery',
52+
'$'
53+
],
5854
envs: [
5955
'browser'
6056
]
@@ -128,26 +124,12 @@ Type: `Array`
128124

129125
Specify a list of [environments](http://eslint.org/docs/user-guide/configuring#specifying-environments) to be applied.
130126

131-
Type: `Object`
132-
133-
Specify [environments](http://eslint.org/docs/user-guide/configuring#specifying-environments). Each key must match an existing env definition, and the key determines whether the env’s rules are applied (`true`) or not (`false`).
134-
135-
Note that setting an env to `false` will not override an env that is set to `true` in the _.eslintrc_ being extended.
136-
137-
Alias: `env` *(deprecated)*
138-
139127
#### options.rulePaths
140128

141129
Type: `Array`
142130

143131
This option allows you to specify additional directories from which to load rules files. This is useful when you have custom rules that aren't suitable for being bundled with ESLint. This option works much like the ESLint CLI's [rulesdir option](http://eslint.org/docs/user-guide/command-line-interface#rulesdir).
144132

145-
Type: `String` *(deprecated)*
146-
147-
Load a single rules file.
148-
149-
Alias: `rulesdir` *(deprecated)*
150-
151133
#### options.configFile
152134

153135
Type: `String`
@@ -166,8 +148,6 @@ Type: `Boolean`
166148

167149
When `false`, ESLint will not load [.eslintrc files](http://eslint.org/docs/user-guide/configuring#using-configuration-files).
168150

169-
Alias: `eslintrc` *(deprecated)*
170-
171151
### eslint(configFilePath)
172152

173153
Type: `String`

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const path = require('path');
1313
* @returns {stream} gulp file stream
1414
*/
1515
function gulpEslint(options) {
16-
options = util.migrateOptions(options);
16+
options = util.migrateOptions(options) || {};
1717
const linter = new CLIEngine(options);
1818

1919
function verify(str, filePath) {

test/util.js

Lines changed: 0 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -106,178 +106,11 @@ describe('utility methods', () => {
106106
});
107107

108108
describe('migrateOptions', () => {
109-
110109
it('should migrate a string config value to "configPath"', () => {
111-
112110
const options = util.migrateOptions('Config/Path');
113111
should.exist(options.configFile);
114112
options.configFile.should.equal('Config/Path');
115-
116-
});
117-
118-
it('should migrate a "config" value to "configPath"', () => {
119-
120-
const options = util.migrateOptions({
121-
config: 'Config/Path'
122-
});
123-
should.exist(options);
124-
should.exist(options.configFile);
125-
options.configFile.should.equal('Config/Path');
126-
127-
});
128-
129-
it('should convert a global(s) table to a list of set of CLI flags', () => {
130-
131-
const options = util.migrateOptions({
132-
globals: {
133-
a: false,
134-
b: true
135-
}
136-
});
137-
should.exist(options);
138-
should.exist(options.globals);
139-
options.globals.should.be.instanceof(Array).and.have.lengthOf(2);
140-
options.globals[0].should.equal('a');
141-
options.globals[1].should.equal('b:true');
142-
143-
});
144-
145-
it('should convert a env table to a list of active env keys', () => {
146-
147-
const options = util.migrateOptions({
148-
envs: {
149-
node: false,
150-
browser: true
151-
}
152-
});
153-
should.exist(options);
154-
should.exist(options.envs);
155-
options.envs.should.be.instanceof(Array).and.have.lengthOf(1);
156-
options.envs[0].should.equal('browser');
157-
158-
});
159-
160-
it('should migrate a "rulesdir" string to a "rulesPaths" array', () => {
161-
162-
const options = util.migrateOptions({
163-
rulesdir: 'Rules/Dir'
164-
});
165-
should.exist(options);
166-
should.exist(options.rulePaths);
167-
options.rulePaths.should.be.instanceof(Array).and.have.lengthOf(1);
168-
options.rulePaths[0].should.equal('Rules/Dir');
169-
170-
});
171-
172-
it('should migrate a "rulesdir" value to a "rulesPaths" value', () => {
173-
174-
const rulePaths = ['Rules/Dir'],
175-
options = util.migrateOptions({
176-
rulesdir: rulePaths
177-
});
178-
should.exist(options);
179-
should.exist(options.rulePaths);
180-
options.rulePaths.should.equal(rulePaths);
181-
182-
});
183-
184-
it('should migrate an "eslintrc" value to "useEslintrc"', () => {
185-
186-
const options = util.migrateOptions({
187-
eslintrc: true
188-
});
189-
should.exist(options);
190-
should.exist(options.useEslintrc);
191-
options.useEslintrc.should.equal(true);
192-
193113
});
194-
195-
it('should migrate an "extends" value to "baseConfig" (w/o baseConfig)', () => {
196-
197-
const options = util.migrateOptions({
198-
extends: 'eslint:recommended'
199-
});
200-
should.exist(options);
201-
should.exist(options.baseConfig);
202-
options.baseConfig.extends.should.equal('eslint:recommended');
203-
204-
});
205-
206-
it('should migrate an "extends" value to "baseConfig" (w/ baseConfig)', () => {
207-
208-
const options = util.migrateOptions({
209-
extends: 'eslint:recommended',
210-
baseConfig: {
211-
parser: 'babel-eslint'
212-
}
213-
});
214-
should.exist(options);
215-
should.exist(options.baseConfig);
216-
options.baseConfig.extends.should.equal('eslint:recommended');
217-
options.baseConfig.parser.should.equal('babel-eslint');
218-
219-
});
220-
221-
it('should migrate an "ecmaFeatures" value to "baseConfig"', () => {
222-
223-
const options = util.migrateOptions({
224-
ecmaFeatures: {
225-
templateStrings: true
226-
}
227-
});
228-
should.exist(options);
229-
should.exist(options.baseConfig);
230-
should.exist(options.baseConfig.ecmaFeatures);
231-
options.baseConfig.ecmaFeatures.templateStrings.should.equal(true);
232-
233-
});
234-
235-
it('should migrate "globals" to "baseConfig" in key-value format', () => {
236-
237-
const options = util.migrateOptions({
238-
// trigger migration to baseConfig
239-
ecmaFeatures: {},
240-
241-
// add global "token" identifier
242-
globals: {
243-
token: true
244-
}
245-
});
246-
247-
should.exist(options.baseConfig);
248-
should.exist(options.baseConfig.globals);
249-
options.baseConfig.globals.token.should.equal(true);
250-
should.exist(options.baseConfig.ecmaFeatures);
251-
252-
should.exist(options.globals);
253-
options.globals.should.be.instanceof(Array).and.have.lengthOf(1);
254-
options.globals[0].should.equal('token:true');
255-
256-
});
257-
258-
it('should migrate "envs" to "baseConfig" in key-value format', () => {
259-
260-
const options = util.migrateOptions({
261-
// trigger migration to baseConfig
262-
ecmaFeatures: {},
263-
264-
// use "browser" env
265-
envs: {
266-
browser: true
267-
}
268-
});
269-
270-
should.exist(options.baseConfig);
271-
should.exist(options.baseConfig.envs);
272-
options.baseConfig.envs.browser.should.equal(true);
273-
should.exist(options.baseConfig.ecmaFeatures);
274-
275-
should.exist(options.envs);
276-
options.envs.should.be.instanceof(Array).and.have.lengthOf(1);
277-
options.envs[0].should.equal('browser');
278-
279-
});
280-
281114
});
282115

283116
describe('isErrorMessage', () => {

util.js

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -60,46 +60,6 @@ exports.migrateOptions = function migrateOptions(options) {
6060
options = {
6161
configFile: options
6262
};
63-
} else {
64-
options = Object.assign({}, options);
65-
}
66-
67-
if (options.extends || options.ecmaFeatures) {
68-
// nest options as baseConfig, since it's basically an .eslintrc config file
69-
options.baseConfig = Object.assign(options.baseConfig || {}, options, {baseConfig: null});
70-
}
71-
72-
options.globals = options.globals || options.global;
73-
if (options.globals != null && !Array.isArray(options.globals)) {
74-
options.globals = Object.keys(options.globals).map(key => {
75-
return options.globals[key] ? key + ':true' : key;
76-
});
77-
}
78-
79-
options.envs = options.envs || options.env;
80-
if (options.envs != null && !Array.isArray(options.envs)) {
81-
options.envs = Object.keys(options.envs).filter(key => {
82-
return options.envs[key];
83-
});
84-
}
85-
86-
if (options.config != null) {
87-
// The "config" option has been deprecated. Use "configFile".
88-
options.configFile = options.config;
89-
}
90-
91-
if (options.rulesdir != null) {
92-
// The "rulesdir" option has been deprecated. Use "rulePaths".
93-
if (typeof options.rulesdir === 'string') {
94-
options.rulePaths = [options.rulesdir];
95-
} else {
96-
options.rulePaths = options.rulesdir;
97-
}
98-
}
99-
100-
if (options.eslintrc != null) {
101-
// The "eslintrc" option has been deprecated. Use "useEslintrc".
102-
options.useEslintrc = options.eslintrc;
10363
}
10464

10565
return options;

0 commit comments

Comments
 (0)