Skip to content

Commit a4f9b86

Browse files
authored
Breaking: Migrate neutrino packages to 9.0.0-rc.4 (#14)
```js // Before without options: module.exports = { use: [ '@mozilla-frontend-infra/react-lint' ] }; // After without options: const reactLint = require('@mozilla-frontend-infra/react-lint'); module.exports = { use: [ reactLint() ] }; // Before with options: module.exports = { use: [ ['@mozilla-frontend-infra/react-lint', options] ] }; // After with options: const reactLint = require('@mozilla-frontend-infra/react-lint'); module.exports = { use: [ reactLint(options) ] }; ```
1 parent 527ab2b commit a4f9b86

File tree

11 files changed

+2491
-1359
lines changed

11 files changed

+2491
-1359
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.neutrinorc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
const nodeLint = require('./packages/node-lint');
2+
13
module.exports = {
24
use: [
3-
'./packages/node-lint',
5+
nodeLint(),
46
],
57
};

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"author": "Hassan Ali <[email protected]>",
55
"engines": {
66
"node": "^8.10 || >=10",
7-
"npm": ">=5.4.0",
8-
"yarn": ">=1.10.1"
7+
"npm": ">=6.10.0",
8+
"yarn": ">=1.17.0"
99
},
1010
"scripts": {
1111
"lint": "eslint --cache --format codeframe --ext js packages/* scripts",
@@ -19,9 +19,9 @@
1919
],
2020
"devDependencies": {
2121
"eslint": "^5.9.0",
22-
"lerna": "^3.4.3",
23-
"neutrino": "9.0.0-beta.1",
24-
"npm": "^6.4.1",
25-
"verdaccio": "^3.8.5"
22+
"lerna": "^3.18.1",
23+
"neutrino": "9.0.0-rc.4",
24+
"npm": "~6.4.1",
25+
"verdaccio": "^4.3.3"
2626
}
2727
}

packages/lint/index.js

Lines changed: 125 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const merge = require('deepmerge');
22

