diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 6909c9dc..00000000 --- a/.babelrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "presets": [ - ["env", { - "modules": false, - "targets": { - "browsers": ["last 2 versions", "ie >= 9"] - } - }] - ] -} diff --git a/.commitlintrc b/.commitlintrc deleted file mode 100644 index 6311d83f..00000000 --- a/.commitlintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["@commitlint/config-angular"] -} diff --git a/.eslintrc b/.eslintrc index 8757045b..ae11e96b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,11 +3,28 @@ "env": { "browser": true }, + "root": true, "rules": { + "import/no-extraneous-dependencies": "off", "no-param-reassign": "off", "no-restricted-properties": "off", "valid-jsdoc": ["error", { "requireReturn": false }] - } + }, + "overrides": [ + { + "files": "test/**/*.js", + "env": { + "jquery": true, + "mocha": true + }, + "globals": { + "expect": true + }, + "rules": { + "no-unused-expressions": "off" + } + } + ] } diff --git a/.gitignore b/.gitignore index 7ea8e82f..f943c9ce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ -node_modules +*.local *.map -_* +coverage +node_modules diff --git a/.stylelintrc b/.stylelintrc new file mode 100644 index 00000000..eacc08cb --- /dev/null +++ b/.stylelintrc @@ -0,0 +1,10 @@ +{ + "extends": "stylelint-config-standard", + "plugins": [ + "stylelint-order" + ], + "rules": { + "no-descending-specificity": null, + "order/properties-alphabetical-order": true + } +} diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 00000000..33a422e6 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,17 @@ +module.exports = { + presets: [ + [ + '@babel/preset-env', + { + modules: false, + }, + ], + ], + env: { + test: { + plugins: [ + 'istanbul', + ], + }, + }, +}; diff --git a/postcss.config.js b/postcss.config.js index 0a8b3c9d..29f9daf8 100644 --- a/postcss.config.js +++ b/postcss.config.js @@ -3,13 +3,20 @@ const rollupConfig = require('./rollup.config'); module.exports = { plugins: { 'postcss-import': {}, - 'postcss-cssnext': {}, + 'postcss-preset-env': { + stage: 3, + features: { + 'nesting-rules': true, + }, + }, 'postcss-url': { url: 'inline', }, 'postcss-header': { header: rollupConfig.output[0].banner, }, - stylefmt: {}, + stylelint: { + fix: true, + }, }, }; diff --git a/rollup.config.js b/rollup.config.js index ef87ba67..fc5c060b 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,47 +1,45 @@ const babel = require('rollup-plugin-babel'); const commonjs = require('rollup-plugin-commonjs'); const nodeResolve = require('rollup-plugin-node-resolve'); +const changeCase = require('change-case'); +const createBanner = require('create-banner'); const pkg = require('./package'); -const now = new Date(); -const banner = `/*! - * Cropper v${pkg.version} - * https://github.com/${pkg.repository} - * - * Copyright (c) 2014-${now.getFullYear()} ${pkg.author.name} - * Released under the ${pkg.license} license - * - * Date: ${now.toISOString()} - */ -`; +const name = changeCase.pascalCase(pkg.name); +const banner = createBanner({ + data: { + name, + year: '2014-present', + }, +}); module.exports = { input: 'src/index.js', output: [ { banner, - file: 'dist/cropper.js', + name, + file: `dist/${pkg.name}.js`, format: 'umd', - name: 'Cropper', globals: { jquery: 'jQuery', }, }, { banner, - file: 'dist/cropper.common.js', + file: `dist/${pkg.name}.common.js`, format: 'cjs', }, { banner, - file: 'dist/cropper.esm.js', + file: `dist/${pkg.name}.esm.js`, format: 'es', }, { banner, - file: 'docs/js/cropper.js', + name, + file: `docs/js/${pkg.name}.js`, format: 'umd', - name: 'Cropper', globals: { jquery: 'jQuery', }, @@ -51,8 +49,6 @@ module.exports = { plugins: [ nodeResolve(), commonjs(), - babel({ - plugins: ['external-helpers'], - }), + babel(), ], };