Skip to content

Commit

Permalink
Add import/no-commonjs lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Apr 2, 2018
1 parent bbee7e5 commit 11feb3b
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 29 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
}
],
"global-require": "off",
"import/no-commonjs": "error",
"key-spacing": "off",
"no-eq-null": "off",
"no-lonely-if": "off",
Expand Down
6 changes: 2 additions & 4 deletions docs/components/expression-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ for (const name in CompoundExpression.definitions) {

delete types['error'];

const expressions = {};
const expressionGroups = {};
export const expressions = {};
export const expressionGroups = {};
for (const name in types) {
const spec = ref['expression_name'].values[name];
expressionGroups[spec.group] = expressionGroups[spec.group] || [];
Expand All @@ -228,5 +228,3 @@ function processParameters(params) {
return [{repeat: [toString(params.type)]}];
}
}

module.exports = {expressions, expressionGroups};
4 changes: 2 additions & 2 deletions docs/pages/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import {highlightJavascript} from '../components/prism_highlight.js';
import Quickstart from '../components/quickstart';
import docs from '../components/api.json'; // eslint-disable-line import/no-unresolved
import GithubSlugger from 'github-slugger';
import createFormatters from 'documentation/lib/output/util/formatters';
import LinkerStack from 'documentation/lib/output/util/linker_stack';

const meta = {
title: 'Mapbox GL JS API',
description: '',
pathname: '/api'
};

const createFormatters = require('documentation/lib/output/util/formatters');
const LinkerStack = require('documentation/lib/output/util/linker_stack');

const linkerStack = new LinkerStack({})
.namespaceResolver(docs, (namespace) => {
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/style-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ const navigation = [
const sourceTypes = ['vector', 'raster', 'raster-dem', 'geojson', 'image', 'video', 'canvas'];
const layerTypes = ['background', 'fill', 'line', 'symbol', 'raster', 'circle', 'fill-extrusion', 'heatmap', 'hillshade'];

const {expressions, expressionGroups} = require('../components/expression-metadata');
import {expressions, expressionGroups} from '../components/expression-metadata';

const groupedExpressions = [
'Types',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
"test-unit": "build/run-tap --reporter classic --no-coverage test/unit",
"test-render": "node --max-old-space-size=2048 test/render.test.js",
"test-query": "node test/query.test.js",
"test-expressions": "node test/expression.test.js",
"test-expressions": "build/run-node test/expression.test.js",
"test-flow": "node build/generate-flow-typed-style-spec && flow .",
"test-flow-cov": "flow-coverage-report -i 'src/**/*.js' -t html",
"test-cov": "nyc --require=@mapbox/flow-remove-types/register --reporter=text-summary --reporter=lcov --cache run-s test-unit test-expressions test-query test-render",
Expand Down
2 changes: 1 addition & 1 deletion src/shaders/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// We use brfs, a browserify transform, to inline shader sources during bundling. As a result:
// - readFileSync calls must be written out long-form
// - this module must use CommonJS rather than ES2015 syntax
/* eslint-disable prefer-template, no-path-concat, import/unambiguous */
/* eslint-disable prefer-template, no-path-concat, import/unambiguous, import/no-commonjs */

const fs = require('fs');

Expand Down
2 changes: 1 addition & 1 deletion test/build/browserify-test-fixture.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/* eslint-disable import/unambiguous */
/* eslint-disable import/unambiguous, import/no-commonjs */
require('../..');
7 changes: 3 additions & 4 deletions test/build/min.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import fs from 'fs';
import path from 'path';
import reference from '../../src/style-spec/reference/latest';
import { Linter } from 'eslint';

const pkg = require('../../package.json');
import { scripts } from '../../package.json';

const minBundle = fs.readFileSync('dist/mapbox-gl.js', 'utf8');

Expand All @@ -16,8 +15,8 @@ test('production build removes asserts', (t) => {
test('trims package.json assets', (t) => {
// confirm that the entire package.json isn't present by asserting
// the absence of each of our script strings
for (const name in pkg.scripts) {
t.assert(minBundle.indexOf(pkg.scripts[name]) === -1);
for (const name in scripts) {
t.assert(minBundle.indexOf(scripts[name]) === -1);
}
t.end();
});
Expand Down
3 changes: 3 additions & 0 deletions test/build/style-spec.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

/* eslint-disable import/no-commonjs */

const test = require('mapbox-gl-js-test').test;
const fs = require('fs');
const path = require('path');
Expand Down
14 changes: 4 additions & 10 deletions test/expression.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@

/* eslint-disable import/unambiguous, no-global-assign */

require('@mapbox/flow-remove-types/register');
require = require("@std/esm")(module, true);

const expressionSuite = require('./integration').expression;
const { createPropertyExpression } = require('../src/style-spec/expression');
const { toString } = require('../src/style-spec/expression/types');
const ignores = require('./ignores.json');
import { expression as expressionSuite } from './integration';
import { createPropertyExpression } from '../src/style-spec/expression';
import { toString } from '../src/style-spec/expression/types';
import ignores from './ignores.json';

let tests;

Expand Down
1 change: 1 addition & 0 deletions test/integration/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"node"
],
"rules": {
"import/no-commonjs": "off",
"node/no-unsupported-features": ["error", {
"version": 4
}]
Expand Down
2 changes: 1 addition & 1 deletion test/query.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/unambiguous,no-global-assign */
/* eslint-disable import/unambiguous, import/no-commonjs, no-global-assign */

require('./stub_loader');
require('@mapbox/flow-remove-types/register');
Expand Down
2 changes: 1 addition & 1 deletion test/render.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/unambiguous,no-global-assign */
/* eslint-disable import/unambiguous, import/no-commonjs, no-global-assign */

require('./stub_loader');
require('@mapbox/flow-remove-types/register');
Expand Down
2 changes: 1 addition & 1 deletion test/stub_loader.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Load our stubbed ajax module for the integration suite implementation
/* eslint-disable import/unambiguous */
/* eslint-disable import/unambiguous, import/no-commonjs */
const fs = require('fs');
const assert = require('assert');
const pirates = require('pirates');
Expand Down
2 changes: 1 addition & 1 deletion test/suite_implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import path from 'path';
rtlTextPlugin['applyArabicShaping'] = rtlText.applyArabicShaping;
rtlTextPlugin['processBidirectionalText'] = rtlText.processBidirectionalText;

module.exports = function(style, options, _callback) {
module.exports = function(style, options, _callback) { // eslint-disable-line import/no-commonjs
let wasCallbackCalled = false;

const timeout = setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/ui/control/geolocate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import GeolocateControl from '../../../../src/ui/control/geolocate_control';
// window and navigator globals need to be set for mock-geolocation
global.window = {};
global.navigator = {};
const geolocation = require('mock-geolocation');
const geolocation = require('mock-geolocation'); // eslint-disable-line import/no-commonjs
geolocation.use();

// assign the mock geolocation to window
Expand Down

0 comments on commit 11feb3b

Please sign in to comment.