3-
module.exports = (neutrino, options = {}) => {
3+
module.exports = (options = {}) => {
44
if (!options.use) {
55
throw new Error(
66
'The linting middleware requires a base middleware to extend'
@@ -13,126 +13,132 @@ module.exports = (neutrino, options = {}) => {
1313
);
1414
}
1515

16-
const [airbnb, overrides] = options.use;
16+
return neutrino => {
17+
const [airbnb, overrides] = options.use;
1718

18-
neutrino.use(airbnb, {
19-
eslint: {
20-
emitWarning: process.env.NODE_ENV === 'development',
21-
baseConfig: {
22-
extends: ['prettier'],
23-
},
24-
plugins: ['prettier'],
25-
rules: {
26-
'import/no-extraneous-dependencies': 'off',
27-
// Specify the maximum length of a line in your program
28-
'max-len': [
29-
'error',
30-
80,
31-
2,
32-
{
33-
ignoreUrls: true,
34-
ignoreComments: false,
35-
ignoreStrings: true,
36-
ignoreTemplateLiterals: true,
19+
neutrino.use(
20+
airbnb({
21+
eslint: {
22+
emitWarning: process.env.NODE_ENV === 'development',
23+
baseConfig: {
24+
extends: ['prettier'],
3725
},
38-
],
39-
// Allow using class methods with static/non-instance functionality
40-
// React lifecycle methods commonly do not use an instance context for
41-
// anything
42-
'class-methods-use-this': 'off',
43-
// Allow console during development, otherwise throw an error
44-
'no-console': process.env.NODE_ENV === 'development' ? 'off' : 'error',
45-
// Allow extra parentheses since multiline JSX being wrapped in parens
46-
// is considered idiomatic
47-
'no-extra-parens': 'off',
48-
// Our frontend strives to adopt functional programming practices,
49-
// so we prefer const over let
50-
'prefer-const': 'error',
51-
'prettier/prettier': [
52-
'error',
53-
{
54-
singleQuote: true,
55-
trailingComma: 'es5',
56-
bracketSpacing: true,
57-
jsxBracketSameLine: true,
58-
tabWidth: 2,
59-
semi: true,
26+
plugins: ['prettier'],
27+
rules: {
28+
'import/no-extraneous-dependencies': 'off',
29+
// Specify the maximum length of a line in your program
30+
'max-len': [
31+
'error',
32+
80,
33+
2,
34+
{
35+
ignoreUrls: true,
36+
ignoreComments: false,
37+
ignoreStrings: true,
38+
ignoreTemplateLiterals: true,
39+
},
40+
],
41+
// Allow using class methods with static/non-instance functionality
42+
// React lifecycle methods commonly do not use
43+
// aninstance context for anything
44+
'class-methods-use-this': 'off',
45+
// Allow console during development, otherwise throw an error
46+
'no-console':
47+
process.env.NODE_ENV === 'development' ? 'off' : 'error',
48+
// Allow extra parentheses since multiline
49+
// JSX being wrapped in parens is considered
50+
// idiomatic
51+
'no-extra-parens': 'off',
52+
// Our frontend strives to adopt functional programming practices,
53+
// so we prefer const over let
54+
'prefer-const': 'error',
55+
'prettier/prettier': [
56+
'error',
57+
{
58+
singleQuote: true,
59+
trailingComma: 'es5',
60+
bracketSpacing: true,
61+
jsxBracketSameLine: true,
62+
tabWidth: 2,
63+
semi: true,
64+
},
65+
],
66+
'padding-line-between-statements': [
67+
'error',
68+
{
69+
blankLine: 'always',
70+
prev: ['const', 'let', 'var'],
71+
next: '*',
72+
},
73+
{
74+
blankLine: 'never',
75+
prev: ['const', 'let', 'var'],
76+
next: ['const', 'let', 'var'],
77+
},
78+
{
79+
blankLine: 'always',
80+
prev: ['cjs-import'],
81+
next: '*',
82+
},
83+
{
84+
blankLine: 'always',
85+
prev: ['import'],
86+
next: '*',
87+
},
88+
{
89+
blankLine: 'always',
90+
prev: '*',
91+
next: ['cjs-export'],
92+
},
93+
{
94+
blankLine: 'always',
95+
prev: '*',
96+
next: ['export'],
97+
},
98+
{
99+
blankLine: 'never',
100+
prev: ['import'],
101+
next: ['import'],
102+
},
103+
{
104+
blankLine: 'never',
105+
prev: ['cjs-import'],
106+
next: ['cjs-import'],
107+
},
108+
{
109+
blankLine: 'any',
110+
prev: ['export'],
111+
next: ['export'],
112+
},
113+
{
114+
blankLine: 'any',
115+
prev: ['cjs-export'],
116+
next: ['cjs-export'],
117+
},
118+
{ blankLine: 'always', prev: 'multiline-block-like', next: '*' },
119+
{
120+
blankLine: 'always',
121+
prev: '*',
122+
next: ['if', 'do', 'for', 'switch', 'try', 'while'],
123+
},
124+
{ blankLine: 'always', prev: '*', next: 'return' },
125+
],
126+
'consistent-return': 'off',
127+
'no-unused-expressions': 'off',
128+
'no-shadow': 'off',
129+
'no-return-assign': 'off',
130+
'babel/new-cap': 'off',
131+
'no-mixed-operators': 'off',
60132
},
61-
],
62-
'padding-line-between-statements': [
63-
'error',
64-
{
65-
blankLine: 'always',
66-
prev: ['const', 'let', 'var'],
67-
next: '*',
68-
},
69-
{
70-
blankLine: 'never',
71-
prev: ['const', 'let', 'var'],
72-
next: ['const', 'let', 'var'],
73-
},
74-
{
75-
blankLine: 'always',
76-
prev: ['cjs-import'],
77-
next: '*',
78-
},
79-
{
80-
blankLine: 'always',
81-
prev: ['import'],
82-
next: '*',
83-
},
84-
{
85-
blankLine: 'always',
86-
prev: '*',
87-
next: ['cjs-export'],
88-
},
89-
{
90-
blankLine: 'always',
91-
prev: '*',
92-
next: ['export'],
93-
},
94-
{
95-
blankLine: 'never',
96-
prev: ['import'],
97-
next: ['import'],
98-
},
99-
{
100-
blankLine: 'never',
101-
prev: ['cjs-import'],
102-
next: ['cjs-import'],
103-
},
104-
{
105-
blankLine: 'any',
106-
prev: ['export'],
107-
next: ['export'],
108-
},
109-
{
110-
blankLine: 'any',
111-
prev: ['cjs-export'],
112-
next: ['cjs-export'],
113-
},
114-
{ blankLine: 'always', prev: 'multiline-block-like', next: '*' },
115-
{
116-
blankLine: 'always',
117-
prev: '*',
118-
next: ['if', 'do', 'for', 'switch', 'try', 'while'],
119-
},
120-
{ blankLine: 'always', prev: '*', next: 'return' },
121-
],
122-
'consistent-return': 'off',
123-
'no-unused-expressions': 'off',
124-
'no-shadow': 'off',
125-
'no-return-assign': 'off',
126-
'babel/new-cap': 'off',
127-
'no-mixed-operators': 'off',
128-
},
129-
},
130-
});
133+
},
134+
})
135+
);
131136

132-
if (overrides) {
133-
neutrino.config.module
134-
.rule('lint')
135-
.use('eslint')
136-
.tap(opts => merge(opts, overrides));
137-
}
137+
if (overrides) {
138+
neutrino.config.module
139+
.rule('lint')
140+
.use('eslint')
141+
.tap(opts => merge(opts, overrides));
142+
}
143+
};
138144
};

packages/lint/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"repository": "https://github.com/mozilla-frontend-infra/lint/tree/master/packages/lint",
2424
"dependencies": {
2525
"deepmerge": "^2.2.1",
26-
"eslint-config-prettier": "^3.3.0",
27-
"eslint-plugin-prettier": "^3.0.1",
28-
"prettier": "^1.16.4"
26+
"eslint-config-prettier": "^6.4.0",
27+
"eslint-plugin-prettier": "^3.1.1",
28+
"prettier": "^1.18.2"
2929
}
3030
}

packages/node-lint/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ const airbnb = require('@neutrinojs/airbnb-base');
22
const lint = require('@mozilla-frontend-infra/lint');
33
const merge = require('deepmerge');
44

5-
module.exports = (neutrino, options = {}) => {
6-
neutrino.use(lint, {
7-
use: [airbnb],
8-
});
5+
module.exports = (options = {}) => neutrino => {
6+
neutrino.use(
7+
lint({
8+
use: [airbnb],
9+
})
10+
);
911

1012
neutrino.config.module
1113
.rule('lint')

packages/node-lint/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"repository": "https://github.com/mozilla-frontend-infra/lint/tree/master/packages/node-lint",
2424
"dependencies": {
2525
"@mozilla-frontend-infra/lint": "^1.2.1",
26-
"@neutrinojs/airbnb-base": "9.0.0-beta.1",
26+
"@neutrinojs/airbnb-base": "9.0.0-rc.4",
2727
"deepmerge": "^2.2.1"
2828
}
2929
}

0 commit comments

Comments
 (0)