Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

[v8.x] Cherrypick more non-breaking changes from master #816

Merged
merged 6 commits into from
Apr 25, 2018
2 changes: 1 addition & 1 deletion docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ command. The results of this command can be returned with `call`, which is loade
```js
const { Neutrino } = require('neutrino');

const eslintConfig = Neutrino()
const eslintConfig = Neutrino({ root: __dirname })
.use('.neutrinorc.js')
.call('eslintrc');
```
Expand Down
13 changes: 1 addition & 12 deletions docs/middleware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,6 @@ module.exports = {
};
```

```js
// Array format being used within an object-format .neutrinorc.js
module.exports = {
use: [
['@neutrinojs/react', {
devServer: { port: 3000 }
}]
]
};
```

```js
// Array format being used within function format
module.exports = neutrino => {
Expand Down Expand Up @@ -244,7 +233,7 @@ module.exports = (neutrino, additionalVars = []) => neutrino.config
```

```js
// react preset (which is also middleware)
// env preset (which is also middleware)
const env = require('@neutrinojs/env');

module.exports = neutrino => {
Expand Down
2 changes: 1 addition & 1 deletion docs/migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ For a concrete example, `.eslintrc.js`, which utilizes these changes, would migr
```js
const { Neutrino } = require('neutrino');

module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('.neutrinorc.js')
.call('eslintrc');
```
Expand Down
4 changes: 2 additions & 2 deletions docs/packages/airbnb-base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ const { Neutrino } = require('neutrino');
// Specify middleware to Neutrino prior to calling eslintrc.
// Even if using .neutrinorc.js, you must specify it when using
// the API
module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('.neutrinorc.js')
.call('eslintrc');
```
Expand All @@ -275,7 +275,7 @@ const { Neutrino } = require('neutrino');
// Specify middleware to Neutrino prior to calling eslintrc.
// You can choose to not use .neutrinorc.js as the middleware to
// use if you prefer, specifying any middleware you wish.
module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('@neutrinojs/airbnb-base', {
eslint: {
rules: { semi: 'off' }
Expand Down
6 changes: 3 additions & 3 deletions docs/packages/airbnb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ config, following the [Airbnb styleguide](https://github.com/airbnb/javascript).

[![NPM version][npm-image]][npm-url]
[![NPM downloads][npm-downloads]][npm-url]
[![Join the Neutrino community on Spectrum][spectrum-image]][spectrum-url]
[![Join the Neutrino community on Spectrum][spectrum-image]][spectrum-url]

## Features

Expand Down Expand Up @@ -258,7 +258,7 @@ const { Neutrino } = require('neutrino');
// Specify middleware to Neutrino prior to calling eslintrc.
// Even if using .neutrinorc.js, you must specify it when using
// the API
module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('.neutrinorc.js')
.call('eslintrc');
```
Expand All @@ -272,7 +272,7 @@ const { Neutrino } = require('neutrino');
// Specify middleware to Neutrino prior to calling eslintrc.
// You can choose to not use .neutrinorc.js as the middleware to
// use if you prefer, specifying any middleware you wish.
module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('@neutrinojs/airbnb', {
eslint: {
rules: { semi: 'off' }
Expand Down
4 changes: 2 additions & 2 deletions docs/packages/eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const { Neutrino } = require('neutrino');
// Specify middleware to Neutrino prior to calling eslintrc.
// Even if using .neutrinorc.js, you must specify it when using
// the API
module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('.neutrinorc.js')
.call('eslintrc');
```
Expand All @@ -156,7 +156,7 @@ _Example: Create a .eslintrc.js file in the root of the project, using specified
// .eslintrc.js
const { Neutrino } = require('neutrino');

module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('@neutrinojs/eslint', {
eslint: {
rules: { semi: 'off' }
Expand Down
4 changes: 2 additions & 2 deletions docs/packages/standardjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ const { Neutrino } = require('neutrino');
// Specify middleware to Neutrino prior to calling eslintrc.
// Even if using .neutrinorc.js, you must specify it when using
// the API
module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('.neutrinorc.js')
.call('eslintrc');
```
Expand All @@ -270,7 +270,7 @@ _Example: Create a .eslintrc.js file in the root of the project, using specified
// .eslintrc.js
const { Neutrino } = require('neutrino');

module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('@neutrinojs/standardjs', {
eslint: {
rules: { semi: 'error' }
Expand Down
51 changes: 42 additions & 9 deletions docs/packages/style-loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ Using a string to define loaders will cause `@neutrinojs/style-loader` to still
will be used as the `loader` property, `options` will be left blank, and the `useId` will be derived from
`cssUseId` option above plus the index of this loader within the `loaders` array.

**Important: The `useId` for string-defined loaders will start at `2`, since all loaders are preceded by the included
`style-loader` and `css-loader`.**
**Important:** The `useId` for string-defined loaders will start at `2`, since all loaders are preceded by the included
`style-loader` and `css-loader`.

```js
module.exports = {
Expand All @@ -156,14 +156,8 @@ module.exports = {
},
{
loader: 'postcss-loader',
useId: 'postcss',
options: {
config: {

// Where to look for config (postcss.config.js)
// https://github.com/postcss/postcss-loader#path
path: neutrino.options.root
}
plugins: [require('autoprefixer')]
}
}
]
Expand All @@ -190,6 +184,45 @@ module.exports = {
Due to the inferred loader names, we highly recommend you stick to using objects
to define loaders.

### Loader Configuration

You can configure loaders directly by passing `options`.
For PostCSS, if you want to use an [external config file](https://github.com/michael-ciniawsky/postcss-load-config),
you need to pass `options.config`:

```js
// .neutrinorc.js
module.exports = {
use: ['@neutrinojs/style-loader', {
loaders: [
{
loader: 'postcss-loader',
useId: 'postcss',
options: {
config: {

// Where to look for config (postcss.config.js)
// https://github.com/postcss/postcss-loader#path
// See "Loader Configuration" below
path: neutrino.options.root
}
}
}
]
}]
}
```

```js
// .postcssrc.js
// Example: load tailwindcss plugin
module.exports = {
plugins: {
tailwindcss: {},
}
};
```

## Customization

`@neutrinojs/style-loader` creates some conventions to make overriding the configuration easier once you are
Expand Down
4 changes: 2 additions & 2 deletions docs/packages/stylelint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const { Neutrino } = require('neutrino');
// Specify middleware to Neutrino prior to calling stylelintrc.
// Even if using .neutrinorc.js, you must specify it when using
// the API
module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('.neutrinorc.js')
.call('stylelintrc');
```
Expand All @@ -106,7 +106,7 @@ _Example: Create a .stylelintrc.js file in the root of the project, using specif
// .stylelintrc.js
const { Neutrino } = require('neutrino');

module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('@neutrinojs/stylelint', {
config: {
rules: { 'max-empty-lines': 2 }
Expand Down
4 changes: 2 additions & 2 deletions packages/airbnb-base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ const { Neutrino } = require('neutrino');
// Specify middleware to Neutrino prior to calling eslintrc.
// Even if using .neutrinorc.js, you must specify it when using
// the API
module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('.neutrinorc.js')
.call('eslintrc');
```
Expand All @@ -275,7 +275,7 @@ const { Neutrino } = require('neutrino');
// Specify middleware to Neutrino prior to calling eslintrc.
// You can choose to not use .neutrinorc.js as the middleware to
// use if you prefer, specifying any middleware you wish.
module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('@neutrinojs/airbnb-base', {
eslint: {
rules: { semi: 'off' }
Expand Down
6 changes: 3 additions & 3 deletions packages/airbnb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ config, following the [Airbnb styleguide](https://github.com/airbnb/javascript).

[![NPM version][npm-image]][npm-url]
[![NPM downloads][npm-downloads]][npm-url]
[![Join the Neutrino community on Spectrum][spectrum-image]][spectrum-url]
[![Join the Neutrino community on Spectrum][spectrum-image]][spectrum-url]

## Features

Expand Down Expand Up @@ -258,7 +258,7 @@ const { Neutrino } = require('neutrino');
// Specify middleware to Neutrino prior to calling eslintrc.
// Even if using .neutrinorc.js, you must specify it when using
// the API
module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('.neutrinorc.js')
.call('eslintrc');
```
Expand All @@ -272,7 +272,7 @@ const { Neutrino } = require('neutrino');
// Specify middleware to Neutrino prior to calling eslintrc.
// You can choose to not use .neutrinorc.js as the middleware to
// use if you prefer, specifying any middleware you wish.
module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('@neutrinojs/airbnb', {
eslint: {
rules: { semi: 'off' }
Expand Down
13 changes: 9 additions & 4 deletions packages/create-project/commands/init/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,15 @@ module.exports = class Project extends Generator {

if (this.data.linter) {
this.log(`${chalk.green('⏳ Performing one-time lint')}`);
this.spawnCommandSync(packages.NEUTRINO, ['lint', '--fix'], {
stdio: this.options.stdio === 'inherit' ? 'ignore' : this.options.stdio,
cwd: this.options.directory
});
this.spawnCommandSync(packageManager,
isYarn
? ['lint', '--fix']
: ['run', 'lint', '--fix'],
{
stdio: this.options.stdio === 'inherit' ? 'ignore' : this.options.stdio,
env: process.env,
cwd: this.options.directory
});
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const { Neutrino } = require('neutrino');
// Specify middleware to Neutrino prior to calling eslintrc.
// Even if using .neutrinorc.js, you must specify it when using
// the API
module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('.neutrinorc.js')
.call('eslintrc');
```
Expand All @@ -156,7 +156,7 @@ _Example: Create a .eslintrc.js file in the root of the project, using specified
// .eslintrc.js
const { Neutrino } = require('neutrino');

module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('@neutrinojs/eslint', {
eslint: {
rules: { semi: 'off' }
Expand Down
3 changes: 2 additions & 1 deletion packages/react-components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ module.exports = (neutrino, opts = {}) => {
title: 'React Preview'
},
manifest: process.env.NODE_ENV === 'development',
externals: opts.externals !== false && {}
externals: opts.externals !== false && {},
style: { extract: { plugin: { filename: '[name].css' } } }
}, opts);

neutrino.config.resolve.modules
Expand Down
4 changes: 2 additions & 2 deletions packages/standardjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ const { Neutrino } = require('neutrino');
// Specify middleware to Neutrino prior to calling eslintrc.
// Even if using .neutrinorc.js, you must specify it when using
// the API
module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('.neutrinorc.js')
.call('eslintrc');
```
Expand All @@ -270,7 +270,7 @@ _Example: Create a .eslintrc.js file in the root of the project, using specified
// .eslintrc.js
const { Neutrino } = require('neutrino');

module.exports = Neutrino()
module.exports = Neutrino({ root: __dirname })
.use('@neutrinojs/standardjs', {
eslint: {
rules: { semi: 'error' }
Expand Down
Loading