Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stylelint dependencies #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions generator/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const chalk = require('chalk');
const { chalk } = require('@vue/cli-shared-utils');
const lint = require('../lint');

module.exports = (api, options = {}) => {
Expand All @@ -17,7 +17,9 @@ module.exports = (api, options = {}) => {
scripts: {
'lint:style': 'vue-cli-service lint:style',
},
devDependencies: {},
devDependencies: {
stylelint: '^12.0.0',
},
vue: {
pluginOptions: {
lintStyleOnBuild: lintStyleOn.includes('build'),
Expand Down
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const StyleLintPlugin = require('stylelint-webpack-plugin');
const CodeframeFormatter = require('stylelint-codeframe-formatter');
/* eslint-disable global-require */

const lint = require('./lint');

module.exports = (api, projectOptions) => {
const { loadModule } = require('@vue/cli-shared-utils');
const cwd = api.resolve('.');
const StyleLintPlugin = loadModule('stylelint-webpack-plugin', cwd, true) || require('stylelint-webpack-plugin');
const CodeframeFormatter = loadModule('stylelint-codeframe-formatter', cwd, true) || require('stylelint-codeframe-formatter');
const { pluginOptions: { lintStyleOnBuild, stylelint } } = projectOptions;
if (lintStyleOnBuild) {
api.chainWebpack((webpackConfig) => {
Expand Down
14 changes: 7 additions & 7 deletions lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
"props": true,
"ignorePropertyModificationsFor": ["args"]
}],
no-console: "off"
no-console: "off",
global-require: 0
*/

const { chalk, loadModule } = require('@vue/cli-shared-utils');
const { execSync } = require('child_process');
const chalk = require('chalk');
const stylelint = require('stylelint');
const CodeframeFormatter = require('stylelint-codeframe-formatter');


// helpers ==========================
function camelize(str) {
Expand Down Expand Up @@ -45,13 +43,15 @@ function format(label, msg) {


module.exports = async function lint(api, args = {}, pluginOptions = {}) {
const cwd = api.resolve('.');
const stylelint = loadModule('stylelint', cwd, true) || require('stylelint');
const CodeframeFormatter = loadModule('stylelint-codeframe-formatter', cwd, true) || require('stylelint-codeframe-formatter');

if (args.options) {
execSync('stylelint --help', { stdio: 'inherit' });
return;
}

const cwd = api.resolve('.');

const files = args._ && args._.length ? args._ : ['src/**/*.{vue,htm,html,css,sss,less,scss}'];
if (args['no-fix']) {
args.fix = false;
Expand Down
Loading