Skip to content

Commit

Permalink
Release candidate
Browse files Browse the repository at this point in the history
* Lint the config using...itself 😱
* Add self-linting as test script
* Implement Cordova's four main ESLint configs

  - node
  - node-tests
  - browser
  - browser-tests

* Transform to scoped package
* Add coarse node engine restriction
* feat: commit package-lock.json
  • Loading branch information
raphinesse authored and erisu committed Nov 5, 2019
1 parent cbae969 commit 6972a0c
Show file tree
Hide file tree
Showing 13 changed files with 1,589 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.yml
@@ -0,0 +1,2 @@
root: true
extends: ./index.js
53 changes: 51 additions & 2 deletions README.md
@@ -1,2 +1,51 @@
# eslint-config-cordova
Cordova ESLint Config
# @cordova/eslint-config
This repository centralizes the ESLint configuration used for Cordova's development.

## Installation

`eslint-config-cordova` comes with all plugins configs and even `eslint` itself. So all you need to do to get started is:

npm i -D @cordova/eslint-config


## Usage
```yml
# In package.json
{
"scripts": {
"eslint": "eslint ."
}
}
```

```yml
# In .eslintrc.yml
root: true
extends: '@cordova/eslint-config/node'
```

```yml
# In spec/.eslintrc.yml
extends: '@cordova/eslint-config/node-tests'
```

```yml
# In cordova-js-src/.eslintrc.yml
extends: '@cordova/eslint-config/browser'
```

## Reference

This package exposes the following shareable ESLint configurations:

### `@cordova/eslint-config/node` (or simply `@cordova`)
For linting scripts intended to be run with Node.js.

### `@cordova/eslint-config/node-tests`
For linting Jasmine tests of Cordova's Node.js scripts.

### `@cordova/eslint-config/browser`
For linting cordova-style CommonJS modules intended to be run in the browser (before they are bundled).

### `@cordova/eslint-config/browser-tests`
For linting Jasmine tests of Cordova's browser code.
30 changes: 30 additions & 0 deletions browser-tests.js
@@ -0,0 +1,30 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

module.exports = {
extends: [
'./lib/base.js',
'./lib/browser.js',
'./lib/tests.js'
],

globals: {
cordova: false
}
};
29 changes: 29 additions & 0 deletions browser.js
@@ -0,0 +1,29 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

module.exports = {
extends: [
'./lib/base.js',
'./lib/browser.js'
],

env: {
commonjs: true
}
};
16 changes: 1 addition & 15 deletions index.js
Expand Up @@ -17,18 +17,4 @@
under the License.
*/

module.exports = {
globals: {
cordova: true
},

extends: ['semistandard'],

rules: {
indent: ['error', 4],
camelcase: 'off',
'padded-blocks': 'off',
'operator-linebreak': 'off',
'no-throw-literal': 'off'
}
};
module.exports = require('./node');
36 changes: 36 additions & 0 deletions lib/base.js
@@ -0,0 +1,36 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

module.exports = {
extends: 'semistandard',

env: {
// `semistandard` sets this to true. We reset it here,
// to make the config extend logic clearer.
node: false
},

rules: {
indent: ['error', 4],
camelcase: 'off',
'padded-blocks': 'off',
'operator-linebreak': 'off',
'no-throw-literal': 'off'
}
};
24 changes: 24 additions & 0 deletions lib/browser.js
@@ -0,0 +1,24 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

module.exports = {
env: {
browser: true
}
};
24 changes: 24 additions & 0 deletions lib/node.js
@@ -0,0 +1,24 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

module.exports = {
env: {
node: true
}
};
24 changes: 24 additions & 0 deletions lib/tests.js
@@ -0,0 +1,24 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

module.exports = {
env: {
jasmine: true
}
};
26 changes: 26 additions & 0 deletions node-tests.js
@@ -0,0 +1,26 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

module.exports = {
extends: [
'./lib/base.js',
'./lib/node.js',
'./lib/tests.js'
]
};
25 changes: 25 additions & 0 deletions node.js
@@ -0,0 +1,25 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

module.exports = {
extends: [
'./lib/base.js',
'./lib/node.js'
]
};

0 comments on commit 6972a0c

Please sign in to comment.