Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
kategengler committed Mar 22, 2023
1 parent cdcdccb commit 213f5ec
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 35 deletions.
14 changes: 10 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ module.exports = {
legacyDecorators: true,
},
},
extends: [
'eslint:recommended',
'plugin:prettier/recommended',
],
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
env: {
browser: true,
},
Expand Down Expand Up @@ -44,6 +41,15 @@ module.exports = {
plugins: ['n'],
extends: ['plugin:n/recommended'],
},
{
// node test files
files: ['node-tests/**/*-test.js'],
plugins: ['mocha'],
extends: ['plugin:mocha/recommended'],
rules: {
'n/no-unpublished-require': 'off',
},
},
{
// test files
files: ['tests/**/*-test.{js,ts}'],
Expand Down
4 changes: 2 additions & 2 deletions addon-config/targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ module.exports = {
'ie 9',
'last 1 Chrome versions',
'last 1 Firefox versions',
'last 1 Safari versions'
]
'last 1 Safari versions',
],
};
21 changes: 15 additions & 6 deletions broccoli-clean-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ class CleanCSSFilter extends BroccoliPersistentFilter {
cacheKeyProcessString(string, relativePath) {
this.optionsHash = this.optionsHash || jsonStableStringify(this.options);

return `${this.optionsHash}${super.cacheKeyProcessString(string, relativePath)}`;
return `${this.optionsHash}${super.cacheKeyProcessString(
string,
relativePath
)}`;
}

setupCleanCSS() {
let inputPath = this.inputPaths[0];
let cleanCSSOptions = Object.assign({}, this.options.cleanCSS, { returnPromise: true });
let cleanCSSOptions = Object.assign({}, this.options.cleanCSS, {
returnPromise: true,
});

if (cleanCSSOptions.rebaseTo) {
cleanCSSOptions.rebaseTo = path.join(inputPath, cleanCSSOptions.rebaseTo);
Expand All @@ -35,17 +40,21 @@ class CleanCSSFilter extends BroccoliPersistentFilter {
}

build() {
if (!this.cleanCSS) { this.setupCleanCSS(); }
if (!this.cleanCSS) {
this.setupCleanCSS();
}

return super.build();
}

processString(contents, relativePath) {
let fullPath = path.resolve(this.inputPaths[0], relativePath);

return this.cleanCSS.minify({
[fullPath]: { styles: contents }
}).then(result => result.styles);
return this.cleanCSS
.minify({
[fullPath]: { styles: contents },
})
.then((result) => result.styles);
}
}

Expand Down
16 changes: 10 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ module.exports = {
name: require('./package').name,

setupPreprocessorRegistry(type, registry) {
if (type !== 'parent') { return; }
if (type !== 'parent') {
return;
}

let addon = this;

Expand All @@ -14,14 +16,16 @@ module.exports = {
toTree(tree) {
let minifyOptions = addon._findHost().options.minifyCSS;

if (!minifyOptions.enabled) { return tree; }
if (!minifyOptions.enabled) {
return tree;
}

const CleanCSSPlugin = require('./broccoli-clean-css');

return new CleanCSSPlugin(tree, {
cleanCSS: minifyOptions.options
cleanCSS: minifyOptions.options,
});
}
})
}
},
});
},
};
14 changes: 10 additions & 4 deletions node-tests/minify-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ const fs = require('fs');
const execa = require('execa');
const assert = require('assert');

describe('ember-cli-clean-css', function() {
it('minifies CSS files', function() {
describe('ember-cli-clean-css', function () {
it('minifies CSS files', function () {
this.timeout(60000);

return execa('ember', ['build', '--prod']).then(() => {
let content = fs.readFileSync(`${__dirname}/../dist/assets/dummy.css`, 'utf8');
assert.strictEqual(content, 'body{background:#ff8c00}.hello{font-family:sans-serif;font-size:40px;margin-top:30px;text-align:center}');
let content = fs.readFileSync(
`${__dirname}/../dist/assets/dummy.css`,
'utf8'
);
assert.strictEqual(
content,
'body{background:#ff8c00}.hello{font-family:sans-serif;font-size:40px;margin-top:30px;text-align:center}'
);
});
});
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@
"ember-source": "~4.8.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-mocha": "^10.1.0",
"eslint-plugin-n": "^15.6.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-qunit": "^7.3.1",
"execa": "^3.4.0",
"loader.js": "^4.7.0",
Expand Down
5 changes: 0 additions & 5 deletions tests/.eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion tests/dummy/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import config from 'dummy/config/environment';
let App = Ember.Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver
Resolver,
});

loadInitializers(App, config.modulePrefix);
Expand Down
15 changes: 10 additions & 5 deletions tests/helpers/module-for-acceptance.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import Ember from 'ember';
import startApp from '../helpers/start-app';
import destroyApp from '../helpers/destroy-app';

const { RSVP: { Promise } } = Ember;
const {
RSVP: { Promise },
} = Ember;

export default function(name, options = {}) {
export default function (name, options = {}) {
module(name, {
beforeEach() {
this.application = startApp();
Expand All @@ -16,8 +18,11 @@ export default function(name, options = {}) {
},

afterEach() {
let afterEach = options.afterEach && options.afterEach.apply(this, arguments);
return Promise.resolve(afterEach).then(() => destroyApp(this.application));
}
let afterEach =
options.afterEach && options.afterEach.apply(this, arguments);
return Promise.resolve(afterEach).then(() =>
destroyApp(this.application)
);
},
});
}
2 changes: 1 addition & 1 deletion tests/helpers/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const resolver = Resolver.create();

resolver.namespace = {
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix
podModulePrefix: config.podModulePrefix,
};

export default resolver;
13 changes: 13 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3851,6 +3851,14 @@ eslint-plugin-es@^4.1.0:
eslint-utils "^2.0.0"
regexpp "^3.0.0"

eslint-plugin-mocha@^10.1.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-mocha/-/eslint-plugin-mocha-10.1.0.tgz#69325414f875be87fb2cb00b2ef33168d4eb7c8d"
integrity sha512-xLqqWUF17llsogVOC+8C6/jvQ+4IoOREbN7ZCHuOHuD6cT5cDD4h7f2LgsZuzMAiwswWE21tO7ExaknHVDrSkw==
dependencies:
eslint-utils "^3.0.0"
rambda "^7.1.0"

eslint-plugin-n@^15.6.1:
version "15.6.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-n/-/eslint-plugin-n-15.6.1.tgz#f7e77f24abb92a550115cf11e29695da122c398c"
Expand Down Expand Up @@ -6993,6 +7001,11 @@ qunit@^2.19.2:
node-watch "0.7.3"
tiny-glob "0.2.9"

rambda@^7.1.0:
version "7.5.0"
resolved "https://registry.yarnpkg.com/rambda/-/rambda-7.5.0.tgz#1865044c59bc0b16f63026c6e5a97e4b1bbe98fe"
integrity sha512-y/M9weqWAH4iopRd7EHDEQQvpFPHj1AA3oHozE9tfITHUtTR7Z9PSlIRRG2l1GuW7sefC1cXFfIcF+cgnShdBA==

randombytes@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a"
Expand Down

0 comments on commit 213f5ec

Please sign in to comment.